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.
Chris Lattner [Fri, 24 Apr 2009 22:30:50 +0000 (22:30 +0000)]
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).
Fix the same false positive reported in PR 2542 and <rdar://problem/6793409>
involving an NSAnimation object delegating its release to a delegate method.
Douglas Gregor [Fri, 24 Apr 2009 21:49:02 +0000 (21:49 +0000)]
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.
Douglas Gregor [Fri, 24 Apr 2009 21:10:55 +0000 (21:10 +0000)]
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.
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.
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.
Anders Carlsson [Fri, 24 Apr 2009 05:23:13 +0000 (05:23 +0000)]
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.
Anders Carlsson [Fri, 24 Apr 2009 04:57:02 +0000 (04:57 +0000)]
Move the CXXConstructExpr before the CXXTemporaryObjectExpr so that the temporary object expr can inherit from the construct expr. No functionality change.
Douglas Gregor [Fri, 24 Apr 2009 02:57:34 +0000 (02:57 +0000)]
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.
Chris Lattner [Fri, 24 Apr 2009 00:30:45 +0000 (00:30 +0000)]
Fix rdar://6821047 - clang crashes on subscript of interface in 64-bit mode
Several changes here:
1. We change Type::isIncompleteType to realize that forward declared
interfaces are incomplete. This eliminate special case code for this
from the sizeof path, and starts us rejecting P[4] when P is a pointer
to an incomplete interface.
2. Explicitly reject P[4] when P points to an interface in non-fragile ABI
mode.
3. Switch the sizeof(interface) diagnostic back to an error instead of a
warning in non-fragile abi mode.
Douglas Gregor [Fri, 24 Apr 2009 00:11:27 +0000 (00:11 +0000)]
Eliminate Sema::ObjCImplementations, relying instead on name lookup. What's good for uniformity is good for PCH (or is it the other way around?).
As part of this, make ObjCImplDecl inherit from NamedDecl (since
ObjCImplementationDecls now need to have names so that they can be
found). This brings ObjCImplDecl very, very close to
ObjCContainerDecl; we may be able to merge them soon.
Douglas Gregor [Thu, 23 Apr 2009 23:18:26 +0000 (23:18 +0000)]
Eliminate Sema::ObjCProtocols. Instead, we place ObjCProtocolDecls in
their own namespace (IDNS_Protocol) and use the normal name-lookup
routines to find them. Aside from the simplification this provides
(one less DenseMap!), it means that protocols will be lazily
deserialized from PCH files.
Make the code size of the selector table block match the code size of
the type and decl blocks.
Douglas Gregor [Thu, 23 Apr 2009 22:29:11 +0000 (22:29 +0000)]
PCH support for all of the predefined Objective-C types, such as id,
SEL, Class, Protocol, CFConstantString, and
__objcFastEnumerationState. With this, we can now run the Objective-C
methods and properties PCH tests.
retain/release checker: Don't call isTrackedObject() with the canonical type.
This was preventing the checker from tracking return objects referenced by 'id'.
Per discussions with Ken Ferry and Paul Marks (<rdar://problem/6815234>) greatly
extend the number of objects tracked by the retain/release checker by assuming
that all class and instance methods should follow Cocoa object "getter" and
"alloc/new" conventions.
Handle corner case where clang-cc is invoked directly to compile preprocessed source file without -main-file-name. In this case, CDDebugInfo is not able identify correct main source file becase SM.isFromMainFile() returns true for locations from header files as well as locations from main source file.
This patch takes conservative approach by not emitting more then one compile unit with isMain bit set.
Steve Naroff [Thu, 23 Apr 2009 15:15:40 +0000 (15:15 +0000)]
Sema::ActOnStartClassInterface(): Use PushOnScopeChains().
This enables class recognition to work with PCH. I believe this means we can remove Sema::ObjCInterfaceDecls and it's usage within Sema::LookupName(). Will investigate.
Daniel Dunbar [Thu, 23 Apr 2009 08:03:21 +0000 (08:03 +0000)]
Mark IMAGE_INFO as constant on x86_64-darwin.
- This shouldn't change anything, we never actually access it, but
this is consistent with llvm-gcc (and 32-bit)
Daniel Dunbar [Thu, 23 Apr 2009 07:00:09 +0000 (07:00 +0000)]
Add implicit definition of objc_msgSend.
- As with malloc and friends, this is important where the return type
on a 64-bit platform would otherwise end up discarding the upper
32-bits.
Chris Lattner [Thu, 23 Apr 2009 05:30:27 +0000 (05:30 +0000)]
the logic for computing __func__ and friends is really broken:
the type assigned by sema (and is visible with sizeof(__func__) for
example) has nothing to do with what codegen ends up producing.
We should eventually add a method on PredefinedExpr to handle this.
In the meantime, just set up some framework and add some fixme's.
Douglas Gregor [Thu, 23 Apr 2009 03:23:08 +0000 (03:23 +0000)]
The ivars in an ObjCImplementationDecl are now stored in the
DeclContext rather than in a separate list. This makes PCH
(de-)serialization trivial, so that ivars can be loaded lazily.
Anders Carlsson [Thu, 23 Apr 2009 02:32:43 +0000 (02:32 +0000)]
Add a CXXConstructExpr that represents an implicit call to a C++ constructor. I think CXXTemporaryObjectExpr is going to become a subclass of CXXConstructExpr, since CXXTemporaryObjectExpr represents a syntactic temporary, for example T()
Douglas Gregor [Thu, 23 Apr 2009 01:02:12 +0000 (01:02 +0000)]
Eliminate the three SmallVectors in ObjCImplDecl (for instance
methods, class methods, and property implementations) and instead
place all of these entities into the DeclContext.
This eliminates more linear walks when looking for class or instance
methods and should make PCH (de-)serialization of ObjCDecls trivial
(and lazy).
Add PathDiagnosticRange to PathDiagnostics. These simply wrap SourceRange and
indicate whether or not the range represents an absolute range or should be
extended by lexing to the end of the token.
Douglas Gregor [Wed, 22 Apr 2009 20:56:09 +0000 (20:56 +0000)]
Eliminate Sema::KnownFunctionIDs, so that Sema doesn't end up pulling
in a bunch of declarations from the PCH file. We're down to loading
very few declarations in Carbon-prefixed "Hello, World!":
Eli Friedman [Wed, 22 Apr 2009 19:23:09 +0000 (19:23 +0000)]
Add handling for complex->int, int->complex float, and float->complex
int. Note that constant int->complex float and float->complex int casts
were being miscompiled.
Douglas Gregor [Wed, 22 Apr 2009 19:09:20 +0000 (19:09 +0000)]
Minimize the number and kind of "external definitions" that the PCH
file needs to store. CodeGen needs to see these definitions (via
HandleTopLevelDecl), otherwise it won't be able to generate code for
them.
This patch notifies the consumer (e.g., CodeGen) about function
definitions and variable definitions when the corresponding
declarations are deserialized. Hence, we don't eagerly deserialize the
declarations for every variable or function that has a definition in
the PCH file. This gives another 5% speedup for the Carbon-prefixed
"Hello, World!", and brings our PCH statistics down to something far
more reasonable:
Douglas Gregor [Wed, 22 Apr 2009 18:49:13 +0000 (18:49 +0000)]
Lazy loading of builtins for precompiled headers.
PCH files now contain complete information about builtins, including
any declarations that have been synthesized as part of building the
PCH file. When using a PCH file, we do not initialize builtins at all;
when needed, they'll be found in the PCH file.
This optimization translations into a 9% speedup for "Hello, World!"
with Carbon.h as a prefix header and roughly a 5% speedup for 403.gcc
with its prefix header. We're also reading less of the PCH file for
"Hello, World!":