Chris Lattner [Wed, 22 Apr 2009 00:54:41 +0000 (00:54 +0000)]
Fix a problem with objc foreach loop. It turns out that objc mode changes
for scoping to match C99 even when in C89 mode. This patch fixes this
(eliminating a "redefinition of thisKey" error), and also prevents non-sensical
diagnostics in -pedantic mode like this:
t.m:7:8: warning: variable declaration in for loop is a C99-specific feature
for (id thisKey in keys) ;
^
Chris Lattner [Wed, 22 Apr 2009 00:03:30 +0000 (00:03 +0000)]
Fix some mishandling of the attr(gnu_inline) mode when used with
extern. Previously we would warn about it and ignore the attribute.
This is incorrect, it should be handled as a c89 "extern inline"
function. Many thanks to Matthieu Castet for pointing this out and
beating me over the head until I got it.
PR3988: extern inline function are not externally visible
Douglas Gregor [Tue, 21 Apr 2009 23:56:24 +0000 (23:56 +0000)]
Lazy deserialization of macro definitions for precompiled headers.
This optimization improves performance on the Carbon-prefixed "Hello,
World!" example by 57%. For reference, we're now about 2.25x faster
than GCC PCH. We're also pulling in far less of the PCH file:
Fix: <rdar://problem/6777209> false Dereference of null pointer in loop: pointer increment/decrement preserves non-nullness
When the StoreManager doesn't reason well about pointer-arithmetic, propagate
the non-nullness constraint on a pointer value when performing pointer
arithmetic uisng ++/--.
Douglas Gregor [Tue, 21 Apr 2009 22:32:33 +0000 (22:32 +0000)]
Don't bother writing a visible-declarations record for the translation
unit into the PCH file, since we won't be performing name lookup into
it anyway. Reduces the size of the Carbon.h PCH file by ~200k.
Chris Lattner [Tue, 21 Apr 2009 22:26:47 +0000 (22:26 +0000)]
fix marking of nested blocks with the "hasBlockDeclRefExprs" to
mark exactly the blocks which have references that are "live through".
This fixes a rejects valid:
rdar://6808730 - [sema] [blocks] block rejected at global scope
Douglas Gregor [Tue, 21 Apr 2009 22:25:48 +0000 (22:25 +0000)]
Lazy deserialization of the declaration chains associated with
identifiers from a precompiled header.
This patch changes the primary name lookup method for entities within
a precompiled header. Previously, we would load all of the names of
declarations at translation unit scope into a large DenseMap (inside
the TranslationUnitDecl's DeclContext), and then perform a special
"last resort" lookup into this DeclContext when we knew there was a
PCH file (see Sema::LookupName). Now, when we see an identifier named
for the first time, we load all of the declarations with that name
that are visible from the translation unit into the IdentifierInfo's
chain of declarations. Thus, the explicit "look into the translation
unit's DeclContext" code is gone, and Sema effectively uses the same
IdentifierInfo-based name lookup mechanism whether we are using a PCH
file or not.
This approach should help PCH scale with the size of the input program
rather than the size of the PCH file. The "Hello, World!" application
with Carbon.h as a PCH file now loads 20% of the identifiers in the
PCH file rather than 85% of the identifiers.
90% of the 20% of identifiers loaded are actually loaded when we
deserialize the preprocessor state. The next step is to make the
preprocessor load macros lazily, which should drastically reduce the
number of types, declarations, and identifiers loaded for "Hello,
World".
Refactor 'BasicStoreManager::CastRegion' and 'RegionStoreManager::CastRegion'
into StoreManager::CastRegion. Both methods were practically identical, and this
is core logic that is common to all StoreManagers since it defines the basic
invariants of the abstract memory model.
Daniel Dunbar [Tue, 21 Apr 2009 21:41:56 +0000 (21:41 +0000)]
Make sure to mark the interface as completed when we see an
@implementation that closes a @class delcaration.
- I don't know how to make a test case for this, but this strengthens
the invariants that hold internally. The functionality change here
is the edit to SemaDeclObjC.cpp.
Douglas Gregor [Tue, 21 Apr 2009 17:11:58 +0000 (17:11 +0000)]
Explictly track tentative definitions within Sema, then hand those
tentative definitions off to the ASTConsumer at the end of the
translation unit.
Eliminate CodeGen's internal tracking of tentative definitions, and
instead hook into ASTConsumer::CompleteTentativeDefinition. Also,
tweak the definition-deferal logic for C++, where there are no
tentative definitions.
Fixes <rdar://problem/6808352>, and will make it much easier for
precompiled headers to cope with tentative definitions in the future.
Daniel Dunbar [Tue, 21 Apr 2009 15:48:54 +0000 (15:48 +0000)]
Use an ASTRecordLayout to compute the sizeof an interface, not
addRecordToClass.
- Among other things, this fixes a crash when applying sizeof to an
interface with synthesized ivars, although things still aren't
"correct" here.
Steve Naroff [Tue, 21 Apr 2009 15:12:33 +0000 (15:12 +0000)]
Add pch reader/writer support for most of DeclObjC.h. Very close to reading/writing all ObjC AST nodes that we will encounter in header files (still a few FIXME's).
Once selector support is in place, we should be able to take this for a spin (and add test cases).
Chris Lattner [Tue, 21 Apr 2009 04:41:23 +0000 (04:41 +0000)]
use of predefined identifiers like __func__ at global scope warn in sema,
but crashed codegen. Fix this to report the name of the llvm function.
This fixes rdar://6808051
Daniel Dunbar [Tue, 21 Apr 2009 01:19:28 +0000 (01:19 +0000)]
Kill ASTContext::[gs]etFieldForDecl, instead we just lookup things
when we need them -- which is exactly what some code was already
doing!
- No intended functionality change.
Daniel Dunbar [Tue, 21 Apr 2009 01:18:01 +0000 (01:18 +0000)]
Kill ASTContext::[gs]etFieldForDecl, instead we just lookup things
when we need them -- which is exactly what some code was already
doing!
- No intended functionality change.
Douglas Gregor [Mon, 20 Apr 2009 20:36:09 +0000 (20:36 +0000)]
Write the identifier table into the PCH file as an on-disk hash table
that also includes the contents of the IdentifierInfo itself (the
various fields and flags, along with the chain of identifiers visible
at the top level that have that name).
We don't make any use of the hash table yet, except that our
identifier ID -> string mapping points into the hash table now.
Douglas Gregor [Mon, 20 Apr 2009 15:53:59 +0000 (15:53 +0000)]
Introduce the notion of a SemaConsumer, which is an ASTConsumer that
also gets access to the Sema object performing semantic analysis. This
will be used by the PCH writer to serialize Sema state.
Eli Friedman [Mon, 20 Apr 2009 08:23:18 +0000 (08:23 +0000)]
Some cleanup and bug-fixing for address-of checking. This causes a couple of
minor accepts-invalid regressions, but we weren't really rejecting them for
the right reason. We really need a more general solution to detect all the
cases of the promotion of arrays with a register storage class.
Daniel Dunbar [Mon, 20 Apr 2009 07:11:47 +0000 (07:11 +0000)]
Set a bit in IMAGE_INFO to indicate that we don't contain any
@synthesized ivars for superclasses.
- <rdar://problem/6806371> [clang] Mark code without miscompiled
@synthesized properties
Daniel Dunbar [Mon, 20 Apr 2009 06:54:31 +0000 (06:54 +0000)]
Lift out GetNamedIvarList.
Drop uses of GetFirstInvarInRecord, instead we lookup the ivars we
know are in the record.
- This is somewhat less efficient, but I need to detangle this code
first...