Commit Graph

5775 Commits

Author SHA1 Message Date
Chris Lattner 38378bf61f various "is invalid" cleanups for C++ ctors/dtors.
llvm-svn: 70021
2009-04-25 08:28:21 +00:00
Chris Lattner f6d1c9c7f0 This is a pretty big cleanup for how invalid decl/type are handle.
This gets rid of a bunch of random InvalidDecl bools in sema, changing
us to use the following approach:

1. When analyzing a declspec or declarator, if an error is found, we 
   set a bit in Declarator saying that it is invalid.
2. Once the Decl is created by sema, we immediately set the isInvalid
   bit on it from what is in the declarator.  From this point on, sema
   consistently looks at and sets the bit on the decl.

This gives a very clear separation of concerns and simplifies a bunch
of code.  In addition to this, this patch makes these changes:

1. it renames DeclSpec::getInvalidType() -> isInvalidType().
2. various "merge" functions no longer return bools: they just set the
   invalid bit on the dest decl if invalid.
3. The ActOnTypedefDeclarator/ActOnFunctionDeclarator/ActOnVariableDeclarator
   methods now set invalid on the decl returned instead of returning an
   invalid bit byref.
4. In SemaType, refering to a typedef that was invalid now propagates the
   bit into the resultant type.  Stuff declared with the invalid typedef
   will now be marked invalid.
5. Various methods like CheckVariableDeclaration now return void and set the
   invalid bit on the decl they check.


There are a few minor changes to tests with this, but the only major bad
result is test/SemaCXX/constructor-recovery.cpp.  I'll take a look at this
next.

llvm-svn: 70020
2009-04-25 08:06:05 +00:00
Douglas Gregor 25d85bcada Revert my PCH change. I'm happy now
llvm-svn: 70018
2009-04-25 07:18:06 +00:00
Douglas Gregor 9e17c07741 Temporarily try to build with PCH by default. Revert this change once
we see what trouble it causes.

llvm-svn: 70017
2009-04-25 06:28:32 +00:00
Chris Lattner 9af40c1e14 fix PR4049, a crash on invalid, by making sema install the right number of
parameters in a functiondecl, even if the decl is invalid and has a confusing
Declarator.  On the testcase, we now emit one beautiful diagnostic:

t.c:2:1: error: unknown type name 'unknown_type'
unknown_type f(void*)
^

GCC 4.0 produces:

t.c:2: error: syntax error before ‘f’
t.c: In function ‘f’:
t.c:2: error: parameter name omitted

and GCC 4.2:

t.c:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘f’

llvm-svn: 70016
2009-04-25 06:12:16 +00:00
Chris Lattner 47c0d00c3f rename getNumParmVarDeclsFromType back to getNumParams(),
remove a special case that was apparently for typeof() and
generalize the code in SemaDecl that handles typedefs to 
handle any sugar type (including typedef, typeof, etc).
Improve comment to make it more clear what is going on.

llvm-svn: 70015
2009-04-25 06:03:53 +00:00
Chris Lattner dfd637f204 add a new helper function to FunctionDecl instead of it being
static in Decl.cpp.

llvm-svn: 70014
2009-04-25 05:56:45 +00:00
Chris Lattner ae4ee5be22 in:
typedef void foo(void);

We get a typedef for a functiontypeproto with no arguments, not
one with one argument and type void.  This means the code being
removed in SemaDecl is dead.

llvm-svn: 70013
2009-04-25 05:51:56 +00:00
Daniel Dunbar 68f1d8ed0c Driver: -mkernel disables default use of unwind tables (although I
don't yet understand where this is happening in llvm-gcc).

llvm-svn: 70012
2009-04-25 05:49:54 +00:00
Chris Lattner 3f863f6827 set NewFD->setInvalidDecl() in one place, sharing code and ensuring that
functions with prototypes get the bit.

llvm-svn: 70011
2009-04-25 05:44:12 +00:00
Daniel Dunbar 11892e951d Driver: -mkernel and -fapple-kext imply -mno-red-zone.
llvm-svn: 70010
2009-04-25 05:33:23 +00:00
Daniel Dunbar ef2ffbc390 Fix pointer addressing and array subscripting of Objective-C interface
types.
 - I broke this in the switch to representing interfaces with opaque
   types.

 - <rdar://problem/6822660> clang crashes on subscript of interface in
   32-bit mode

llvm-svn: 70009
2009-04-25 05:08:32 +00:00
Ted Kremenek e75de95408 Hook up attribute 'objc_ownership_retain' to the analyzer. This attribute allows
users to specify that a method's argument is visibly retained (reference count
incremented).

llvm-svn: 70008
2009-04-25 01:21:50 +00:00
Douglas Gregor f005eac566 Make sure that the consumer sees all interested decls. This fixes Preview
llvm-svn: 70007
2009-04-25 00:41:30 +00:00
Ted Kremenek 2cfd264636 Add new checker-specific attribute 'objc_ownership_retain'. This isn't hooked up
to the checker yet, but essentially it allows a user to specify that an
Objective-C method or C function increments the reference count of a passed
object.

llvm-svn: 70005
2009-04-25 00:17:17 +00:00
Chris Lattner 12bdebbbf7 reject explicit pointer arithmetic on interface pointers in 64-bit objc ABI
llvm-svn: 70004
2009-04-24 23:50:08 +00:00
Douglas Gregor c62a133a38 When we de-serialize an Objective-C protocol, hand it to the AST consumer so that we can create metadata
llvm-svn: 70003
2009-04-24 23:42:14 +00:00
Ted Kremenek b97d093e16 Hook up __attribute__((objc_ownership_returns)) to the retain/release checker.
llvm-svn: 70002
2009-04-24 23:32:32 +00:00
Ted Kremenek 44e662cd4f Add new checker-specific attribute 'objc_ownership_returns'. This isn't hooked
up to the checker yet, but essentially it allows a user to specify that an
Objective-C method or C function returns an owned an Objective-C object.

llvm-svn: 70001
2009-04-24 23:09:54 +00:00
Anders Carlsson defc644e06 Add CXXExprWithCleanup
llvm-svn: 70000
2009-04-24 22:47:04 +00:00
Chris Lattner cd2a8c5864 fix the sizeof error recovery issue (sizeof-interface.m:attributeRuns)
by correctly propagating the fact that the type was invalid up to the
attributeRuns decl, then returning an ExprError when attributeRuns is
formed (like we do for normal declrefexprs).

llvm-svn: 69998
2009-04-24 22:30:50 +00:00
Douglas Gregor 9a1899ba42 Fix a pasto in the lookup of instance methods in the global pool
llvm-svn: 69996
2009-04-24 22:23:41 +00:00
Douglas Gregor 6525578397 Once the protocol list has been loaded from the PCH file, add it to
the Objective-C interface.

llvm-svn: 69993
2009-04-24 22:01:00 +00:00
Ted Kremenek 6a966b2486 Fix the same false positive reported in PR 2542 and <rdar://problem/6793409>
involving an NSAnimation object delegating its release to a delegate method.

llvm-svn: 69992
2009-04-24 21:56:17 +00:00
Douglas Gregor 4647cfac32 Fix two small but very nasty bugs in the PCH writer for method pools:
(1) Make sure to pad on-disk hash tables with 4 bytes, not 2, since
  the reader assumes that bucket data is aligned on 4-byte
  boundaries. 
  (2) Don't emit the number of factory methods twice. This was
  throwing off the data counts and therefore causing lookups to
  fail. I've added asserts so that this class of error cannot happen
  again.

llvm-svn: 69991
2009-04-24 21:49:02 +00:00
Douglas Gregor c78d34699f PCH support for the global method pool (= instance and factory method
pools, combined). The methods in the global method pool are lazily
loaded from an on-disk hash table when Sema looks into its version of
the hash tables.

llvm-svn: 69989
2009-04-24 21:10:55 +00:00
Fariborz Jahanian 969bc68195 Minor refactoring. No intended change in behavior.
llvm-svn: 69988
2009-04-24 21:07:43 +00:00
Steve Naroff 3fa455a1aa Add PCH support for #import.
llvm-svn: 69987
2009-04-24 20:03:17 +00:00
Ted Kremenek 53c5b7e0bd Minor refactoring: pass selector to getCommonMethodSummary(). No functionality
change.

llvm-svn: 69985
2009-04-24 18:19:07 +00:00
Ted Kremenek 6e86cafca3 retain/release checker: more hacks to workaround false positives cause by
delegates. When a reference counted object is passed as to a 'void*' argument to
a method stop tracking the reference count.

llvm-svn: 69984
2009-04-24 18:00:17 +00:00
Ted Kremenek 21895e0b89 Sentence case bug name.
llvm-svn: 69983
2009-04-24 17:51:19 +00:00
Ted Kremenek 8a5ad39a46 retain/release checker:
- Fix summary lookup for class methods to now use the (optional)
  ObjCInterfaceDecl associated with a message expression. This removes a
  long-standing FIXME.
- Partial fix for <rdar://problem/6062730> by stop tracking objects that
  are passed to [NSObject performSelector].  These methods are often used
  for delegates, which the analyzer doesn't reason about well yet.

llvm-svn: 69982
2009-04-24 17:50:11 +00:00
Anders Carlsson 95c56ebfb5 Make CXXTemporaryObjectExpr inherit from CXXConstructExpr.
llvm-svn: 69981
2009-04-24 17:34:38 +00:00
Fariborz Jahanian 1dcb32260a Avoid issuing spurious errors as side-effect of diagnosing
application of sizeof on an interface.

llvm-svn: 69980
2009-04-24 17:34:33 +00:00
Fariborz Jahanian ce567657fd Minor refactoring. No change in functionality.
llvm-svn: 69979
2009-04-24 17:15:27 +00:00
Steve Naroff b87eeaeadf Use cast_or_null instead of ternary operator (suggested by Doug).
llvm-svn: 69975
2009-04-24 16:59:10 +00:00
Fariborz Jahanian a123b64218 Some code clean up of objc2's bitmap layout.
llvm-svn: 69970
2009-04-24 16:17:09 +00:00
Steve Naroff 54b6db1763 Allow the next catoregory slot to be null.
llvm-svn: 69969
2009-04-24 16:08:42 +00:00
Chris Lattner 40493eb6eb fix rdar://6816766 - Crash with function-like macro test at end of directive.
llvm-svn: 69964
2009-04-24 07:15:46 +00:00
Chris Lattner 469fdc6af3 simplification and speedup
llvm-svn: 69963
2009-04-24 07:15:22 +00:00
Anders Carlsson 643e0a40db Fix assert.
llvm-svn: 69961
2009-04-24 06:06:07 +00:00
Anders Carlsson b17a2c3d8f CXXTempVarDecls aren't looked up. Fixes tests.
llvm-svn: 69960
2009-04-24 06:02:55 +00:00
Anders Carlsson a861067029 Add an ASTContext parameter to CXXTemporaryObjectExpr.
llvm-svn: 69959
2009-04-24 05:44:25 +00:00
Anders Carlsson 56c5bd8d23 Add a VarDecl parameter to the CXXTemporaryObjectExpr constructor. It's unused for now, so no functionality change yet. Also, create CXXTempVarDecls to pass to the CXXTemporaryObjectExpr ctor.
llvm-svn: 69957
2009-04-24 05:23:13 +00:00
Anders Carlsson e500faf8c8 Create a CXXConstructExpr instead of a CXXTemporaryObjectExpr in InitializeVarWithConstructor.
llvm-svn: 69956
2009-04-24 05:16:06 +00:00
Anders Carlsson 32ebd29b99 Make the CXXConstructExpr public and add a StmtClass to it. No functionality change.
llvm-svn: 69954
2009-04-24 05:04:04 +00:00
Daniel Dunbar c1b1b4b2c9 Don't run dsymutil when making a fat executable direct source.
- Otherwise, we will end up with stray .dSYM files which don't get
   lipo'ed or removed.

 - Ideally we would run dsymutil on the result, but we don't have the
   infrastructure for that yet. Note that gcc doesn't handle this case
   either.

 - <rdar://problem/6809621> [driver] clang leaves .dSYM files lying
   around in tmp.

llvm-svn: 69951
2009-04-24 03:03:52 +00:00
Douglas Gregor 38feed810f Eliminate Sema::ObjCAliasDecls. This is based on Steve's fix, but also
updates name lookup so that we see through @compatibility_alias
declarations to their underlying interfaces.

llvm-svn: 69950
2009-04-24 02:57:34 +00:00
Sanjiv Gupta 4742515771 Clang part of r69947. Reverting back 69574 as it is no longer needed.
llvm-svn: 69949
2009-04-24 02:40:57 +00:00
Douglas Gregor ac3531247f Fix Objective-C crashes
llvm-svn: 69945
2009-04-24 02:15:36 +00:00