Commit Graph

1707 Commits

Author SHA1 Message Date
Douglas Gregor dc37c81448 Add the test for __null
llvm-svn: 60357
2008-12-01 17:31:21 +00:00
Anders Carlsson 0309d904f7 Fix test. (0 && (a(),1)) is a valid I-C-E according to C99.
llvm-svn: 60331
2008-12-01 06:27:38 +00:00
Anders Carlsson 1dbffc6e36 Add Sema::isNullPointerConstant which extwarns if necessary. Use it in Sema::CheckConditionalOperands.
llvm-svn: 60319
2008-12-01 02:17:22 +00:00
Anders Carlsson f7fba46331 Use VerifyIntegerConstantExpression for case values.
llvm-svn: 60317
2008-12-01 02:13:02 +00:00
Zhongxing Xu 9cc7cba848 remove a test case that causes compiler warning.
llvm-svn: 60282
2008-11-30 05:59:27 +00:00
Zhongxing Xu 5c75919093 Add test for initializing array with string literal.
llvm-svn: 60281
2008-11-30 05:51:19 +00:00
Douglas Gregor a29dc05eaf Add implicit conversions for Objective-C qualified ids, e.g.,
id<P0>

The intended overloading behavior of these entities isn't entirely
clear, and GCC seems to have some strange limitations (e.g., the
inability to overload on id<P0> vs. id<P1>). We'll want to revisit
these semantics and determine just how Objective-C++ overloading
should really work.

llvm-svn: 60142
2008-11-27 01:19:21 +00:00
Douglas Gregor 9ccbcdfb27 Test conversion from apointer to incomplete type to void* in C++
llvm-svn: 60131
2008-11-26 23:33:36 +00:00
Douglas Gregor 237f96c40f Implement implicit conversions for Objective-C specific types, e.g.,
converting a pointer to one Objective-C interface into a pointer to another
Objective-C interface, and conversions with 'id'. The semantics seems
to match GCC, although they seem somewhat ad hoc.

Fixed a few cases where we assumed the C++ definition of isObjectType,
but were getting the C definition, causing failures in trouble with
conversions to void pointers.

llvm-svn: 60130
2008-11-26 23:31:11 +00:00
Fariborz Jahanian 6de7eb8587 Another test for property code gen.
llvm-svn: 60128
2008-11-26 23:20:29 +00:00
Fariborz Jahanian 57251782d0 Code gen for aggregate-valued properties and a test case.
llvm-svn: 60122
2008-11-26 22:36:09 +00:00
Fariborz Jahanian e7167c28f6 Removed a FIXME. Added a test case for anonymous category.
llvm-svn: 60115
2008-11-26 20:33:54 +00:00
Fariborz Jahanian f8ef9f3dc9 Set default property attributes on each property.
Implemented anonymous category (also know as continuation class)
used to override main class's property attribute. This is work in 
propgress.

llvm-svn: 60114
2008-11-26 20:01:34 +00:00
Anders Carlsson f7a9a92359 Convert incomplete array types before emitting debug info for them, fixes PR3134.
llvm-svn: 60109
2008-11-26 17:40:42 +00:00
Nuno Lopes 8c6fbc04ee add missing RUN lines
llvm-svn: 60107
2008-11-26 15:50:12 +00:00
Douglas Gregor 08d96d5182 Fix a minor typo in the handling of the conditional operator for Objective-C interface pointers
llvm-svn: 60096
2008-11-26 06:43:45 +00:00
Anders Carlsson 32ef8ceaa1 Handle returning complex types that get coerced. Fixes PR3131
llvm-svn: 60058
2008-11-25 22:21:48 +00:00
Fariborz Jahanian 9a207ee4dc Patch to allow over-riding of readonly property to
a writable property in one of its category.

llvm-svn: 60035
2008-11-25 17:56:43 +00:00
Douglas Gregor 3ff3cf5f21 Test another error message, make sure to verify C++ new and delete tests
llvm-svn: 60007
2008-11-25 04:08:05 +00:00
Douglas Gregor 2afd0be069 Simple parsing of exception specifications, with no semantic analysis yet
llvm-svn: 60005
2008-11-25 03:22:00 +00:00
Zhongxing Xu f39268ae8c Add documentation for test.
llvm-svn: 60002
2008-11-25 01:45:11 +00:00
Zhongxing Xu 2939a50b67 Add no-warning to test case.
llvm-svn: 59995
2008-11-24 23:45:56 +00:00
Fariborz Jahanian 8fc3741b76 Patch to remove bogus waring when a property declaration
is imported from a protocol into the implementation.

llvm-svn: 59988
2008-11-24 22:16:00 +00:00
Chris Lattner 1e5665e6be Change a whole lot of diagnostics to take QualType's directly
instead of converting them to strings first.  This also fixes a
bunch of minor inconsistencies in the diagnostics emitted by clang
and adds a bunch of FIXME's to DiagnosticKinds.def.

llvm-svn: 59948
2008-11-24 06:25:27 +00:00
Chris Lattner f3d3faeca6 Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of
uses of getName() with uses of getDeclName().  This upgrades a bunch of
diags to take DeclNames instead of std::strings.

This also tweaks a couple of diagnostics to be cleaner and changes
CheckInitializerTypes/PerformInitializationByConstructor to pass
around DeclarationNames instead of std::strings.

llvm-svn: 59947
2008-11-24 05:29:24 +00:00
Anders Carlsson a7c5eb72a0 Reimplement Expr::isConstantExpr in terms of Expr::Evaluate. This fixes PR2832.
llvm-svn: 59946
2008-11-24 05:23:59 +00:00
Zhongxing Xu f556cd6cb9 Strings are NULL terminated. So the region size should plus one.
llvm-svn: 59943
2008-11-24 05:16:01 +00:00
Anders Carlsson 87da2b5dce Forgot the newline :)
llvm-svn: 59942
2008-11-24 05:13:45 +00:00
Anders Carlsson 3abcb58a35 Add test case for bug that's been fixed.
llvm-svn: 59941
2008-11-24 05:11:21 +00:00
Anders Carlsson a42ee44aab The address of a variable is only constant if the variable has global storage.
llvm-svn: 59939
2008-11-24 04:41:22 +00:00
Anders Carlsson 4c76e93507 Fix bug in the constant evaluator. Fixes PR3115.
llvm-svn: 59938
2008-11-24 04:21:33 +00:00
Chris Lattner 86d7d91366 Rename NamedDecl::getIdentifierName() to ::getNameAsCString() and make it
assert if the name is not an identifier.  Update callers to do the right
thing and avoid this method in unsafe cases.  This also fixes an objc
warning that was missing a space, and migrates a couple more to taking
IdentifierInfo and QualTypes instead of std::strings.

llvm-svn: 59936
2008-11-24 03:54:41 +00:00
Zhongxing Xu bf900755d0 Add test case for out-of-bound memory access checking.
llvm-svn: 59931
2008-11-24 02:19:49 +00:00
Chris Lattner 4fc69799f5 Rewrite FindDiagnostics to be more strict about the formatting of the
expected-foo strings.  Now the only allowed characters between 
expected-error and {{  is whitespace.

llvm-svn: 59925
2008-11-24 01:28:17 +00:00
Chris Lattner f3ab014308 clean up -verify mode output. If the expected-error string is
mangled, report it using the diagnostics machinery instead of printf.

llvm-svn: 59924
2008-11-23 23:38:26 +00:00
Chris Lattner 12f7c5a36a convert some more warnings to NOTEs.
llvm-svn: 59923
2008-11-23 23:26:13 +00:00
Chris Lattner d068503565 remove warn_previous_declaration
llvm-svn: 59922
2008-11-23 23:20:13 +00:00
Chris Lattner 03c4041cb5 make the 'to match this' diagnostic a note.
llvm-svn: 59921
2008-11-23 23:17:07 +00:00
Chris Lattner 0369c57ac6 Make all the 'redefinition' diagnostics more consistent, and make the
"previously defined here" diagnostics all notes.

llvm-svn: 59920
2008-11-23 23:12:31 +00:00
Chris Lattner e6447ef989 make some objc redefinition warnings more consistent: call definitions
"definitions", not declarations.  Point out the location of the 
original definition.

llvm-svn: 59919
2008-11-23 22:46:27 +00:00
Chris Lattner 88dcd2a1ab Tweak duplicate category diagnostic to work like the duplicate protocol diagnostic.
Also, point out where the previous decl was.  This unxfails two tests.

llvm-svn: 59918
2008-11-23 22:38:38 +00:00
Chris Lattner e3d20d9545 Convert IdentifierInfo's to be printed the same as DeclarationNames
with implicit quotes around them.  This has a bunch of follow-on 
effects and requires tweaking to a whole lot of code.  This causes
a regression in two tests (xfailed) by causing it to emit things like:

  Line 10: duplicate interface declaration for category 'MyClass1' ('Category1')

instead of:

  Line 10: duplicate interface declaration for category 'MyClass1(Category1)'

I will fix this in a follow-up commit.

As part of this, I had to start switching stuff to use ->getDeclName() instead
of Decl::getName() for consistency.  This is good, but I was planning to do this
as an independent patch.  There will be several follow-on patches
to clean up some of the mess, but this patch is already too big.

llvm-svn: 59917
2008-11-23 21:45:46 +00:00
Chris Lattner f7e69d5a77 add support for inserting a DeclarationName into a diagnostic directly
without calling getAsString().  This implicitly puts quotes around the
name, so diagnostics need to be tweaked to accommodate this.

llvm-svn: 59916
2008-11-23 20:28:15 +00:00
Zhongxing Xu 60d6cd1940 Improve test case.
llvm-svn: 59902
2008-11-23 05:50:21 +00:00
Sebastian Redl 632ab20e1e Fix test cases broken by quote normalization in diagnostics.
llvm-svn: 59888
2008-11-22 22:39:41 +00:00
Fariborz Jahanian 9ac535162b Implemented ir-gen for 'implicit' properties using the new AST nodes.
llvm-svn: 59886
2008-11-22 22:30:21 +00:00
Anders Carlsson 475f4bce36 Case values must be evaluated
llvm-svn: 59884
2008-11-22 21:50:49 +00:00
Anders Carlsson 59689ed764 Use Expr::Evaluate for case statements. Fixes PR2525
llvm-svn: 59881
2008-11-22 21:04:56 +00:00
Fariborz Jahanian 5118c418e6 Support for implicit property assignment. Error assigning to
'implicit' property with no 'setter'.

llvm-svn: 59878
2008-11-22 20:25:50 +00:00
Chris Lattner 8cd9b96ee1 add a silly testcase
llvm-svn: 59877
2008-11-22 19:57:03 +00:00
Fariborz Jahanian bf65ce5372 And a test case for my last patch.
llvm-svn: 59875
2008-11-22 18:40:47 +00:00
Sebastian Redl 15b02d2e62 Implement a %plural modifier for complex plural forms in diagnostics. Use it in the overload diagnostics.
llvm-svn: 59871
2008-11-22 13:44:36 +00:00
Anders Carlsson 4d5f2e532c Add test for PR2992.
llvm-svn: 59861
2008-11-22 06:42:54 +00:00
Fariborz Jahanian e2caaaa13c Fixed bugzilla bug# 3095 related to code gen. for @synchronized.
llvm-svn: 59838
2008-11-21 19:21:53 +00:00
Sebastian Redl bd150f431e Implementation of new and delete parsing and sema.
This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first.

llvm-svn: 59835
2008-11-21 19:14:01 +00:00
Chris Lattner cedef8d111 merge some simple call diagnostics.
llvm-svn: 59831
2008-11-21 18:44:24 +00:00
Chris Lattner 40bb0c83d4 print a type in a diagnostic.
llvm-svn: 59829
2008-11-21 18:27:34 +00:00
Douglas Gregor 5d58c3a568 Allow redeclaration of typedefs in C++
llvm-svn: 59822
2008-11-21 16:29:06 +00:00
Douglas Gregor b81897cda6 Fix overloading of non-static member functions that differ in their cv-qualifiers
llvm-svn: 59819
2008-11-21 15:36:28 +00:00
Douglas Gregor 9eb16eadfb Enable some more operator overloading tests, and don't look into an identifier for functions that might not have one
llvm-svn: 59818
2008-11-21 15:30:19 +00:00
Chris Lattner adcbb7f85d testcase for PR3096
llvm-svn: 59794
2008-11-21 06:19:48 +00:00
Douglas Gregor 4fc308bd3b Don't print canonical types in overloading-related diagnostics
llvm-svn: 59789
2008-11-21 02:54:28 +00:00
Chris Lattner fd384b1b3a Change -verify mode to find the "expected-error" and "expected-warning" strings
with a raw lexer instead of a PP lexer.  This means that -verify doesn't scan
#include'd headers for expected-error/warning strings, and it also means that it
doesn't ignore them in #if 0.

llvm-svn: 59774
2008-11-21 01:18:36 +00:00
Chris Lattner 66c8bebe81 remove expected-error from #if 0 section of code.
llvm-svn: 59772
2008-11-21 01:05:35 +00:00
Chris Lattner 4d7c58f0eb disable expected-errors in #if parts of the test.
llvm-svn: 59771
2008-11-21 01:05:04 +00:00
Chris Lattner 1759ea400e split into two tests.
llvm-svn: 59770
2008-11-21 01:04:13 +00:00
Ted Kremenek dfcbcfe328 Add checker test case: warn about returning an uninitialized value to the caller.
llvm-svn: 59765
2008-11-21 00:28:47 +00:00
Ted Kremenek c7792048ff Enable test file for 'region store' in addition to basic store.
llvm-svn: 59762
2008-11-21 00:15:15 +00:00
Fariborz Jahanian c1877cbc21 __weak ivar need not warn.
llvm-svn: 59743
2008-11-20 19:35:51 +00:00
Fariborz Jahanian d4081c697a Added a test case for __weak field decls. Change SetVarDeclObjCAttribute
to static function. Added comments.

llvm-svn: 59738
2008-11-20 18:10:58 +00:00
Douglas Gregor e0e79bdef6 Add support for overloaded operator-> when used in a member access
expression (smart_ptr->mem).

llvm-svn: 59732
2008-11-20 16:27:02 +00:00
Zhongxing Xu 06b377668d Split region store specific test cases.
llvm-svn: 59683
2008-11-20 00:46:15 +00:00
Douglas Gregor 20b300231a Beef up the test for function call operators slightly
llvm-svn: 59675
2008-11-19 22:59:19 +00:00
Douglas Gregor ab7897ac44 Implement the rest of C++ [over.call.object], which permits the object
being called to be converted to a reference-to-function,
pointer-to-function, or reference-to-pointer-to-function. This is done
through "surrogate" candidate functions that model the conversions
from the object to the function (reference/pointer) and the
conversions in the arguments.

llvm-svn: 59674
2008-11-19 22:57:39 +00:00
Steve Naroff dbfc693f47 Fix <rdar://problem/6291588> assertion failure: SourceManager.h line 489.
llvm-svn: 59664
2008-11-19 21:15:47 +00:00
Douglas Gregor 91cea0ad1e Support for calling overloaded function call operators (operator())
with function call syntax, e.g.,

  Functor f;
  f(x, y);

This is the easy part of handling calls to objects of class type 
(C++ [over.call.object]). The hard part (coping with conversions from
f to function pointer or reference types) will come later. Nobody uses
that stuff anyway, right? :)

llvm-svn: 59663
2008-11-19 21:05:33 +00:00
Daniel Dunbar bc47ed8e74 Ignore Output directories when searching for tests.
llvm-svn: 59660
2008-11-19 19:06:57 +00:00
Argyrios Kyrtzidis 0d09c4944e Take care another assert:
struct A {
  struct B;
};

struct A::B {
  void m() {} // Assertion failed: getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."
};

Introduce DeclContext::getLexicalParent which may be different from DeclContext::getParent when nested-names are involved, e.g:

   namespace A {
      struct S;
   }
   struct A::S {}; // getParent() == namespace 'A'
                   // getLexicalParent() == translation unit

llvm-svn: 59650
2008-11-19 18:01:13 +00:00
Nuno Lopes 0e33c688d5 fix folding of '*doubleArray'
llvm-svn: 59647
2008-11-19 17:44:31 +00:00
Douglas Gregor 40412acc02 Support overloading of the subscript operator[], including support for
built-in operator candidates. Test overloading of '&' and ','.

In C++, a comma expression is an lvalue if its right-hand
subexpression is an lvalue. Update Expr::isLvalue accordingly.

llvm-svn: 59643
2008-11-19 17:17:41 +00:00
Steve Naroff 9e4ac111f0 Fix <rdar://problem/6150376> [sema] crash on invalid message send.
The core fix in Sema::ActOnClassMessage(). All the other changes have to do with passing down the SourceLocation for the receiver (to properly position the cursor when producing an error diagnostic).

llvm-svn: 59639
2008-11-19 15:54:23 +00:00
Douglas Gregor d08452f60a Added operator overloading for unary operators, post-increment, and
post-decrement, including support for generating all of the built-in
operator candidates for these operators. 

C++ and C have different rules for the arguments to the builtin unary
'+' and '-'. Implemented both variants in Sema::ActOnUnaryOp.

In C++, pre-increment and pre-decrement return lvalues. Update
Expr::isLvalue accordingly.

llvm-svn: 59638
2008-11-19 15:42:04 +00:00
Argyrios Kyrtzidis 89709ac2cc Fix this:
With this snippet:
  void f(a::b);

An assert is hit:
Assertion failed: CachedTokens[CachedLexPos-1].getLocation() == Tok.getAnnotationEndLoc() && "The annotation should be until the most recent cached token", file ..\..\lib\Lex\PPCaching.cpp, line 98

Introduce Preprocessor::RevertCachedTokens that reverts a specific number of tokens when backtracking is enabled.

llvm-svn: 59636
2008-11-19 15:22:16 +00:00
Zhongxing Xu 16a92afc4b Add test for path-sensitive uninit-val detection involving struct field.
llvm-svn: 59620
2008-11-19 11:10:42 +00:00
Daniel Dunbar 9b1335eca8 Fix redundant load of bit-fields on assignment (to get the updated
value).
 - Use extra argument to EmitStoreThroughLValue to provide place to
   write update bit-field value if caller requires it.
 - This fixes several FIXMEs.

llvm-svn: 59615
2008-11-19 09:36:46 +00:00
Chris Lattner 3b05413e9d Switch several more Sema Diag methods over. This simplifies the
__builtin_prefetch code to only emit one diagnostic per builtin_prefetch.
While this has nothing to do with the rest of the patch, the code seemed
like overkill when I was updating it.

llvm-svn: 59588
2008-11-19 05:08:23 +00:00
Douglas Gregor ca63811b39 Built-in equality and relational operators have return type "bool" in C++,
not "int".

Fix a typo in the promotion of enumeration types that was causing some
integral promotions to look like integral conversions (leading to
extra ambiguities in overload resolution).

Check for "acceptable" overloaded operators based on the types of the
arguments. This is a somewhat odd check that is specified by the
standard, but I can't see why it actually matters: the overload
candidates it suppresses don't seem like they would ever be picked as
the best candidates.

llvm-svn: 59583
2008-11-19 03:25:36 +00:00
Douglas Gregor 436424cfa5 Partial expansion of C++ operator overloading (for binary operators)
to support operators defined as member functions, e.g.,

  struct X { 
    bool operator==(X&);
  };

Overloading with non-member operators is supported, and the special
rules for the implicit object parameter (e.g., the ability for a
non-const *this to bind to an rvalue) are implemented.

This change also refactors and generalizes the code for adding
overload candidates for overloaded operator calls (C++ [over.match.expr]),
both to match the rules more exactly (name lookup of non-member
operators actually ignores member operators) and to make this routine
more reusable for the other overloaded operators.

Testing for the initialization of the implicit object parameter is
very light. More tests will come when we get support for calling
member functions directly (e.g., o.m(a1, a2)).

llvm-svn: 59564
2008-11-18 23:14:02 +00:00
Steve Naroff 119f60e12a Fix <rdar://problem/6329769> [sema] crash on duplication definition of interface with protocols.
As soon as we detect duplicate interfaces, discontinue further semantic checks (returning the original interface).

This is now consistent with how we handle protocols (and less error prone in general).

llvm-svn: 59541
2008-11-18 19:15:30 +00:00
Torok Edwin c63831dd6a remove this testcase, it fails with -verify still
llvm-svn: 59539
2008-11-18 18:48:14 +00:00
Nuno Lopes b4e7e859e2 fix test. it now crashes, but thats another problem..
llvm-svn: 59537
2008-11-18 17:57:01 +00:00
Torok Edwin 1403f404da add testcase for PR3093
llvm-svn: 59534
2008-11-18 17:31:32 +00:00
Douglas Gregor 4ea8043d6f As threatened previously: consolidate name lookup and the creation of
DeclRefExprs and BlockDeclRefExprs into a single function
Sema::ActOnDeclarationNameExpr, eliminating a bunch of duplicate
lookup-name-and-check-the-result code.

Note that we still have the three parser entry points for identifiers,
operator-function-ids, and conversion-function-ids, since the parser
doesn't (and shouldn't) know about DeclarationNames. This is a Good
Thing (TM), and there will be more entrypoints coming (e.g., for C++
pseudo-destructor expressions).

llvm-svn: 59527
2008-11-18 15:03:34 +00:00
Douglas Gregor 163c58502a Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.

Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.

Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.

Extended Declarator to store overloaded operator names. 
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator. 

Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.

llvm-svn: 59526
2008-11-18 14:39:36 +00:00
Zhongxing Xu 19cad71552 Add test cast for struct array.
llvm-svn: 59522
2008-11-18 13:30:46 +00:00
Chris Lattner 74112917b2 implement a fixme by making warnings for ++/-- on non-modifiable-lvalues better.
llvm-svn: 59484
2008-11-18 01:26:17 +00:00
Sebastian Redl 8071edb297 Implement effects of 'mutable', and a few comments from Chris on its parsing.
llvm-svn: 59470
2008-11-17 23:24:37 +00:00
Douglas Gregor 92751d41a0 Eliminate all of the placeholder identifiers used for constructors,
destructors, and conversion functions. The placeholders were used to
work around the fact that the parser and some of Sema really wanted
declarators to have simple identifiers; now, the code that deals with
declarators will use DeclarationNames.

llvm-svn: 59469
2008-11-17 22:58:34 +00:00
Steve Naroff 773cdc7c0d Fix <rdar://problem/6333904> [sema] message lookup on super is incorrect
Missing special lookup rule in Sema::ActOnInstanceMessage().

llvm-svn: 59467
2008-11-17 22:29:32 +00:00
Douglas Gregor 0f492d1a11 Only test test/CodeGenObjC/synchronized.m as a i686-apple-darwin8 target
llvm-svn: 59463
2008-11-17 20:45:14 +00:00
Douglas Gregor ae2fbad373 Updated IdentifierResolver to deal with DeclarationNames. The names of
C++ constructors, destructors, and conversion functions now have a
FETokenInfo field that IdentifierResolver can access, so that these
special names are handled just like ordinary identifiers. A few other
Sema routines now use DeclarationNames instead of IdentifierInfo*'s.

To validate this design, this code also implements parsing and
semantic analysis for id-expressions that name conversion functions,
e.g.,

  return operator bool();

The new parser action ActOnConversionFunctionExpr takes the result of
parsing "operator type-id" and turning it into an expression, using
the IdentifierResolver with the DeclarationName of the conversion
function. ActOnDeclarator pushes those conversion function names into
scope so that the IdentifierResolver can find them, of course.

llvm-svn: 59462
2008-11-17 20:34:05 +00:00
Chris Lattner 9b3bbe9db7 Implement rdar://6319320: give a good diagnostic for cases where people
are trying to use the old GCC "casts as lvalue" extension.  We don't and
will hopefully never support this.

llvm-svn: 59460
2008-11-17 19:51:54 +00:00
Steve Naroff 753567f2c1 Fix <rdar://problem/6316324> [sema] spurious warning on comparison of qualified id.
llvm-svn: 59459
2008-11-17 19:49:16 +00:00
Fariborz Jahanian e3126a24e3 Test case for objective-c's @synchronized statement.
llvm-svn: 59451
2008-11-17 18:03:28 +00:00
Steve Naroff ecf2bb8724 Fix <rdar://problem/6320086> parser rejects block capturing ivar.
llvm-svn: 59444
2008-11-17 16:28:52 +00:00
Douglas Gregor d69246bd5b Some cleanups for C++ operator overloading
llvm-svn: 59443
2008-11-17 16:14:12 +00:00
Douglas Gregor 9edcc802c3 Simplify error messages for two-parameter overloaded increment/decrement operators
llvm-svn: 59442
2008-11-17 15:03:30 +00:00
Nuno Lopes e236a48210 fix folding of comma if given a non-constant operand.
Eli please take a look, as I'm not sure if this gets the extension warning in the right place

llvm-svn: 59422
2008-11-16 20:09:07 +00:00
Chris Lattner 962b4eed9d Fix PR3075, __builtin_stdarg_start being misprototyped. This affects netbsd headers.
llvm-svn: 59419
2008-11-16 18:43:46 +00:00
Zhongxing Xu e76577a97d add targe triple commandline option to fix test failure on Linux.
llvm-svn: 59412
2008-11-16 09:17:52 +00:00
Zhongxing Xu a3b2ef6fa9 Re-enable array-struct test.
llvm-svn: 59396
2008-11-16 04:47:39 +00:00
Ted Kremenek 3ebd7dea7e Add a test case for compound assignments that lazily symbolicate the value of the LHS when the computation type is an integer of more bits.
llvm-svn: 59352
2008-11-15 04:44:13 +00:00
Sebastian Redl ccdfabab35 Implement parsing and semantic checking of the 'mutable' keyword.
Thanks to Doug for the review. Actual effects of mutable to follow.

llvm-svn: 59331
2008-11-14 23:42:31 +00:00
Chris Lattner 0046de17e5 Fix a couple of suboptimalities in error recovery.
1. In the top level of ParseStatementOrDeclaration, don't eat a } if we
   just parsed a statement if it list there.  Also, don't even bother
   emitting an error about a missing semicolon if the statement had a 
   bug (an rbrace is fine).
2. In do/while parsing, don't require a 'while' to be present if the do
   body didn't parse.

This allows us to generate a clean diagnostic for this code:

t.c:1:22: error: expected expression
void foo (void) { do . while (0); }
                     ^

Thanks to Neil for pointing this out.

llvm-svn: 59256
2008-11-13 18:52:53 +00:00
Chris Lattner 7464fc784e disable these two tests, they crash and take a long time to run crashreporter etc.
llvm-svn: 59254
2008-11-13 18:45:47 +00:00
Chris Lattner 9226b92563 implement a fixme :), switch to -verify mode.
llvm-svn: 59253
2008-11-13 18:42:17 +00:00
Ted Kremenek 7d5389e4b3 - Revert r59229 and r59232: AllocRegion should be immutable.
- Temporarily disabled test Analysis/array-struct.c for region store.

llvm-svn: 59245
2008-11-13 15:42:31 +00:00
Zhongxing Xu e9857ddcc0 Add test for unsigned array index.
llvm-svn: 59239
2008-11-13 09:20:05 +00:00
Zhongxing Xu b9ec8f555f Add test for incomplete struct pointer.
llvm-svn: 59236
2008-11-13 08:44:52 +00:00
Zhongxing Xu 06a04bd1ae Add a test case for alloca().
llvm-svn: 59233
2008-11-13 07:59:15 +00:00
Ted Kremenek 16866d6fd8 GRExprEngine/CFRefCount/GRSimpleVals: We don't do any special handling (yet) of vector types. Add explicit checks that when we process integers that they really are scalars.
llvm-svn: 59225
2008-11-13 06:10:40 +00:00
Eli Friedman 5a332ea01f Fix for crash issues with comma operators with a void first operand, and
some more bullet-proofing/enhancements for tryEvaluate.  This shouldn't 
cause any behavior changes except for handling cases where we were 
crashing before and being able to evaluate a few more cases in tryEvaluate.
 
This should settle the minor mess surrounding r59196.

llvm-svn: 59224
2008-11-13 06:09:17 +00:00
Ted Kremenek 45698bf05f GRExprEngine::VisitInitListExpr:
- Don't crash on vector types.
- Handle typedefs.

llvm-svn: 59220
2008-11-13 05:05:34 +00:00
Eli Friedman 8553a98b8e Backout of r59196, plus a new ICE test. Sorry if this is a
little rude; I figure it's cleaner to just back this out now so 
it doesn't get forgotten or mixed up with other checkins.

The modification to isICE is simply wrong; I've added a test that the 
change to isICE breaks.

I'm pretty sure the modification to tryEvaluate is also wrong.  
At the very least, there's some serious miscommunication going on here, 
as this is going in exactly the opposite direction of r59105.  My 
understanding is that tryEvaluate is not supposed to care about side 
effects.  That said, a lot of the clients to tryEvaluate are 
expecting it to enforce a no-side-effects policy, so we probably need 
another method that provides that guarantee.

llvm-svn: 59212
2008-11-13 02:13:11 +00:00
Daniel Dunbar c7ec5fcf24 Fix bug in constant evaluation exposed by 176.gcc.
- Evaluation of , operator used bogus assumption that LHS could be
   evaluated as an integral expression even though its type is
   unspecified.

This change is making isICE very permissive of the LHS in non-evaluated 
contexts because it is not clear what predicate we would use to reject 
code here. The standard didn't offer me any guidance; opinions?

llvm-svn: 59196
2008-11-13 00:03:19 +00:00
Chris Lattner 6515bcc3c6 Fix a FIXME by improving a diagnostic, add a testcase for PR3048
llvm-svn: 59167
2008-11-12 21:25:45 +00:00
Sebastian Redl 15b7160a17 64-bit test fixes.
llvm-svn: 59165
2008-11-12 21:19:11 +00:00
Douglas Gregor a11693bc37 Implement support for operator overloading using candidate operator
functions for built-in operators, e.g., the builtin

  bool operator==(int const*, int const*)

can be used for the expression "x1 == x2" given:

  struct X {
    operator int const*();
  } x1, x2;

The scheme for handling these built-in operators is relatively simple:
for each candidate required by the standard, create a special kind of
candidate function for the built-in. If overload resolution picks the
built-in operator, we perform the appropriate conversions on the
arguments and then let the normal built-in operator take care of it. 

There may be some optimization opportunity left: if we can reduce the
number of built-in operator overloads we generate, overload resolution
for these cases will go faster. However, one must be careful when
doing this: GCC generates too few operator overloads in our little
test program, and fails to compile it because none of the overloads it
generates match.

Note that we only support operator overload for non-member binary
operators at the moment. The other operators will follow.

As part of this change, ImplicitCastExpr can now be an lvalue.

llvm-svn: 59148
2008-11-12 17:17:38 +00:00
Eli Friedman 9a156e5c1e Some additions to tryEvaluate I've had sitting around for a while.
This pushes it a lot closer to being able to deal with most of the stuff 
CodeGen's constant expression evaluator knows how to deal with.  This 
also fixes PR3003.

The test could possibly use some improvement, but this'll work for now.  
Test 6 is inspired by PR3003; the other tests are mostly just designed
to exercise the new code.  The reason for the funny structure of the 
tests is that type fixing for arrays inside of structs is the only place 
in Sema that calls tryEvaluate, at least for the moment.

llvm-svn: 59125
2008-11-12 09:44:48 +00:00
Sebastian Redl 85a4019167 Fix testcase for 64-bit systems.
llvm-svn: 59099
2008-11-12 00:18:32 +00:00
Anton Korobeynikov fdf389b9e4 Codegen support for fastcall & stdcall CC.
Patch by Ilya Okonsky!

llvm-svn: 59080
2008-11-11 20:21:14 +00:00
Sebastian Redl c470476420 Implement C++ 'typeid' parsing and sema.
llvm-svn: 59042
2008-11-11 11:37:55 +00:00
Chris Lattner bd178d51ff merge some testcases together.
llvm-svn: 59031
2008-11-11 06:42:53 +00:00
Chris Lattner 4497fbf6e0 remove the wrong PR # from the file name.
llvm-svn: 59029
2008-11-11 06:28:10 +00:00
Chris Lattner d75e4e59b9 add PR#
llvm-svn: 59028
2008-11-11 06:27:34 +00:00
Chris Lattner 8c5dd730ce Fix PR3031 by silencing follow-on errors in invalid declarations.
llvm-svn: 59027
2008-11-11 06:13:16 +00:00
Daniel Dunbar 471d9ddeab These tests have no needed to redirect stderr to stdout.
llvm-svn: 59019
2008-11-11 04:09:47 +00:00
Zhongxing Xu f8b84b0def Add && to test command.
llvm-svn: 59014
2008-11-11 01:25:18 +00:00
Douglas Gregor cd695e500d Basic support for taking the address of an overloaded function
llvm-svn: 59000
2008-11-10 20:40:00 +00:00
Douglas Gregor 49de5340c0 Improve parser error recovery after a constructor initializer
llvm-svn: 58989
2008-11-10 16:59:40 +00:00
Douglas Gregor f52cdd0124 Allow user-defined conversions during reference binding
llvm-svn: 58988
2008-11-10 16:14:15 +00:00
Zhongxing Xu 7be05ed6b8 Add region store model to path-sensitive testing.
llvm-svn: 58983
2008-11-10 09:43:12 +00:00
Argyrios Kyrtzidis 9e59b577d8 Introduce ScopedDecl::getLexicalDeclContext() which is different from ScopedDecl::getDeclContext() when there are nested-names.
e.g.:
  namespace A {
    void f(); // SemanticDC (getDeclContext) == LexicalDC (getLexicalDeclContext) == 'namespace A'
  }
  void A::f(); // SemanticDC == namespace 'A'
               // LexicalDC == global namespace

llvm-svn: 58948
2008-11-09 23:41:00 +00:00
Argyrios Kyrtzidis 16ac9be7f0 Implement Sema support for C++ nested-name-specifiers.
llvm-svn: 58916
2008-11-08 17:17:31 +00:00
Argyrios Kyrtzidis 32a0379575 Implement support for C++ nested-name-specifiers ('foo::bar::x') in the Parser side.
No Sema functionality change, just the signatures of the Action/Sema methods.

llvm-svn: 58913
2008-11-08 16:45:02 +00:00
Sebastian Redl f4485de48a Update C++ status to reflect parser capabilities for chapter 9 (classes). Slightly extend the class parser test.
llvm-svn: 58909
2008-11-08 15:40:37 +00:00
Daniel Dunbar 8ec8048f93 "Fix" PR3021, don't crash on generating record types when we can't
generate the type of a member.

llvm-svn: 58889
2008-11-08 04:42:29 +00:00
Sebastian Redl 015085fafa Greatly improve static_cast diagnostics
llvm-svn: 58873
2008-11-07 23:29:29 +00:00
Douglas Gregor a1f013e8ed Initial, partially-baked support for implicit user-defined conversions by conversion functions
llvm-svn: 58870
2008-11-07 22:36:19 +00:00
Argyrios Kyrtzidis e442635c37 Changes in preparation for nested-name-specifiers.
-When parsing declarators, don't depend on "CurScope->isCXXClassScope() == true" for constructors/destructors
-For C++ member declarations, don't depend on "Declarator.getContext() == Declarator::MemberContext"

llvm-svn: 58866
2008-11-07 22:02:30 +00:00
Douglas Gregor dbc5daf058 Parsing, ASTs, and semantic analysis for the declaration of conversion
functions in C++, e.g.,

  struct X {
    operator bool() const;
  };

Note that these conversions don't actually do anything, since we don't
yet have the ability to use them for implicit or explicit conversions.

llvm-svn: 58860
2008-11-07 20:08:42 +00:00
Anders Carlsson aaa183e944 include alloca.h instead of malloc.h. If this doesn't work for everyone we can just declare alloca directly in the file.
llvm-svn: 58853
2008-11-07 15:41:33 +00:00
Argyrios Kyrtzidis a848ced426 Append the test runs with '&&'.
llvm-svn: 58851
2008-11-07 14:28:18 +00:00
Argyrios Kyrtzidis c118934d12 Bring in 'alloca' for the Analysis/stack-addr-ps.c test case.
llvm-svn: 58849
2008-11-07 14:00:25 +00:00
Argyrios Kyrtzidis 6709e7d4cc Fix crash caused by this:
void f() {
   int +; // crash here
}

llvm-svn: 58846
2008-11-07 13:01:22 +00:00
Douglas Gregor 7d5fc7e28b Initial, rudimentary implementation of operator overloading for binary
operators. For example, one can now write "x + y" where x or y is a
class or enumeration type, and Clang will perform overload resolution
for "+" based on the overloaded operators it finds.

The other kinds of overloadable operators in C++ will follow this same
approach. 

Three major issues remain:
  1) We don't find member operators
  2) Since we don't have user-defined conversion operators, we can't
  call any of the built-in overloaded operators in C++ [over.built].
  3) Once we've done the semantic checks, we drop the overloaded
  operator on the floor; it doesn't get into the AST at all.

llvm-svn: 58821
2008-11-06 23:29:22 +00:00
Douglas Gregor 11d0c4c098 Parsing, ASTs, and semantic analysis for the declaration of overloaded
operators in C++. Overloaded operators can be called directly via
their operator-function-ids, e.g., "operator+(foo, bar)", but we don't
yet implement the semantics of operator overloading to handle, e.g.,
"foo + bar".

llvm-svn: 58817
2008-11-06 22:13:31 +00:00
Sebastian Redl b426f63302 Sema-check virtual declarations. Complete dynamic_cast checking.
llvm-svn: 58804
2008-11-06 15:59:35 +00:00
Ted Kremenek eb39732d53 Add a test case for CFMakeCollectable.
llvm-svn: 58772
2008-11-05 22:17:39 +00:00
Douglas Gregor 831c93f6c0 Parsing, representation, and preliminary semantic analysis of destructors.
Implicit declaration of destructors (when necessary).

Extended Declarator to store information about parsed constructors
and destructors; this will be extended to deal with declarators that
name overloaded operators (e.g., "operator +") and user-defined
conversion operators (e.g., "operator int").

llvm-svn: 58767
2008-11-05 20:51:48 +00:00
Sebastian Redl 6a43b1c435 A small error message improvement and some comment cleanup for static_cast.
llvm-svn: 58762
2008-11-05 17:54:26 +00:00
Douglas Gregor cfd8ddc6de Keep track of whether a C++ class is an aggregate. Don't allow initialization of non-aggregates with initializer lists.
llvm-svn: 58757
2008-11-05 16:20:31 +00:00
Douglas Gregor 6f5431543a Implement C++ copy-initialization for declarations. There is now some
duplication in the handling of copy-initialization by constructor,
which occurs both for initialization of a declaration and for
overloading. The initialization code is due for some refactoring.

llvm-svn: 58756
2008-11-05 15:29:30 +00:00
Douglas Gregor e8381c00eb Initial implementation of parsing, semantic analysis, and AST-building
for constructor initializations, e.g.,

  class A { };
  class B : public A { 
    int m;
  public:
    B() : A(), m(17) { };
  };

llvm-svn: 58749
2008-11-05 04:29:56 +00:00
Anders Carlsson a6b508a28c Make it an error if an Objective-C declaration is not in the global scope.
llvm-svn: 58705
2008-11-04 16:57:32 +00:00
Douglas Gregor 5496d4caa0 Now that we have copy initialization support, use it for checking the default arguments
llvm-svn: 58692
2008-11-04 13:57:51 +00:00
Douglas Gregor 8e12c38115 Diagnose use of 'this' in a C++ default argument. Thanks to Eli for correcting my bogus assertion about it already being handled
llvm-svn: 58691
2008-11-04 13:41:56 +00:00
Douglas Gregor fa7431a807 Check that this cannot be used in a default argument. Happily, it was already implemented
llvm-svn: 58649
2008-11-03 22:47:57 +00:00
Douglas Gregor c28b57d703 Implicit support for direct initialization of objects of class type, e.g.,
X x(5, 7);

llvm-svn: 58641
2008-11-03 20:45:27 +00:00
Douglas Gregor 2fe9883a96 Standard conversion sequences now have a CopyConstructor field, to
cope with the case where a user-defined conversion is actually a copy
construction, and therefore can be compared against other standard
conversion sequences. While I called this a hack before, now I'm
convinced that it's the right way to go.

Compare overloads based on derived-to-base conversions that invoke
copy constructors. 

Suppress user-defined conversions when attempting to call a
user-defined conversion.

llvm-svn: 58629
2008-11-03 19:09:14 +00:00
Douglas Gregor 0537942f3c Add implicitly-declared default and copy constructors to C++ classes,
when appropriate.

Conversions for class types now make use of copy constructors. I've
replaced the egregious hack allowing class-to-class conversions with a
slightly less egregious hack calling these conversions standard
conversions (for overloading reasons).

llvm-svn: 58622
2008-11-03 17:51:48 +00:00
Douglas Gregor 66583c5ff3 Implement C++ DR 106 and C++ DR 540, both of which deal with
reference-collapsing. 

Implement diagnostic for formation of a reference to cv void.

Drop cv-qualifiers added to a reference type when the reference type
comes from a typedef.

llvm-svn: 58612
2008-11-03 15:51:28 +00:00
Chris Lattner 8cc7be369c Fix PR3001: if we have an error parsing an initializer, make sure to remove
the designator corresponding to it, otherwise Sema and later parsing will
get confused.

llvm-svn: 58603
2008-11-03 09:28:22 +00:00
Zhongxing Xu de297f8198 Add function side-effect test cast.
llvm-svn: 58565
2008-11-02 13:17:44 +00:00
Ted Kremenek f3d9f805c7 Add 'alloca' test case for return-of-stack-address checker.
llvm-svn: 58554
2008-11-02 00:37:31 +00:00
Douglas Gregor eebb5c10aa Semantic checking of constructor declarations and classification of default/copy constructors
llvm-svn: 58538
2008-10-31 20:25:05 +00:00
Douglas Gregor 26bee0b326 Implement basic support for converting constructors in user-defined
conversions.

Notes:
  - Overload resolution for converting constructors need to prohibit
    user-defined conversions (hence, the test isn't -verify safe yet).
  - We still use hacks for conversions from a class type to itself. 
    This will be the case until we start implicitly declaring the appropriate
    special member functions. (That's next on my list)

llvm-svn: 58513
2008-10-31 16:23:19 +00:00
Sebastian Redl 72b8aef613 Implement semantic checking of static_cast and dynamic_cast.
llvm-svn: 58509
2008-10-31 14:43:28 +00:00
Zhongxing Xu 87bfa4340c Add test code for array initialization.
llvm-svn: 58502
2008-10-31 10:23:14 +00:00
Douglas Gregor 61956c460a Add support for parsing and representing C++ constructor declarations.
Notes:
  - Constructors are never found by name lookup, so they'll never get
    pushed into any scope. Instead, they are stored as an 
    OverloadedFunctionDecl in CXXRecordDecl for easy overloading.
  - There's a new action isCurrentClassName that determines whether an
    identifier is the name of the innermost class currently being defined;
    we use this to identify the declarator-id grammar rule that refers to 
    a type-name. 
  - MinimalAction does *not* support parsing constructors.
  - We now handle virtual and explicit function specifiers.

llvm-svn: 58499
2008-10-31 09:07:45 +00:00
Daniel Dunbar f8362f9e5d "One" line fix for -parse-noop failure, "id" and several other things
were being treated as type names for non-Objective-C files.
 - Other lines are just because MinimalAction didn't have access to
   the LangOptions.

llvm-svn: 58498
2008-10-31 08:56:51 +00:00
Daniel Dunbar d678ae2da3 Quick fix for PR2950, infinite loop generating debug info for
recursive types.
 - Style will be clean up in further patches.

llvm-svn: 58490
2008-10-31 04:04:54 +00:00
Ted Kremenek d119c0bd24 Added missing 'expected-warning'
llvm-svn: 58481
2008-10-31 00:20:13 +00:00
Ted Kremenek 20cf431bce Enhance compound literal test case.
llvm-svn: 58480
2008-10-31 00:19:42 +00:00
Ted Kremenek 3d71fe1503 Add missing "expected warning".
Add compound literal with empty initializer (just to test the analyzer handles it).

llvm-svn: 58470
2008-10-30 23:17:05 +00:00
Ted Kremenek ae4d61efb2 Add method that will be invoked using the dot-syntax just to test that the missing -dealloc checker handles it.
llvm-svn: 58467
2008-10-30 23:00:13 +00:00
Ted Kremenek b7d13803ce Improve compound literal test case.
llvm-svn: 58447
2008-10-30 18:46:50 +00:00
Ted Kremenek d26da8cf82 Patch by Nikita Zhuk: test case for fix for false positive reported in PR2978.
llvm-svn: 58432
2008-10-30 15:19:43 +00:00
Daniel Dunbar c475d4224b NeXT: Emit protocol objects lazily.
- That is, the metadata for a protocol is only emitted if that
   protocol is actually used in the translation unit. This is
   important because Objective-C headers frequently contain a large
   number of protocol definitions, only a few of which will be used in
   any given file.

llvm-svn: 58400
2008-10-29 22:36:39 +00:00
Sebastian Redl 5c0098271b Remove workaround for reference. No longer necessary.
llvm-svn: 58395
2008-10-29 19:45:21 +00:00
Sebastian Redl 5f74e09f47 Fix missing %s in run string causing hang during tests.
llvm-svn: 58394
2008-10-29 19:29:09 +00:00
Ted Kremenek 82c1cc3d52 Fix crash reported in PR2923 where a function declared using typeof(another_function) would have FunctionDecl::getNumParams() return the number of parameters in the original function type and not the number of parameters in the actual FunctionDecl.
llvm-svn: 58392
2008-10-29 18:41:34 +00:00
Douglas Gregor cad304ba37 Simplify and correct the check for function redefinitions. This does two things:
- Allows definitions of overloaded functions :)
  - Eliminates extraneous error messages when we have a definition of a 
    function that isn't an overload but doesn't have exactly the same type
    as the original.
  

llvm-svn: 58382
2008-10-29 15:10:40 +00:00
Douglas Gregor ef30a5ff98 Implement overloading rules for reference binding
llvm-svn: 58381
2008-10-29 14:50:44 +00:00
Douglas Gregor 9774aa13c7 Temporary disable the const-object-declaration-without-initializer check, because it depends on linkage-specifier semantics we don't yet have
llvm-svn: 58377
2008-10-29 13:50:18 +00:00
Douglas Gregor 786ab2119f Tweak Sema::CheckReferenceInit so that it (optionally) computes an
ImplicitConversionSequence and, when doing so, following the specific
rules of [over.best.ics]. 

The computation of the implicit conversion sequences implements C++
[over.ics.ref], but we do not (yet) have ranking for implicit
conversion sequences that use reference binding.

llvm-svn: 58357
2008-10-29 02:00:59 +00:00
Douglas Gregor 8e1cf608dc Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:

  - Try/Perform-ImplicitConversion now handles implicit conversions
    that don't involve references.
  - Try/Perform-CopyInitialization uses
    CheckSingleAssignmentConstraints for C. PerformCopyInitialization
    is now used for all argument passing and returning values from a
    function.
  - Diagnose errors with declaring references and const values without
    an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
  
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.

llvm-svn: 58353
2008-10-29 00:13:59 +00:00
Daniel Dunbar 03a3844c66 Add attribute always_inline support.
llvm-svn: 58304
2008-10-28 00:17:57 +00:00
Mike Stump c60dcc25dd Skip random pathname characters better. I had a 5 in mine.
llvm-svn: 58291
2008-10-27 22:49:55 +00:00
Daniel Dunbar 0b288b8a59 Add test case to exercise IRgen "unsupported" path (mostly cleanup).
llvm-svn: 58286
2008-10-27 22:11:01 +00:00
Ted Kremenek 03ce9eeee2 Add 'expected-warning' for braces around scalar initializer
llvm-svn: 58280
2008-10-27 22:00:16 +00:00
Ted Kremenek c1739912c8 Added compound literal test case.
llvm-svn: 58279
2008-10-27 21:57:17 +00:00
Douglas Gregor e200adc503 Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts
  - ImplicitCastExpr is (still) used for all explicit casts
  - ExplicitCastExpr is now the root of all *explicit* casts
  - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
  - CXXFunctionalCastExpr inherits from ExplicitCastExpr
  - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all
    of the C++ named cast expression types (static_cast, dynamic_cast, etc.)
  - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, 
    CXXReinterpretCastExpr, and CXXConstCastExpr to 

Also, fixed returned-stack-addr.cpp, which broke once when we fixed
reinterpret_cast to diagnose double->int* conversions and again when
we eliminated implicit conversions to reference types. The fix is in
both testcase and SemaChecking.cpp.

Most of this patch is simply support for the renaming. There's very
little actual change in semantics.

llvm-svn: 58264
2008-10-27 19:41:14 +00:00
Sebastian Redl 344fc3db3f Fix some invalid casts that are detected by Sema now or soon.
llvm-svn: 58252
2008-10-27 16:34:21 +00:00
Douglas Gregor 89ebcb9d8d When destroying a translation unit, deallocate its owned declarations in reverse order, because there may be dependencies among the declarations.
llvm-svn: 58244
2008-10-27 12:50:38 +00:00
Steve Naroff 1d4a9a31b6 Fix <rdar://problem/6315646> clang on xcode: error: invalid operands to binary expression ('id<NSTableViewDelegate>' and 'XCExtendedArrayController *').
There is still a bug here (as the FIXME in the test case indicates). Prior to this patch, the bug would generate an error. Now, we simply do nothing (which is less harmful until we can get it right). The complete bug fix will require changing ASTContext::mergeTypes(), which I'd like to defer for now.

llvm-svn: 58241
2008-10-27 10:33:19 +00:00
Zhongxing Xu b32af436df Add test for SCA region store.
llvm-svn: 58235
2008-10-27 09:21:27 +00:00
Zhongxing Xu 7a2ce566bc Add test for SCA region store.
llvm-svn: 58234
2008-10-27 09:19:25 +00:00
Chris Lattner 9a53fdc23e implement some more FIXMEs, by rejecting more bogus stuff in
objc mode.

llvm-svn: 58216
2008-10-26 23:29:41 +00:00
Chris Lattner 46dcba6d2d add some simple designator testcases. Reject things like this:
struct foo Y[10] = {
  [4] .arr [2] 4  // expected-error {{expected '=' or another designator}}
};

because the "missing equals" extension only is valid if there 
is exactly one array designator.

llvm-svn: 58215
2008-10-26 23:22:23 +00:00
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