Commit Graph

1497 Commits

Author SHA1 Message Date
Ted Kremenek e69a1fa342 Do not crash when performing VisitLValue on union types.
This fixes PR 2948.

llvm-svn: 58148
2008-10-25 20:09:21 +00:00
Zhongxing Xu 80422b07c5 Add StringLiteral test code.
llvm-svn: 58136
2008-10-25 14:11:23 +00:00
Argyrios Kyrtzidis 98ca36f009 Unbreak the test by.. removing a space. (clang protested that -verify only works on single input files).
llvm-svn: 58123
2008-10-24 22:25:11 +00:00
Argyrios Kyrtzidis 22c40fa285 -Add support for cv-qualifiers after function declarators.
-Add withConst/withVolatile/withRestrict methods to QualType class, that return the QualType plus the respective qualifier.

llvm-svn: 58120
2008-10-24 21:46:40 +00:00
Ted Kremenek 14e6350dcc This test no longer is marked XFAIL.
Enhance test to include a case where a tracked object escapes because it is stored to a local ivar through a method dispatch to 'self.'

llvm-svn: 58109
2008-10-24 20:33:56 +00:00
Douglas Gregor a8aa7a08b8 PR2942: FunctionDecls by typedef crash the C++ front-end
llvm-svn: 58100
2008-10-24 18:09:54 +00:00
Douglas Gregor 08d918a6c3 Semantic analysis for C++ reinterpret_cast and const_cast. Patch by Sebastian Redl.
llvm-svn: 58094
2008-10-24 15:36:09 +00:00
Zhongxing Xu d2f0c7b37b Add random array and struct test code for SCA.
llvm-svn: 58085
2008-10-24 08:51:58 +00:00
Daniel Dunbar 5043549666 Use #define trickery to de-XFAIL test/Coverage/codegen-gnu.m while
still getting coverage for non-IRgen cases.

llvm-svn: 58084
2008-10-24 08:42:52 +00:00
Daniel Dunbar 15fadeb9cf Use #define trickery to de-XFAIL test/Coverage/codegen-next.m while
still getting coverage for non-IRgen cases.

llvm-svn: 58082
2008-10-24 08:39:46 +00:00
Daniel Dunbar d7be95d60a PR2919: __builtin_types_compatible_p strips CRV qualifiers.
llvm-svn: 58079
2008-10-24 08:07:57 +00:00
Douglas Gregor 39c16d445e First non-embarrassing cut at checking for ambiguous derived-to-base
conversions.

Added PerformImplicitConversion, which follows an implicit conversion sequence
computed by TryCopyInitialization and actually performs the implicit
conversions, including the extra check for ambiguity mentioned above.

llvm-svn: 58071
2008-10-24 04:54:22 +00:00
Daniel Dunbar 340b5ddcf9 Fix regression in comparison of qualified id; == operator was being
created with LHS and RHS whose types didn't match.

llvm-svn: 58049
2008-10-23 23:30:52 +00:00
Ted Kremenek c5092cc061 Temporarily mark this test XFAIL.
llvm-svn: 58024
2008-10-23 01:57:31 +00:00
Douglas Gregor 5c407d9a9b Add support for conversions from a pointer-to-derived to a
pointer-to-base. Also, add overload ranking for pointer conversions
(for both pointer-to-void and derived-to-base pointer conversions).

Note that we do not yet diagnose derived-to-base pointer conversion
errors that stem from ambiguous or inacessible base classes. These
aren't handled during overload resolution; rather, when the conversion
is actually used we go ahead and diagnose the error.

llvm-svn: 58017
2008-10-23 00:40:37 +00:00
Ted Kremenek 631ff239fc Warn about potentially leaked objects that are returned from methods whose names do not follow the Cocoa Memory Management guidelines.
llvm-svn: 58012
2008-10-22 23:56:21 +00:00
Steve Naroff b0c653a649 Fix <rdar://problem/6311947> clang on xcode (regression): error: use of undeclared identifier 'expandedValue'.
Mea culpa: I introduced this regresson in the following 2 commits: r57529 (10/14), r57841 (10/20).

llvm-svn: 58007
2008-10-22 22:40:28 +00:00
Ted Kremenek 9a96bf22ec Enhance reference-count checker to correctly identify CG "release" functions. This fixes <rdar://problem/6303488>.
llvm-svn: 57997
2008-10-22 20:54:52 +00:00
Steve Naroff 1df62692f2 Fix <rdar://problem/6257675> error: member reference base type ('NSUserDefaults *') is not a structure or union.
Teach Sema::ActOnMemberReferenceExpr() to look through local category implementations associated with the class.

llvm-svn: 57995
2008-10-22 19:16:27 +00:00
Douglas Gregor 29a9247ec2 Add representation of base classes in the AST, and verify that we
don't have duplicated direct base classes.

Seriliazation of base class specifiers is not yet implemented.

llvm-svn: 57991
2008-10-22 17:49:05 +00:00
Zhongxing Xu da84f683c8 Add test case for FuncDecl and function pointer variable.
llvm-svn: 57979
2008-10-22 14:39:20 +00:00
Douglas Gregor e1eb9d8cc4 Implement ranking of standard conversion sequences by their qualification
conversions (e.g., comparing int* -> const int* against 
int* -> const volatile int*); see C++ 13.3.3.2p3 bullet 3.

Add Sema::UnwrapSimilarPointerTypes to simplify the control flow of
IsQualificationConversion and CompareQualificationConversion (and fix
the handling of the int* -> volatile int* conversion in the former).
 

llvm-svn: 57978
2008-10-22 14:17:15 +00:00
Douglas Gregor ea2d4211e5 Fix a thinko in the qualification-conversion check when the qualificaitons are disjoint, and add some overloading-based tests of qualification conversions
llvm-svn: 57942
2008-10-22 00:38:21 +00:00
Douglas Gregor 9a6579340f Initial step toward supporting qualification conversions (C++ 4.4).
Changes:
  - Sema::IsQualificationConversion determines whether we have a qualification
    conversion.
  - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++,
    performing an implicit conversion from the right-hand side to the type of
    the left-hand side rather than checking based on the C notion of 
    "compatibility". We now rely on the implicit-conversion code to
    determine whether the conversion can happen or
    not. Sema::TryCopyInitialization has an ugly reference-related
    hack to cope with the initialization of references, for now.
  - When building DeclRefExprs, strip away the reference type, since
    there are no expressions whose type is a reference. We'll need to
    do this throughout Sema.
  - Expr::isLvalue now permits functions to be lvalues in C++ (but not
  in C).

llvm-svn: 57935
2008-10-21 23:43:52 +00:00
Daniel Dunbar 29fa8354fc Add coverage of part of getPrimaryDecl that was failing prior to
previous commit.

llvm-svn: 57930
2008-10-21 21:32:38 +00:00
Steve Naroff e94444faf3 Fix <rdar://problem/6257645> clang static analyzer crashes when encountering blocks as objects
ASTContext::isObjCObjectPointerType() needs to consider blocks as objects.

llvm-svn: 57913
2008-10-21 18:21:45 +00:00
Douglas Gregor 5251f1b283 Preliminary support for function overloading
llvm-svn: 57909
2008-10-21 16:13:35 +00:00
Steve Naroff 90255b4f54 Fix a crasher during error recovery in Parser::ParseObjCTypeName().
Found this while fixing another unrelated radar.

llvm-svn: 57904
2008-10-21 14:15:04 +00:00
Gabor Greif 09a5cf89ca Tweak an expected-error to match the output. IMHO it is better to diagnose 'int (void)' because it has the same meaning in C and C++.
llvm-svn: 57901
2008-10-21 11:46:36 +00:00
Steve Naroff a0ed165a84 Fix <rdar://problem/6261178> clang-on-xcode: [sema] multiple method warning is over enthusiastic.
Fix <rdar://problem/6265257> warnings for ambiguous message send swamp other warnings.

Reworked Sema::MatchTwoMethodDeclarations() to optionally match based on method size and alignment (the default in GCC). Changed Sema::LookupInstanceMethodInGlobalPool() to use this feature.

Added -Wno-struct-selector-match to driver, however didn't hook it up yet. Added a FIXME that says this.

llvm-svn: 57898
2008-10-21 10:37:50 +00:00
Ted Kremenek c32ec3a0c4 Further improve path-sensitivity with divide-by-zero checking by assuming that a denominator cannot be zero even when the result of an '/' or '%' expression is unknown.
llvm-svn: 57855
2008-10-20 23:40:25 +00:00
Ted Kremenek e67437f3a9 Added test case inspired by <rdar://6268365>: recover path-sensitivity after compound assignment when the result of the assignment is not known.
llvm-svn: 57852
2008-10-20 23:14:31 +00:00
Steve Naroff bca9fd755d Fix <rdar://problem/6268365> Parser rejects property (dot notation) access on id<protocol>.
llvm-svn: 57850
2008-10-20 22:53:06 +00:00
Steve Naroff ea54d9ef72 Sema::CheckCompareOperands() and ASTContext::mergeTypes(): Change handling of ObjC qualified id types to be consistent with gcc. This changes a handful of test case errors into warnings (diff will tell you which cases have changed).
llvm-svn: 57841
2008-10-20 18:19:10 +00:00
Chris Lattner 64b1f2f030 More property attribute recovery improvements. Instead of this:
crash.m:8:12: error: type name requires a specifier or qualifier
@property (readonlyx, getter=isAwesome) int _awesome;
           ^
crash.m:8:29: error: expected ';' at end of declaration list
@property (readonlyx, getter=isAwesome) int _awesome;
                            ^
crash.m:8:39: error: expected identifier or '('
@property (readonlyx, getter=isAwesome) int _awesome;
                                      ^

we now get:

crash.m:8:12: error: unknown property attribute 'readonlyx'
@property (readonlyx, getter=isAwesome) int _awesome;
           ^

Also, we can eliminate isObjCPropertyAttribute now.

llvm-svn: 57811
2008-10-20 07:15:22 +00:00
Chris Lattner 55c53a3dd8 add testcase for the recovery improvements in my last patch.
llvm-svn: 57810
2008-10-20 07:03:51 +00:00
Chris Lattner 93429b047b fix a crash on unnamed properties like:
@property (readonly) int : 4;

llvm-svn: 57805
2008-10-20 06:33:53 +00:00
Chris Lattner da9fb15b90 refactor a bunch of code:
Check for @end in ParseObjCInterfaceDeclList instead of in each caller
Handle @required and @optional with the same code

Add some fixmes about some apparently objc2 code that is being accepted
in objc1.

llvm-svn: 57803
2008-10-20 06:10:06 +00:00
Chris Lattner 2a9d9897b7 Fix rdar://6257721 by tightening up the block "snapshot" check, and
move it to its own predicate to make it more clear.

llvm-svn: 57796
2008-10-20 05:16:36 +00:00
Chris Lattner 29e6f2b674 Support attributes in *yet another* place. Is there any place you
can't stick an attributes?

llvm-svn: 57795
2008-10-20 04:57:38 +00:00
Chris Lattner 8ff2c6c9f0 Fix a parser bug where we let attributes interfere with our disambiguation
of whether a '(' was a grouping paren or the start of a function declarator.
This is PR2796.

Now we eat the attribute before deciding whether the paren is grouping or
not, then apply it to the resultant decl or to the first argument as needed.

One somewhat surprising aspect of this is that attributes interact with
implicit int in cases like this:

void a(x, y) // k&r style function
void b(__attribute__(()) x, y); // function with two implicit int arguments
void c(x, __attribute__(()) y); // error, can't have attr in identifier list.

Fun stuff.

llvm-svn: 57790
2008-10-20 02:05:46 +00:00
Daniel Dunbar 70e3ebafdb Improve attribute parsing & tests.
- Support noreturn on function-typed variables.

 - Extend isFunctionOrMethod to return true for K&R functions and
   provide hasFunctionProto to check if a decl has information about
   its arguments. This code needs some serious cleaning, but works.

 - Add/improve test cases for noreturn and unused.

llvm-svn: 57778
2008-10-19 02:04:16 +00:00
Ted Kremenek f8d65a30d6 Add support in GRExprEngine for UnaryOperator::AlignOf. This fixes one crash report in PR 2796.
llvm-svn: 57777
2008-10-18 22:20:20 +00:00
Ted Kremenek fef1f30ea2 Use "VisitLValue" when processing the base for "x.f" field accesses, and "Visit" when processing the base for "x->f" field accesses.
llvm-svn: 57754
2008-10-18 03:28:48 +00:00
Mon P Wang 179a72f000 Added vec_set intrinsics
llvm-svn: 57749
2008-10-18 02:43:25 +00:00
Daniel Dunbar 6ccea71c64 Add some uses of PredefinedExpr to language coverage includes.
llvm-svn: 57744
2008-10-17 23:04:32 +00:00
Ted Kremenek 0b09ea54ba This test now passes again.
llvm-svn: 57742
2008-10-17 22:53:09 +00:00
Ted Kremenek 055891cbf3 Test now passes.
llvm-svn: 57718
2008-10-17 20:29:05 +00:00
Ted Kremenek 5870046c43 "Implement" GRExprEngine::VisitLValue for ObjCPropertyRefExpr. This is only a bandid; we need to properly handle properties by using locv/nonloc objects and specially handling property assignments in the transfer function for BinaryOperator.
llvm-svn: 57693
2008-10-17 17:24:14 +00:00
Daniel Dunbar 472175e545 Exercise #pragma pack(pop, <width>) in test case.
llvm-svn: 57683
2008-10-17 16:05:47 +00:00
Zhongxing Xu 0dd213f8f5 Add test case for array and struct variable lvalue evaluation.
llvm-svn: 57670
2008-10-17 05:19:52 +00:00
Daniel Dunbar 380827cfa1 Quick patch for PR2784, assert genereting debug info for opaque
structure.
 - I'm not sure yet about the behavior, but this at least prevents the
   crash.

Add some asserts on RegionStack usage.

llvm-svn: 57661
2008-10-17 01:07:56 +00:00
Ted Kremenek 7ff153c9cb Mark these tests XFAIL. We need to add back assumption logic when doing array and field accesses.
llvm-svn: 57658
2008-10-17 00:51:39 +00:00
Steve Naroff 9546eee50a Fix <rdar://problem/6239726> Parser rejects: type of property 'list' does not match type of ivar
and
http://llvm.org/bugs/show_bug.cgi?id=2893

llvm-svn: 57640
2008-10-16 14:59:30 +00:00
Daniel Dunbar c3d79cf6b3 Teach tryEvaluate that fabs, copysign, and unary +/- are constants for
floats.
 - With testcase, which also has some other things GCC folds but we
   don't commented out in it.

llvm-svn: 57624
2008-10-16 03:51:50 +00:00
Daniel Dunbar 4290d46bd4 Implement #pragma pack use in structure packing. The general approach
is to encode the state of the #pragma pack stack as an attribute when
the structure is declared. 

 - Extend PackedAttr to take an alignment (in bits), and reuse for
   both __attribute__((packed)) (which takes no argument, instead
   packing tightly (to "minimize the memory required") and for #pragma
   pack (which allows specification of the maximum alignment in
   bytes). __attribute__((packed)) is just encoded as Alignment=1.

   This conflates two related but different mechanisms, but it didn't
   seem worth another attribute.

 - I have attempted to follow the MSVC semantics as opposed to the gcc
   ones, since if I understand correctly #pragma pack originated with
   MSVC. The semantics are generally equivalent except when the stack
   is altered during the definition of a structure; its not clear if
   anyone does this in practice. See testcase if curious.

llvm-svn: 57623
2008-10-16 02:34:03 +00:00
Argyrios Kyrtzidis 84a4df8c92 Issue a warning when there's an ambiguous function declarator (that could be a direct initializer for a variable defition).
Idea originated from here: http://thread.gmane.org/gmane.comp.gcc.devel/101524

llvm-svn: 57609
2008-10-15 23:21:32 +00:00
Argyrios Kyrtzidis 2e3e756304 Fix this bug:
typedef int f();
struct S {
   f *x; // incorrectly assuming this is function decl, leading to failed assertions.
};

llvm-svn: 57598
2008-10-15 20:23:22 +00:00
Steve Naroff e17f52fc23 Tighten up blocks rewriter to handle casts and some other interesting cases.
This fixes <rdar://problem/6289007> clang block rewriter: ^ in cast is not rewritten.

llvm-svn: 57591
2008-10-15 18:38:58 +00:00
Ted Kremenek bb7818b666 Enhance dead store checker to not flag preincrements to dead variables where the preincrement is a subexpression, e.g. foo(++x); This can cause false negatives, but will remove a whole class of false positives.
llvm-svn: 57554
2008-10-15 05:23:41 +00:00
Daniel Dunbar 267c4fe1b5 Test commit.
llvm-svn: 57540
2008-10-15 00:26:06 +00:00
Steve Naroff 8afa98916a Downgrade incompatibilities with objc qualified types (e.g. id <P>) to warnings.
Note: One day, we should consider moving the actual diags to ObjCQualifiedIdTypesAreCompatible(), since it has more information on the actual problem. GCC currently emits slightly more instructive errors for some cases involving protocols. I added a FIXME to the code.

llvm-svn: 57529
2008-10-14 22:18:38 +00:00
Daniel Dunbar eee51d125f Fix typo in testcase.
llvm-svn: 57499
2008-10-14 16:46:03 +00:00
Chris Lattner 3211159cab add a testcase.
llvm-svn: 57479
2008-10-14 06:32:07 +00:00
Daniel Dunbar 5460374cd9 Add Sema implementation of #pragma pack stack.
- Follows the MSVC (original) implementation, including support of
   pack(show) (useful for testing).
 - Implements support for named pack records which gcc seems to
   ignore (or implements incorrectly).
 - Not currently wired to anything, only functionality change is the
   type checking of the pragma.

llvm-svn: 57476
2008-10-14 05:35:18 +00:00
Chris Lattner fc7d4a3bd2 Add a new -dump-raw-tokens option, which allows us to see raw tokens.
Rename -dumptokens to -dump-tokens.

llvm-svn: 57405
2008-10-12 05:03:36 +00:00
Seo Sanghyeon c9e7c272da Tests for return statement checks
llvm-svn: 57341
2008-10-10 07:20:06 +00:00
Argyrios Kyrtzidis 1207d31952 Fix a bug that crashed clang when parsing this:
class C {
  static const int number = 50;
  static int arr[number];
};

Here's how it worked:
-GetTypeForDeclarator was called from both Sema::ActOnCXXMemberDeclarator and Sema::ActOnDeclarator.
-VariableArrayTypes are not uniqued so two VariableArrayTypes were created with the same DeclRefExpr.
-On exit they both tried to destroy that one DeclRefExpr.

The fix is not to use GetTypeForDeclarator from the Sema::ActOnCXXMemberDeclarator.

llvm-svn: 57313
2008-10-08 22:20:31 +00:00
Argyrios Kyrtzidis 8ae3684aa9 In ParseParenDeclarator match "D.setGroupingParens(true);" with another setGroupingParens call after the ')' is parsed.
Fixes this bug:
  int (x)(0); // error, expected function declarator where the '(0)' initializer is

llvm-svn: 57241
2008-10-07 10:21:57 +00:00
Argyrios Kyrtzidis 9a1191c047 Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
This is how this kind of initializers appear in the AST:
-The Init expression of the VarDecl is a functional type construction (of the VarDecl's type).
-The new VarDecl::hasCXXDirectInitializer() returns true.

e.g, for "int x(1);":
-VarDecl 'x' has Init with expression "int(1)" (CXXFunctionalCastExpr).
-hasCXXDirectInitializer() of VarDecl 'x' returns true.

A major benefit is that clients that don't particularly care about which exactly form was the initializer can handle both cases without special case code.
Note that codegening works now for "int x(1);" without any changes to CodeGen.

llvm-svn: 57178
2008-10-06 17:10:33 +00:00
Chris Lattner 25728d931a fix incorrect rdar number.
llvm-svn: 57165
2008-10-06 07:43:28 +00:00
Chris Lattner 1b0a00a4c9 __CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329

llvm-svn: 57164
2008-10-06 07:43:09 +00:00
Chris Lattner a97132a9c4 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.

llvm-svn: 57163
2008-10-06 07:26:43 +00:00
Chris Lattner c43467526d "Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
condition as a constant even if the unevaluated side is a not a constant.
We don't do this when extensions are off, and we emit a warning when this 
happens:

t.c:22:11: warning: expression is not a constant, but is accepted as one by GNU extensions
short t = __builtin_constant_p(5353) ? 42 : somefunc();
          ^                                 ~~~~~~~~~~

suggestions for improvement are welcome.  This is obviously horrible, but
is required for real-world code.

llvm-svn: 57153
2008-10-06 05:42:39 +00:00
Argyrios Kyrtzidis e8addf5e04 Allow variadic arguments without named ones for C++, e.g. "void(...);"
llvm-svn: 57143
2008-10-06 00:07:55 +00:00
Argyrios Kyrtzidis 279d9814e5 Add some text from the C++ standard and additional ambiguity resolution tests.
No funcitonality change.

llvm-svn: 57136
2008-10-05 21:10:08 +00:00
Argyrios Kyrtzidis 2b1ef227f5 Handle ambiguities between expressions and type-ids that occur inside parentheses, e.g.:
sizeof(int()) -> "int()" is type-id
sizeof(int()+1) -> "int()+1" is expression.

llvm-svn: 57131
2008-10-05 19:56:22 +00:00
Argyrios Kyrtzidis df788f4eea Found a subtle bug caused by an implicit enum-to-bool conversion (of the TentativeParsingResult enum).
This was the motivation of the following changes:

-'TentativeParsingResult' enum is replaced by a 'TPResult' class that basically encapsulates the enum.
-TPR_true, TPR_false, TPR_ambiguous, and TPR_error enum constants are replaced by TPResult::True(), TPResult::False(), etc. calls that return a TPResult object.
-Also fixed the subtle bug in Parser::isCXXFunctionDeclarator (caught by the above changes as a compilation error).

llvm-svn: 57125
2008-10-05 18:52:21 +00:00
Anders Carlsson c181b01681 Add parsing of the sentinel attribute. Still need to create the attribute.
llvm-svn: 57121
2008-10-05 18:05:59 +00:00
Argyrios Kyrtzidis bc28fefcde Disambiguate between a declaration or an expression, in the 'for-init-statement' part of a 'for' statement.
llvm-svn: 57112
2008-10-05 15:50:46 +00:00
Argyrios Kyrtzidis 2534620b4e Fix Parser::isCXXConditionDeclaration to properly resolve declarations.
llvm-svn: 57111
2008-10-05 15:19:49 +00:00
Argyrios Kyrtzidis 71f3e19df0 Disambiguate between a declaration or expression for the 'condition' part of a if/switch/while/for statement.
llvm-svn: 57109
2008-10-05 15:03:47 +00:00
Argyrios Kyrtzidis 7b87f27438 Consider GNU attributes when doing ambiguity resolution.
llvm-svn: 57108
2008-10-05 14:27:18 +00:00
Daniel Dunbar 93bc49d882 Add X86 builtin code generation test case.
llvm-svn: 57104
2008-10-05 06:38:36 +00:00
Daniel Dunbar 363a5c0a1b Improve C language testing coverage.
llvm-svn: 57103
2008-10-05 06:36:33 +00:00
Daniel Dunbar b11d5d65e8 Add some builtins to codegen test case.
llvm-svn: 57101
2008-10-05 06:34:45 +00:00
Daniel Dunbar 0af89ff0fb Add -rewrite-macros test case.
llvm-svn: 57094
2008-10-05 01:39:04 +00:00
Daniel Dunbar 91d085e368 Coverage test for targets.
- This pushes us over 80% coverage of executable LOC.

llvm-svn: 57092
2008-10-05 01:04:25 +00:00
Daniel Dunbar 05d93dd73d Improve codegen coverage tests.
- Hit debug info generation.
 - Hit both ObjC runtimes.

llvm-svn: 57088
2008-10-05 00:31:54 +00:00
Argyrios Kyrtzidis 72d8149a1e Append the test runs with '&&'.
llvm-svn: 57085
2008-10-05 00:08:56 +00:00
Argyrios Kyrtzidis 2c7137d8d1 Resolve ambiguous C++ statements (C++ 6.8p1).
'ParseTentative.cpp' implements the functionality needed to resolve ambiguous C++ statements, to either a declaration or an expression, by "tentatively parsing" them.

llvm-svn: 57084
2008-10-05 00:06:24 +00:00
Daniel Dunbar 83f705ac20 Add coverage tests of C and Obj-C language features.
- AST printing, dumping, serialization, codegen.
 - HTML printing.
 - Parser callbacks.

Several of these are XFAIL because they trigger unimplemented code.

llvm-svn: 57081
2008-10-04 23:47:28 +00:00
Daniel Dunbar 4777ba0102 Desensitize env-include-paths.c to the directory it is running in.
- It would probably be better if TestRunner.sh canonicalized this.

llvm-svn: 57075
2008-10-04 21:05:04 +00:00
Daniel Dunbar 3ca0a634c2 Bug fix, CPATH="" does not add '.' to search path.
llvm-svn: 57072
2008-10-04 20:58:18 +00:00
Daniel Dunbar 23bd6cc156 Add test/Driver.
- env-include-paths.c is XFAIL as it exposed a bug.

Add test/Coverage.
 - For tests which achieve code coverage but don't validate anything.

llvm-svn: 57070
2008-10-04 20:46:41 +00:00
Daniel Dunbar fdfb0a0d5e De-XFAIL test/Parser/pragma-pack.c
llvm-svn: 57069
2008-10-04 19:45:56 +00:00
Chris Lattner 464e17ab20 switch to using -verify
llvm-svn: 57068
2008-10-04 19:43:25 +00:00
Chris Lattner cc498392a2 Move the expected-warning lines to a place that clang -verify will pick them
up.  Speculatularly hacktastic, but strangely beautiful?
Daniel, lines 20/21 are rejected, please investigate.

llvm-svn: 57067
2008-10-04 19:38:15 +00:00
Daniel Dunbar 921b968841 Add Parser support for #pragma pack
- Uses Action::ActOnPragmaPack
 - Test case is XFAIL pending verifier fixes.

llvm-svn: 57066
2008-10-04 19:21:03 +00:00
Daniel Dunbar 325601a9e5 Merge postfix attributes on record decls.
llvm-svn: 57019
2008-10-03 17:33:35 +00:00
Daniel Dunbar dc2ab1740a Add Builtins.def attribute for "can be a constant expression".
- Enabled for builtins which are always constant expressions
   (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p,
   __builtin_classify_type, __builtin___CFStringMakeConstantString).

Added Builtin::Context::isConstantExpr.
 - Currently overly simply interface which only works for builtins
   whose constantexprness does not depend on their arguments.

CallExpr::isBuiltinConstantExpr now takes an ASTContext argument.

llvm-svn: 56983
2008-10-02 23:30:31 +00:00
Daniel Dunbar dd9b2d16f9 Add support for format string checking of object-size checking
versions of sprintf and friends.
 - Added FIXME that this mechanism should be generalized.

llvm-svn: 56962
2008-10-02 18:44:07 +00:00
Steve Naroff d40a39626c Changed Sema::CheckForConstantInitializer to allow global block literals.
This commit also includes some name changes in the blocks rewriter (no functionality change).

llvm-svn: 56955
2008-10-02 17:12:56 +00:00
Ted Kremenek 3aa89a971d Enhance NSError** checking with analogous checking for CFErrorRef*.
Expand checking to include functions, not just methods.

llvm-svn: 56938
2008-10-01 23:24:09 +00:00
Ted Kremenek 63249b6e57 Added test case.
llvm-svn: 56915
2008-10-01 05:05:46 +00:00
Daniel Dunbar fbe68a84f8 NeXT: Update to use CreateRuntimeFunction for the routines it imports.
llvm-svn: 56902
2008-10-01 01:06:06 +00:00
Steve Naroff 4a82d815de Fix <rdar://problem/6191148> [sema] Objective-C method lookup (at global scope) fails to handle overloaded selectors properly.
Long standing bug in Sema::ActOnInstanceMessage(). We now warn when messaging an "id" with multiple method signatures in scope. The diags are a little verbose, however they can be streamlined if necessary. 

llvm-svn: 56843
2008-09-30 14:38:43 +00:00
Nuno Lopes a459f12862 fix test for latest changes in llvm asm representation
llvm-svn: 56842
2008-09-30 14:37:33 +00:00
Chris Lattner 4a80a59b6e Fix va_arg handling to do argument decaying at the correct place. This
fixes problems handling references of va_list, which happens on x86_64.
This fixes PR2841 and rdar://6252231

llvm-svn: 56809
2008-09-29 22:28:25 +00:00
Steve Naroff 32d072ca45 Teach Sema::CheckAssignmentConstraints() to allow assignments between id and block pointer types (^{}).
llvm-svn: 56793
2008-09-29 18:10:17 +00:00
Steve Naroff 03fc762a02 Fix <rdar://problem/6251012> clang: Blocks are objects too.
llvm-svn: 56791
2008-09-29 16:51:41 +00:00
Steve Naroff c2036d5da4 Fix <rdar://problem/6253149> property declaration doesn't declare getter and setter.
llvm-svn: 56785
2008-09-29 14:20:56 +00:00
Steve Naroff 8edb573a79 Fix <rdar://problem/6252129> implementation of method in category doesn't effectively declare it for methods below.
llvm-svn: 56771
2008-09-28 14:55:53 +00:00
Steve Naroff 4831c74d40 Fix <rdar://problem/6252108> assigning to argument passed to block should not require __block.
llvm-svn: 56770
2008-09-28 14:02:55 +00:00
Chris Lattner 037379d767 Fix rdar://6252231 - cannot call vsnprintf with va_list on x86_64,
by decaying __builtin_va_list's type when forming builtins.  On
x86-64 (and other targets) __builtin_va_list is a typedef for
an array.

llvm-svn: 56768
2008-09-28 06:05:35 +00:00
Chris Lattner e9d291c038 Fix rdar://6251437, references to enum constant decls in a block
don't need a BlockDeclRefExpr.

llvm-svn: 56766
2008-09-28 05:30:26 +00:00
Steve Naroff e18f94c20d Fix <rdar://problem/6252216> compare block to NULL.
llvm-svn: 56764
2008-09-28 01:11:11 +00:00
Steve Naroff edec9ba58d Fix <rdar://problem/6252226> parser thinks block argument is undefined identifier in NSServices.m
llvm-svn: 56761
2008-09-28 00:13:36 +00:00
Daniel Dunbar 53642c0160 Remove automagic substitution of %llvmgcc
- Is unused and somewhat unreliable.

llvm-svn: 56737
2008-09-27 00:47:03 +00:00
Daniel Dunbar 00e36f4c5c Fix function-attributes test case to not rely on llvm-gcc.
llvm-svn: 56734
2008-09-27 00:44:01 +00:00
Daniel Dunbar 23b46ca198 Fix attributes test case to not run clang umpteen times.
llvm-svn: 56733
2008-09-27 00:39:13 +00:00
Ted Kremenek f5e7e3ae26 Add more control-flow to test case.
llvm-svn: 56707
2008-09-26 23:05:47 +00:00
Ted Kremenek d86d39cc9e Add CFG support for implicit-control flow for VLA size expressions within an SizeOfAlignOfTypeExpr.
llvm-svn: 56706
2008-09-26 22:58:57 +00:00
Chris Lattner 6bea488c79 testcase for my previous patch.
llvm-svn: 56670
2008-09-26 18:07:51 +00:00
Ted Kremenek 68d2190226 Enter a new scope for a @try block.
llvm-svn: 56668
2008-09-26 17:32:47 +00:00
Steve Naroff ba756cb3fc Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with BlockDeclRef exprs.
This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block.

llvm-svn: 56652
2008-09-26 14:41:28 +00:00
Ted Kremenek 2ece64bbc4 Examine VLA size expressions when computing liveness information.
Fixes <rdar://problem/6248086>

llvm-svn: 56645
2008-09-26 05:52:45 +00:00
Daniel Dunbar 26e2ab4a37 Parser support for prefix __attribute__ on @protocol.
llvm-svn: 56642
2008-09-26 04:48:09 +00:00
Daniel Dunbar c136e0ca43 Sema support for format and noreturn attributes on Objective-C methods.
llvm-svn: 56640
2008-09-26 04:12:28 +00:00
Daniel Dunbar 980c66946b Add support for CFString in format attribute.
llvm-svn: 56639
2008-09-26 03:32:58 +00:00
Ted Kremenek a34ea3b9cf Have @finally introduce a new scope.
Fixes: <rdar://problem/6248119> @finally doesn't introduce a new scope

llvm-svn: 56629
2008-09-26 00:31:16 +00:00
Steve Naroff f17c232a9e Downgrade incompatible block pointer error to a warning (to be consistent with incompatible pointer warnings in general).
llvm-svn: 56595
2008-09-24 23:31:10 +00:00
Steve Naroff c60873ce44 Fix <rdar://problem/6243788> clang: Incorrect return statement for Blocks?
llvm-svn: 56590
2008-09-24 22:26:48 +00:00
Daniel Dunbar 3a28b9acbd Add more testing of Obj-C property synthesis.
llvm-svn: 56564
2008-09-24 18:00:13 +00:00
Ted Kremenek 1f58ec6475 Updated test case.
llvm-svn: 56548
2008-09-24 06:40:03 +00:00
Daniel Dunbar e8a06e619a Implement type checking of Objective-C property attributes.
- readonly and readwrite are mutually exclusive.
 - assign, copy, and retain are mutually exclusive.
 - copy and retain are invalid on non-object types.
 - Warn about using default 'assign' property on object types
   (attempting to follow gcc behavior).

llvm-svn: 56507
2008-09-23 21:53:23 +00:00
Steve Naroff 87930ca38f Teach block rewriter to replace '^' with '*' in VarDecls.
Since we don't have DeclGroup's and location information for types, there is some fancy footwork to do this fairly reliably.

O.K...it's a kludge. One day, we can use this as motivation to do this more gracefully:-)

llvm-svn: 56499
2008-09-23 19:24:41 +00:00
Ted Kremenek 81ec48a1d5 Added test case.
llvm-svn: 56493
2008-09-23 18:05:01 +00:00
Daniel Dunbar c6fdac260b Bug fix, result of isIntegerConstantExpr could be of incorrect width
for type.
  - PR2817

llvm-svn: 56482
2008-09-22 23:53:24 +00:00
Steve Naroff cd5e782bce Fix http://llvm.org/bugs/show_bug.cgi?id=2816.
llvm-svn: 56433
2008-09-22 10:28:57 +00:00
Ted Kremenek 8cdc71859c Test case for transfer function logic of const casts.
llvm-svn: 56369
2008-09-19 20:53:52 +00:00
Ted Kremenek 34bfd8a490 Fixed logic error in BasicConstraintManager pointed out by Zhongxing Xu.
For checking if a symbol >= value, we need to check if symbol == value || symbol
> value. When checking symbol > value and we know that symbol != value, the path
is infeasible only if value == maximum integer.

For checking if a symbol <= value, we need to check if symbol == value || symbol
< value. When checking symbol < value and we know that symbol != value, the path
is infeasible only if value == minimum integer.

Updated test case exercising this logic: we only prune paths if the values are
unsigned.

llvm-svn: 56354
2008-09-19 18:00:36 +00:00
Chris Lattner a7b034463e Fix rdar://6222856: the receiver of a message expr is an
arbitrary expr, not just a assign expr.  The grammar comment
was right, the code was just wrong.

llvm-svn: 56353
2008-09-19 17:44:00 +00:00
Ted Kremenek 55bec4d511 Added test case for PR 2600: proper use of NSError**
llvm-svn: 56332
2008-09-19 04:56:32 +00:00
Steve Naroff 3405a73ab8 Finish pushing blocks attribute through the clang attribute machinery.
Also added a couple simple tests from the "gcc.apple" test suite.

llvm-svn: 56309
2008-09-18 16:44:58 +00:00
Ted Kremenek 137fc0ea01 Added CFNumberCreate test case to illustrate a 32-bit/64-bit arch issue.
llvm-svn: 56295
2008-09-18 00:28:23 +00:00
Ted Kremenek 24bef31597 Add path-sensitivity test case.
llvm-svn: 56294
2008-09-17 22:24:13 +00:00
Daniel Dunbar 6ff95305e6 Another attempt to make test/Makefile return correct error code.
llvm-svn: 56285
2008-09-17 18:08:07 +00:00
Steve Naroff a5629376e8 Fix http://llvm.org/bugs/show_bug.cgi?id=2760.
llvm-svn: 56280
2008-09-17 14:05:40 +00:00
Daniel Dunbar 86169d6d0d Ignore XFAIL tests when checking for make failure in test/
llvm-svn: 56262
2008-09-16 23:43:13 +00:00
Ted Kremenek 025f83534c Fix copy-paste error in test case.
llvm-svn: 56261
2008-09-16 23:25:28 +00:00
Ted Kremenek 8782716c4a Minor pass-sensitivity improvement:
if we know that 'len != 0' and know that 'i == 0' then we know that
  'i < len' must evaluate to true and cannot evaluate to false

llvm-svn: 56260
2008-09-16 23:24:45 +00:00
Steve Naroff 7a147c6a3c Remove support for BlockExprExpr. For example...
^(expression) or ^(int arg1, float arg2)(expression)
...is no longer supported. 
All block literals now require a compound statement.

llvm-svn: 56257
2008-09-16 23:11:46 +00:00
Steve Naroff 3b1e172d7e Sema::ActOnBlockReturnStmt(): Need to perform the UsualUnaryConversions on the return type.
Sema::CheckReturnStackAddr(): Make sure we skip over implicit casts.
Added some more test cases...

llvm-svn: 56254
2008-09-16 22:25:10 +00:00
Douglas Gregor aa1e21dcbd Give string literals const element typesin C++, and cope with the deprecated C++ conversion from a string literal to a pointer-to-non-const-character
llvm-svn: 56137
2008-09-12 00:47:35 +00:00
Daniel Dunbar 484603be40 Iterate on sema for :? in Objective-C:
- Follow C99 behavior of using other operand type when one of
   operands is a null pointer constant.
 - Fix overenthusiastic devolving of any Objective-C types to id:
   o If either operand has an Objective-C object type then:
     - If both operands are interfaces and either operand can be
       assigned to the other, use that type as the composite type.
     - Otherwise, if either type is id, use id as the composite type.
     - Otherwise, warn about incompatible types and use id as the
       composite type.
 - Return handling of qualified idea to separate test following
   general pointer type checking.
   o Upgraded from old code to allow devolving to id (without warning,
     which matches GCC).
 - <rdar://problem/6212771>

Add test case for issues fixed above, XFAIL though because it exposed
a new issue in property handling.

llvm-svn: 56135
2008-09-11 23:12:46 +00:00
Argyrios Kyrtzidis 176edb5490 Do implicit conversion to bool for the condition in a do-while statement.
llvm-svn: 56096
2008-09-11 05:16:22 +00:00
Argyrios Kyrtzidis fea38016a9 Fix do-while scoping in C++.
llvm-svn: 56095
2008-09-11 04:46:46 +00:00
Daniel Dunbar ce05c8eb49 Fix two bugs exposed by array passing assert:
(1) Additional arguments to variadic methods should have default
promotions applied.

(2) Additional arguments to non-variadic methods were allowed.

llvm-svn: 56084
2008-09-11 00:50:25 +00:00
Argyrios Kyrtzidis 996677e12d In the 'condition.cpp' test case, make sure that condition declarations are local to the statement.
llvm-svn: 56077
2008-09-10 23:34:50 +00:00
Daniel Dunbar b034bc71d4 Add XFAIL test case for:
<rdar://problem/6211479> [sema] array type invalid for Obj-C property

llvm-svn: 56075
2008-09-10 23:11:23 +00:00
Steve Naroff 2752a17a00 More semantic analysis for blocks...
llvm-svn: 56064
2008-09-10 19:17:48 +00:00
Steve Naroff 3ef15b5c2a Sema::ActOnIdentifierExpr(): Lookup block arguments.
llvm-svn: 56063
2008-09-10 18:33:00 +00:00
Argyrios Kyrtzidis 07052350f0 Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which represents a 'condition' declaration, e.g: "if (int x=0) {...}".
llvm-svn: 56045
2008-09-10 02:36:38 +00:00
Argyrios Kyrtzidis 7620ee4550 Implement Sema support for the 'condition' part of C++ selection-statements and iteration-statements (if/switch/while/for).
llvm-svn: 56044
2008-09-10 02:17:11 +00:00
Argyrios Kyrtzidis f602e427e9 Fix test case.
llvm-svn: 56012
2008-09-09 20:56:12 +00:00
Argyrios Kyrtzidis 2b4072fe55 Implement parser support for the 'condition' part of C++ selection-statements and iteration-statements (if/switch/while/for).
Add new 'ActOnCXXConditionDeclarationExpr' action, called when the 'condition' is a declaration instead of an expression.

llvm-svn: 56007
2008-09-09 20:38:47 +00:00
Daniel Dunbar 0beedc1684 Fix a number of issues w.r.t. emission of global for functions and
aliases.
 - Attributes specific to a definition are only set when the
   definition is seen.
 - Alias generation is delayed until the end of the module; necessary
   since the alias may reference forward.
 - Fixes: PR2743, <rdr://6140807&6094512>
 - Improves: <rdr://6095112> (added XFAIL)

Also, print module on verification failures.

llvm-svn: 55966
2008-09-08 23:44:31 +00:00
Daniel Dunbar 47be094138 Add missing RUN line
llvm-svn: 55934
2008-09-08 18:01:15 +00:00
Nuno Lopes fc8c680b89 skip test if llvm-gcc is requires but not found on the path.
someone with llvm-gcc installed please test if the Codegen/function-attributes.c test isn't skip in your system. thanks.

llvm-svn: 55871
2008-09-06 16:42:14 +00:00
Steve Naroff 8de9c3affe More type checking for blocks. Still incomplete (will hopefully finish up this weekend).
llvm-svn: 55862
2008-09-05 22:11:13 +00:00
Argyrios Kyrtzidis 2545aeb710 Support "typeof unary-expression" (GNU C++ extension).
llvm-svn: 55833
2008-09-05 11:26:19 +00:00
Argyrios Kyrtzidis 91c3f526dc Line endings: CRLF -> LF
llvm-svn: 55829
2008-09-05 08:53:53 +00:00
Daniel Dunbar 0335024c4a Test case for previous commit (Workaround gcc bug causing crash on our
preprocessed outputs)

llvm-svn: 55826
2008-09-05 03:23:51 +00:00
Daniel Dunbar 2ffee610da Set sext/zext on function result.
- <rdar://problem/6156739>

llvm-svn: 55815
2008-09-05 00:57:45 +00:00
Daniel Dunbar 98982ef954 Fix unintended use of doxygen comment strings.
llvm-svn: 55805
2008-09-04 21:54:53 +00:00
Ted Kremenek 72c06446bb Added test case for the dead stores checker that was originally an FP reported in PR 2763.
llvm-svn: 55801
2008-09-04 21:52:52 +00:00
Daniel Dunbar c7dfbfd544 Prevent invalid warnings about incomplete implementations for methods
which are inherited from base clases or protocols.

llvm-svn: 55790
2008-09-04 20:01:15 +00:00
Nuno Lopes 92c4bc8873 fix running tests with valgrind (there were a lot of bogus failures and warnings)
currently clang passes all tests under valgrind with the leak checker disabled :P (and fails most otherwise)

llvm-svn: 55782
2008-09-04 18:33:57 +00:00
Daniel Dunbar c01f56c8de Add some Objective-C code generation tests.
- Note that these don't really test anything other than that code
   generation doesn't fail or crash. Better than nothing though!

llvm-svn: 55761
2008-09-04 04:36:23 +00:00
Daniel Dunbar 8cde00a510 Implement codegen of aggregates as lvalues in binary expressions,
e.g. "(a = b).somefield".

llvm-svn: 55758
2008-09-04 03:20:13 +00:00
Daniel Dunbar 0f99912868 Update TestRunner to not report failure for XFAIL tests
llvm-svn: 55751
2008-09-04 00:30:11 +00:00
Daniel Dunbar 0ff4192f3a Set register storage class correctly for function parameters.
- PR2730

llvm-svn: 55739
2008-09-03 21:54:21 +00:00
Ted Kremenek b44763456c Following gcc's behavior, only enable trigraphs if '-trigraphs' or '-ansi' is
specified, or -std is set to a conforming mode.

llvm-svn: 55738
2008-09-03 21:22:16 +00:00
Daniel Dunbar 20e5db77a3 Add two test cases for builtins (mostly related to object size
builtins).

llvm-svn: 55736
2008-09-03 21:17:21 +00:00
Daniel Dunbar de1ec9cdcd Improve type-checking of ?: for Objective-C types.
- Allow any Objective-C object types to devolve to type id in a ?:
   expression. This matches gcc behavior more closely.

llvm-svn: 55705
2008-09-03 17:53:25 +00:00
Daniel Dunbar ef89086c12 Restore Objective-C dot-syntax access of methods.
- Now also searches for correct setter method.
 - There are still some issues regarding validation of the setter
   method and access of read-only properties.

llvm-svn: 55686
2008-09-03 01:05:41 +00:00
Steve Naroff c84e8b779e - Implement __block.
- Replace FIXME in Preprocessor::HandleIdentifier() with a check that avoids diagnosing extension tokens that originate from macro definitions.

llvm-svn: 55639
2008-09-02 18:50:17 +00:00
Steve Naroff d450bffcf1 Pull code from last commit. will put back soon.
llvm-svn: 55637
2008-09-02 18:04:36 +00:00
Steve Naroff 95bffc74da Implement block pseudo-storage class modifiers (__block, __byref).
llvm-svn: 55635
2008-09-02 15:20:19 +00:00
Nuno Lopes dd30e2c677 add the other test case for completeness and to avoid regressions in the future
llvm-svn: 55629
2008-09-02 10:10:14 +00:00
Eli Friedman de09ce03c4 Fix for PR2747: allow pointer->int casts with a null base; these are
offset-of-like expressions.

llvm-svn: 55627
2008-09-02 09:37:00 +00:00
Eli Friedman ee29c9c2fc Fix for PR2750; don't check for an 'e' in the trash after the token.
Note that this isn't really a complete fix; I think there are other 
potential overrun situations.  I don't really know what the best 
systematic fix is, though.

llvm-svn: 55622
2008-09-02 05:29:22 +00:00
Eli Friedman 7c9ba6a1e3 An extremely hacky version of transparent_union support; it isn't
anywhere near correct in terms of missing cases and missing 
diagnostics, but it's good enough to handle the uses in the 
Linux system headers, which are currently a constant pain for compiling 
applications on Linux.

llvm-svn: 55621
2008-09-02 05:19:23 +00:00
Eli Friedman e7175d83dc Make sure to take the unqualified versions of the canonical types for
type-checking pointer subtraction; if the canonical types aren't used,
the qualifiers won't always get stripped off correctly.

llvm-svn: 55620
2008-09-02 05:09:35 +00:00
Nuno Lopes 4e630967fc readd test as it passes correctly. nice, but weird
llvm-svn: 55615
2008-09-01 22:28:55 +00:00
Eli Friedman 4c55e2c4ed Backing out r55607 due to logic errors and test regression.
I'll try to come up with a correct fix for the testcase sometime soon.

llvm-svn: 55614
2008-09-01 22:08:17 +00:00
Ted Kremenek c4f6d90ba1 Tidy up sema processing of attribute "nonull":
- warn about nonnull being applied to functions with no pointer arguments
- continue processing argument list in the attribute when we encounter a non-pointer parameter being marked as nonnull
- when no argument list is specified, only mark pointers as nonnull.  This fixes PR 2732 and radar 6188814.

llvm-svn: 55610
2008-09-01 19:57:52 +00:00
Nuno Lopes 2c5208c59f fix one more this-is-not-a-constant error. test included
llvm-svn: 55609
2008-09-01 18:42:41 +00:00
Nuno Lopes feac637074 make CheckArithmeticConstantExpression() aware of &foo and pointers
llvm-svn: 55607
2008-09-01 14:47:06 +00:00
Daniel Dunbar e0a09432cc Temporarily disable some tests which due to dot-syntax
access of methods.

llvm-svn: 55569
2008-08-30 16:22:34 +00:00
Daniel Dunbar 5888e603c3 Allow 'make TESTDIRS=Sema' in test/ directory for only running a
subset of tests.

llvm-svn: 55513
2008-08-28 23:28:16 +00:00
Steve Naroff 0ac012835f Add parser/action support for block literal expressions.
Parser support for blocks is almost complete...just need to add support for the __block() storage class qualifier.

llvm-svn: 55495
2008-08-28 19:20:44 +00:00
Daniel Dunbar 8c8616377d Fix isIntegerConstantExpr eval of __builtin_offsetof to return result
with correct width.
 - PR2728.

Also, fix PR2727 test case.

llvm-svn: 55493
2008-08-28 18:42:20 +00:00
Daniel Dunbar 3e1888e8bd Fix double-free error with sizeof applied to VLA types.
- PR2727.

Also, fix warning in CodeGenTypes for new BlockPointer type.

llvm-svn: 55479
2008-08-28 18:02:04 +00:00
Steve Naroff ec33ed9ced First wave of changes to support "blocks" (an extension to C).
This commit adds the declaration syntax (and associated type).

llvm-svn: 55417
2008-08-27 16:04:49 +00:00
Daniel Dunbar e0a673e60f Update test case (we were missing a warning here)
llvm-svn: 55408
2008-08-27 05:41:04 +00:00
Daniel Dunbar 5e558bcf26 Add ObjCPropertyDecl::isReadOnly.
Respect isReadOnly when generating synthesized method decls.

llvm-svn: 55364
2008-08-26 07:16:44 +00:00
Daniel Dunbar 40bf7fe20e In incompatible pointer-typed ?: expressions, add implicit conversion
of RHSs to id type instead of void* if either has Objective-C object
type.
 - This ensures the result can still be used in normal places an
   object can be used, like a message send.

Add implicit conversions for ?: applied to qualified id types to
ensure that the RHSs are compatible. 
 - This prevents a codegen crash (creating invalid PHI nodes).
 - Again, this relates to the fact that qualified id types have no
   canonical types.
 - Note that the implicit type casted to is incorrect, however this
   doesn't currently cause problems because of the flexibility of the
   id type.

Test cases for above.

llvm-svn: 55346
2008-08-26 00:41:39 +00:00
Eli Friedman 3d421e190a Do typechecking and codegen for K&R-style function declarations
correctly.  Not a regression, but made more obvious by my recent fix 
which made function type compatibility checking a bit more strict.

llvm-svn: 55339
2008-08-25 21:31:01 +00:00
Eli Friedman 0a2ba3f10b Fix for PR2720; be a little bit more permissive in initializers for
casting pointers to integers.

Eventually, we should check whether we can evaluate an expression 
using Expr::tryEvaluate, and this codepath should be tightened to only 
handle standard-compliant cases.

llvm-svn: 55331
2008-08-25 20:46:57 +00:00
Daniel Dunbar 8d57244601 Add test case for function-pointer-cast-of-global as constant
expression.

llvm-svn: 55323
2008-08-25 20:08:27 +00:00
Anders Carlsson 1ec2ccd8ee Objective-C foreach selector elements must be lvalues.
llvm-svn: 55316
2008-08-25 18:16:36 +00:00
Anders Carlsson c7c20702b1 Fix silly bug in objc_gc attribute parsing and add test case
llvm-svn: 55286
2008-08-24 16:33:25 +00:00
Anders Carlsson d059d5bba0 Add carbon.cpp and cocoa.mm tests
llvm-svn: 55262
2008-08-23 22:21:00 +00:00
Anders Carlsson 4f177f803a treat bool literals as constatnt expressions.
llvm-svn: 55255
2008-08-23 21:12:35 +00:00
Anders Carlsson a3345a5d73 Handle Objective-C++ tests.
llvm-svn: 55254
2008-08-23 21:03:10 +00:00
Anders Carlsson f93f56a28e Reserved C++ words are valid selectors in Objective-C++
llvm-svn: 55253
2008-08-23 21:00:01 +00:00
Argyrios Kyrtzidis ce4528f008 Add CodeGen support for CXXZeroInitValueExpr.
llvm-svn: 55249
2008-08-23 19:35:47 +00:00
Argyrios Kyrtzidis 0116530ba2 Add a null pointer test in the type-convert-construct.cpp tests.
llvm-svn: 55247
2008-08-23 19:24:45 +00:00
Chris Lattner 2ebb178f8b Fix a FIXME by not creating an invalid AST on erroneous input. Also
make diagnostic output in some other malformed cases significantly
more useful.  This fixes PR2708

llvm-svn: 55215
2008-08-23 01:48:03 +00:00
Argyrios Kyrtzidis 3d0f51d703 Move the rest of the Sema C++ tests into the SemaCXX test directory.
llvm-svn: 55178
2008-08-22 15:43:49 +00:00
Argyrios Kyrtzidis 857fcc2f8e Add support for C++'s "type-specifier ( expression-list )" expression:
-The Parser calls a new "ActOnCXXTypeConstructExpr" action.
-Sema, depending on the type and expressions number:
   -If the type is a class, it will treat it as a class constructor. [TODO]
   -If there's only one expression (i.e. "int(0.5)" ), creates a new "CXXFunctionalCastExpr" Expr node
   -If there are no expressions (i.e "int()" ), creates a new "CXXZeroInitValueExpr" Expr node.

llvm-svn: 55177
2008-08-22 15:38:55 +00:00
Nico Weber 5a87265775 make test fails if llvm is checked out to llvm-svn of if there is a dash somewhere else in the path. fix that.
llvm-svn: 55175
2008-08-22 09:33:51 +00:00
Anders Carlsson 41e0881b34 Initial sema support for C++ static initializers.
llvm-svn: 55166
2008-08-22 05:00:02 +00:00
Chris Lattner ea71438a93 add a simple check to warn people who type "=+" when they probably meant
"+=".

llvm-svn: 55131
2008-08-21 18:04:13 +00:00
Daniel Dunbar 66dd6382e4 Use full path to count script, and don't treat files with missing RUN
lines as errors.

llvm-svn: 55109
2008-08-21 04:43:28 +00:00
Daniel Dunbar 5f977e7b15 Missed a test case writing a .ll file.
Suppress count output from 'make test' on errors (used to generate
result code).

llvm-svn: 55107
2008-08-21 04:30:23 +00:00
Daniel Dunbar 746d104b3d Reorder the PATH used during testing so $(ToolDir) and the LLVM
scripts dir appear before the user path.
 - This is an attempt to pick up the right executables. We should
   probably be substituting the exact things we want for clang a la
   the LLVM test script.

llvm-svn: 55105
2008-08-21 03:03:44 +00:00
Daniel Dunbar 19d84c3c51 Update a number of CodeGen tests to not create .ll files in the test
directory.
 - Removed .ll from the svn:ignore lists to try and prevent this.
 - Added svn:ignore on test/Misc/Output

llvm-svn: 55104
2008-08-21 02:51:29 +00:00
Daniel Dunbar 10a230ded9 Update test/Makefile to allow testing when using a separate obj
directory.
 - Also, return proper error code if testing fails.

llvm-svn: 55103
2008-08-21 02:48:23 +00:00
Eli Friedman 1be92d297a Fix a regression from my fix to PR2631. Fixes PR2692.
llvm-svn: 55083
2008-08-20 22:17:17 +00:00
Eli Friedman 002ad1274b Fix a minor crash-on-invalid.
llvm-svn: 55082
2008-08-20 22:07:34 +00:00
Daniel Dunbar 94834d8883 Fix subtle bug introduced in r54852.
- UsualUnaryConversions takes an Expr *& and may modify its argument,
   this broke when it was refactored into Sema::CheckCastTypes. This
   meant that we were missing implicit casts in some places.
 - Seems pretty sad that this got through our tests.

llvm-svn: 55039
2008-08-20 03:55:42 +00:00
Eli Friedman 5dd15a3c45 Fix test failure on Linux.
llvm-svn: 55032
2008-08-20 01:05:41 +00:00
Eli Friedman a7e8c231ea Fix some spam from make I accidentally introduced.
llvm-svn: 55027
2008-08-20 00:38:03 +00:00
Eli Friedman 02d4a78688 Get rid of the bogus -depth +0 argument; I really have no clue what the
heck it does on Darwin, but it's not part of POSIX, and the GNU version 
of find errors out on it.

On a side note, there are a couple of new failures due to tests 
including OS X specific headers.

llvm-svn: 55019
2008-08-20 00:02:01 +00:00
Steve Naroff ad7013b1e6 Fix crasher in RewriteObjC::RewriteObjCSynchronizedStmt(). Can't depend on the source locations of the sync expression (since it may have been rewritten.
Fixes <rdar://problem/6156363> clang ObjC rewriter: rewriting attached file causes assertion failure: invalid FileID

llvm-svn: 54986
2008-08-19 13:04:19 +00:00
Chris Lattner 5caafe598f add testcase we already handle.
llvm-svn: 54967
2008-08-19 00:58:40 +00:00
Chris Lattner 3f4c68b78e proper grammar n stuph
llvm-svn: 54954
2008-08-18 22:51:28 +00:00
Chris Lattner e5d812af59 warn when someone tries to make an array of ObjC interfaces instead of array
of pointers to them.  rdar://4304469

llvm-svn: 54953
2008-08-18 22:49:54 +00:00
Daniel Dunbar aa64b7e0a8 Support initialization of incomplete array with zero size (as
extension).

llvm-svn: 54946
2008-08-18 20:28:46 +00:00
Chris Lattner 7f33544cc7 fix bogus run line.
llvm-svn: 54940
2008-08-18 19:54:48 +00:00
Daniel Dunbar 309dd7e31a Change test/Makefile to automatically test all subdirs.
llvm-svn: 54923
2008-08-18 18:05:17 +00:00
Daniel Dunbar 5a42754328 Fix test case RUN: line (thanks Argiris)
llvm-svn: 54922
2008-08-18 17:52:17 +00:00
Argyrios Kyrtzidis 00441dfcd4 Type::isIntegerType() returns true for types between Bool and LongLong.
Put WChar between them to make it integer type.

llvm-svn: 54882
2008-08-17 13:24:01 +00:00
Argyrios Kyrtzidis 3014572ea2 Move the C++ Sema tests into a separate SemaCXX directory.
llvm-svn: 54853
2008-08-16 20:53:59 +00:00
Argyrios Kyrtzidis 16d63a727e C++ casts, (static_cast. dynamic_cast, etc.) can have postfix-expression pieces.
llvm-svn: 54850
2008-08-16 19:45:32 +00:00
Ted Kremenek 3b977558ce Enhance null-dereference checker test.
llvm-svn: 54834
2008-08-16 00:45:40 +00:00
Nuno Lopes cb46c144bc make sure the size of constant arrays is respected
llvm-svn: 54769
2008-08-13 23:28:57 +00:00