Commit Graph

85 Commits

Author SHA1 Message Date
Daniel Dunbar b616260624 Use %S, not `pwd`, and enable a line that *does* work.
- Doug, please check.

llvm-svn: 77778
2009-08-01 05:57:38 +00:00
Mike Stump 93a7ed1fc7 Revert this, we can now avoid error cascades better.
llvm-svn: 76691
2009-07-21 23:52:50 +00:00
Mike Stump d7b9282e48 Revert recent change, I now have a better way to solve this (thanks Chris).
llvm-svn: 76681
2009-07-21 23:41:23 +00:00
Mike Stump bdbe099dd2 Prep for new warning.
llvm-svn: 76670
2009-07-21 22:54:02 +00:00
Argyrios Kyrtzidis 11a846ab53 Fixes for a couple of things:
- Declaration context of ParmVarDecls (that we got from the Declarator) was not their containing function.
- C++ out-of-line method definitions didn't get an access specifier.

Both were exposed by a crash when emitting a C++ method to a PCH file (assert at Decl::CheckAccessDeclContext()).

llvm-svn: 75597
2009-07-14 03:18:53 +00:00
Steve Naroff 7cae42b07a This patch includes a conceptually simple, but very intrusive/pervasive change.
The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.

This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.

By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 

Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.

llvm-svn: 75314
2009-07-10 23:34:53 +00:00
Douglas Gregor 27821cee82 Make ASTContext explicitly keep track of the declaration for the C
FILE type, rather than using name lookup to find FILE within the
translation unit. Within precompiled headers, FILE is treated as yet
another "special type" (like __builtin_va_list).

This change should provide a performance improvement (not verified),
since the lookup into the translation unit declaration 
forces the (otherwise unneeded) construction of a large hash table.
More importantly, with precompiled headers, the construction
of that table requires deserializing most of the top-level
declarations from the precompiled header, which are then unused.

Fixes PR 4509.

llvm-svn: 74911
2009-07-07 16:35:42 +00:00
Douglas Gregor 0086a5a3bb Introduce the notion of "Relocatable" precompiled headers, which are built
with a particular system root directory and can be used with a different
system root directory when the headers it depends on have been installed.
Relocatable precompiled headers rewrite the file names of the headers used
when generating the PCH file into the corresponding file names of the 
headers available when using the PCH file.

Addresses <rdar://problem/7001604>.

llvm-svn: 74885
2009-07-07 00:12:59 +00:00
Douglas Gregor 1342e84c17 Fix PR 4489, a crash in PCH loading that occurs when loading the name
of a top-level declaration loads another top-level declaration of the
same name whose type depends on the first declaration having been
completed. This commit breaks the circular dependency by delaying
loads of top-level declarations triggered by loading a name until we
are no longer recursively loading types or declarations.

llvm-svn: 74847
2009-07-06 18:54:52 +00:00
Douglas Gregor e4d00dd7f6 Fix PR 4489, a PCH crash during de-serialization.
llvm-svn: 74664
2009-07-01 23:29:14 +00:00
Douglas Gregor 45fe0364aa Make precompiled headers work with -E. When we're only preprocessing
(with -E), we turn the PCH include into an implicit include of the
file from which the PCH file was generated.

llvm-svn: 71534
2009-05-12 01:31:05 +00:00
Chris Lattner 5c633e38a8 Make this test portable to non-x86 hosts, patch by Mark Cianciosa!
llvm-svn: 71146
2009-05-07 04:21:16 +00:00
Douglas Gregor e6648fb79e Implement checking for macro definitions that occur on the command
line when using a PCH that were not provided when building the PCH
file. If those names were used as identifiers somewhere in the PCH
file, reject the PCH file.

llvm-svn: 70321
2009-04-28 20:33:11 +00:00
Douglas Gregor c379c07240 Allow some differences between the predefines buffer used to build a
PCH file and the predefines buffer used when including the PCH
file. We (explicitly) detect conflicting macro definitions (rejecting
the PCH file) and about missing macro definitions (they'll be
automatically pulled from the PCH file anyway).

We're missing some checking to make sure that new macro definitions
won't have any impact on the PCH file itself (e.g., #define'ing an
identifier that the PCH file used).

llvm-svn: 70316
2009-04-28 18:58:38 +00:00
Douglas Gregor 61cac2b295 Add Sema::ExtVectorDecls and Sema::ObjCCategoryImpls to the PCH file. Since these vectors are very, very rarely used and, when used in headers, and even when used are relatively small, we load them eagerly.
llvm-svn: 70240
2009-04-27 20:06:05 +00:00
Douglas Gregor 988e627f8c Fix a problem with the RUN line of one of the PCH tests
llvm-svn: 70227
2009-04-27 18:49:47 +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
Steve Naroff 3fa455a1aa Add PCH support for #import.
llvm-svn: 69987
2009-04-24 20:03:17 +00:00
Douglas Gregor 512b077803 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.

llvm-svn: 69932
2009-04-23 22:29:11 +00:00
Steve Naroff 0cbba990d7 More PushOnScopeChain() FIXME's.
llvm-svn: 69894
2009-04-23 16:00:56 +00:00
Steve Naroff 3c301dc573 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.

llvm-svn: 69891
2009-04-23 15:15:40 +00:00
Steve Naroff 2ddea05bca Add PCH read/write support for Objective-C Selectors.
Note: This support is non-lazy. Once we get "Cocoa.h" humming, we can optimize this.
llvm-svn: 69884
2009-04-23 10:39:46 +00:00
Douglas Gregor 85e110828e PCH support for Objective-C property declarations (UNTESTED!)
llvm-svn: 69843
2009-04-22 23:20:34 +00:00
Douglas Gregor acfc76cc63 Support locally-declared external declarations in PCH files
llvm-svn: 69833
2009-04-22 22:18:58 +00:00
Douglas Gregor 2e43ab535b Clean up and de-XFAIL-ify PCH test for external definitions
llvm-svn: 69831
2009-04-22 22:09:39 +00:00
Douglas Gregor d4df8657b4 Support tentative definitions in precompiled headers. This isn't likely
to happen (ever), but at least we'll do the right thing when it does.

llvm-svn: 69829
2009-04-22 22:02:47 +00:00
Chris Lattner 587cbe1ef2 deserialization support for qualified interfaces
llvm-svn: 69782
2009-04-22 06:45:28 +00:00
Chris Lattner 6e054afc9e pch support for protocol qualified id's.
llvm-svn: 69781
2009-04-22 06:40:03 +00:00
Chris Lattner 8f0734972b add three new objc expression types. @selector doesn't work because we have no
way to serialize selectors yet.

llvm-svn: 69780
2009-04-22 06:29:42 +00:00
Chris Lattner 19cea4eeb4 implement serialization support for @encode,
fix a couple of bugs in reader support for ObjCInterfaceDecl,
and add support for reading ObjCInterfaceType.

llvm-svn: 69779
2009-04-22 05:57:30 +00:00
Chris Lattner 01146a5fa9 rename methods.* -> objc_methods.*
llvm-svn: 69778
2009-04-22 05:31:53 +00:00
Douglas Gregor 3ddc876758 Test PCH support for VLAs
llvm-svn: 69758
2009-04-22 00:21:21 +00:00
Douglas Gregor 13d247f7ec Eliminate a FIXME in one of the PCH test cases
llvm-svn: 69757
2009-04-22 00:17:41 +00:00
Douglas Gregor 195e9c5d18 Lazy deserialization of identifiers in PCH files fixed a problem with
name lookup of structures declared within other structures.

llvm-svn: 69744
2009-04-21 22:48:38 +00:00
Douglas Gregor a868bbd392 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".

llvm-svn: 69737
2009-04-21 22:25:48 +00:00
Douglas Gregor beecd58e21 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.

llvm-svn: 69681
2009-04-21 17:11:58 +00:00
Steve Naroff 04f2d14d6a Add pch reader/writer support for ObjCMethodDecl.
Test will be enabled with ObjCInterfaceDecl is added.

llvm-svn: 69594
2009-04-20 15:06:07 +00:00
Chris Lattner a2ac7aab6e make sure to verify that the "non pch" runs worked.
llvm-svn: 69457
2009-04-18 18:45:36 +00:00
Douglas Gregor 652d82a096 Store the type ID for __builtin_va_list in the PCH file, so that the
AST context's __builtin_va_list type will be set when the PCH file is
loaded. This fixes the crash when CodeGen'ing a va_arg expression
pulled in from a PCH file.

llvm-svn: 69421
2009-04-18 05:55:16 +00:00
Douglas Gregor e3dcb2ddd1 FunctionDecl::getBody() is getting an ASTContext argument for use in
lazy PCH deserialization. Propagate that argument wherever it needs to
be. No functionality change, except that I've tightened up a few PCH
tests in preparation.

llvm-svn: 69406
2009-04-18 00:02:19 +00:00
Douglas Gregor ba6e557378 Fix two embarrassing PCH bugs:
1) Accidentally used delete [] on an array of statements that was allocated with ASTContext's allocator
  2) Deserialization of names with multiple declarations (e.g., a struct and a function) used the wrong mangling constant, causing it to view declaration IDs as Decl*s.

403.gcc builds and links properly.

llvm-svn: 69390
2009-04-17 21:46:47 +00:00
Douglas Gregor f994f062fd PCH support for inline assembly statements.
This completes support for all of C (+ extensions). We can (again)
build a PCH file for Carbon.h.

llvm-svn: 69385
2009-04-17 20:57:14 +00:00
Douglas Gregor 5ceb1a2dd9 PCH tests for va_arg expressions. Verified that the blocks test does create a BlockDeclRefExpr
llvm-svn: 69376
2009-04-17 20:06:59 +00:00
Douglas Gregor c95701da6c PCH support for blocks
llvm-svn: 69373
2009-04-17 19:21:43 +00:00
Douglas Gregor af97671954 PCH support for GNU statement expressions
llvm-svn: 69370
2009-04-17 19:05:30 +00:00
Douglas Gregor 779d865b48 PCH support for indirect gotos and address-of-label expressions.
llvm-svn: 69369
2009-04-17 18:58:21 +00:00
Douglas Gregor 6cc68a47b5 PCH support for labels and goto.
llvm-svn: 69364
2009-04-17 18:18:49 +00:00
Douglas Gregor 915b6c663d PCH support for declaration statements, and a test for PredefinedExpr
llvm-svn: 69356
2009-04-17 16:55:36 +00:00
Douglas Gregor f961e5921f PCH support for return statements.
Optimize PCH encoding for switch-case statements slightly, by making
the switch-case numbering local to a particular statement.

llvm-svn: 69355
2009-04-17 16:34:57 +00:00
Douglas Gregor 71517c47e6 PCH support for do-while and for loops
llvm-svn: 69334
2009-04-17 00:29:51 +00:00