Commit Graph

196 Commits

Author SHA1 Message Date
Douglas Gregor 44e5c1f16c Serialize the "inline" bit for namespaces. Fixes <rdar://problem/8515069>.
llvm-svn: 115667
2010-10-05 20:41:58 +00:00
Douglas Gregor 9b3932c0bc Fix a marvelous chained AST writing bug, where we end up with the
following amusing sequence:
  - AST writing schedules writing a type X* that it had never seen
  before
  - AST writing starts writing another declaration, ends up
  deserializing X* from a prior AST file. Now we have two type IDs for
  the same type!
  - AST writer tries to write X*. It only has the lower-numbered ID
  from the the prior AST file, so references to the higher-numbered ID
  that was scheduled for writing go off into lalaland.

To fix this, keep the higher-numbered ID so we end up writing the type
twice. Since this issue occurs so rarely, and type records are
generally rather small, I deemed this better than the alternative: to
keep a separate mapping from the higher-numbered IDs to the
lower-numbered IDs, which we would end up having to check whenever we
want to deserialize any type.

Fixes <rdar://problem/8511624>, I think.

llvm-svn: 115647
2010-10-05 18:37:06 +00:00
Douglas Gregor 93269380e7 Register the __builtin_va_list_type node when we parse it, rather than
waiting until we think we need it: we didn't catch all of the places
where we actually needed it, and we probably wouldn't ever. Fixes a
C++ PCH crasher.

llvm-svn: 115617
2010-10-05 14:55:45 +00:00
Douglas Gregor 3022037787 When we insert a category (or class extension) into an interface, mark
the interface as having changed since it was originally
serialized. This ensures that we see class extensions/categories in
chained PCH files.

llvm-svn: 115421
2010-10-02 21:06:43 +00:00
Douglas Gregor 9109629e55 Implement chained PCH support for the macro definitions stored within
the "detailed" preprocessing record.

llvm-svn: 115417
2010-10-02 19:29:26 +00:00
Douglas Gregor eb114da506 When an identifier that has a macro definition in the original PCH
file is somehow changed in a chained PCH file, make sure that we write
out the macro definition. Fixes part of <rdar://problem/8499034>.

llvm-svn: 115259
2010-10-01 01:03:07 +00:00
Argyrios Kyrtzidis 1664634cbb Add test case I forgot for r115159 (support implicit includes along with PCH).
llvm-svn: 115247
2010-10-01 00:00:18 +00:00
Argyrios Kyrtzidis f24d569f9e Fix C++ PCH issue.
The canonical FunctionTemplateDecl contains the specializations but we cannot use getCanonicalDecl on Template because it may still be initializing.
Write and read it from PCH.
Fixes http://llvm.org/PR8134

llvm-svn: 113744
2010-09-13 11:45:48 +00:00
Argyrios Kyrtzidis d05f3e3730 Fix a C++ PCH problem which was exposed by r113019. CXXBaseOrMemberInitializer's IsWritten and source order is not set.
llvm-svn: 113161
2010-09-06 19:04:27 +00:00
Sebastian Redl 401b39a736 AST writer support for having specializations of templates from earlier in the chain. This ought to finish C++ chained PCH support.
llvm-svn: 111986
2010-08-24 22:50:24 +00:00
Sebastian Redl 9617e7e8c7 Add testcase for C++ chained PCH and fix the bugs it uncovered in name lookup.
llvm-svn: 111882
2010-08-24 00:50:16 +00:00
Argyrios Kyrtzidis d32ee89ea2 Fix an issue with writing to PCH another included PCH, introduced by the "using an AST on-disk hash table for name lookup" commit.
When including a PCH and later re-emitting to another PCH, the name lookup tables of DeclContexts
may be incomplete, since we now lazily deserialize the visible decls of a particular name.
Fix the issue by iterating over the un-deserialized visible decls and completing the lookup tables
of DeclContexts before writing them out.

llvm-svn: 111698
2010-08-20 23:35:55 +00:00
Sebastian Redl e7c1fe6ab7 Instead of modifying the ObjC AST to not modify existing declarations, teach chained PCH to overwrite declarations from earlier PCH files in dependent ones. Tell Sema to note when it changes AST nodes so that they have to be reserialized. Finally, the ObjCProtocolDecls created in forward decls, like the ObjCInterfaceDecls in @class forward decls, are not lexically part of the decl context; only the definition is.
llvm-svn: 110989
2010-08-13 00:28:03 +00:00
Argyrios Kyrtzidis 3084a61e98 -Make TokenID of IdentifierInfo read-only, remove setTokenID().
-There are 2 instances that change the TokenID for GNU libstdc++ 4.2 compatibility.
  To handler those cases introduce a RevertedTokenID bitfield, RevertTokenIDToIdentifier() and hasRevertedTokenIDToIdentifier() methods.
  Store the bitfield in PCH.

llvm-svn: 110868
2010-08-11 22:55:12 +00:00
Daniel Dunbar 00012c869f tests: Add a missing -Xclang.
llvm-svn: 110776
2010-08-11 02:32:03 +00:00
Daniel Dunbar 4c60857426 tests: Avoid unnecessary redirection.
llvm-svn: 110709
2010-08-10 19:33:56 +00:00
Daniel Dunbar 656f3bd3e2 tests: Tests which include system headers must use the driver, not -cc1.
llvm-svn: 110708
2010-08-10 19:32:44 +00:00
Argyrios Kyrtzidis f355e0cacd Remove a FIXME.
llvm-svn: 110571
2010-08-09 10:59:17 +00:00
Argyrios Kyrtzidis a8607779a4 Complete PCH support for ObjCPropertyImplDecl.
llvm-svn: 110570
2010-08-09 10:54:37 +00:00
Argyrios Kyrtzidis 13257c5527 Support ObjC implementation decls for PCH.
Strictly speaking, implementations don't go in headers but there's no law against it.

llvm-svn: 110567
2010-08-09 10:54:20 +00:00
Argyrios Kyrtzidis 7f76d11dcc Store the pending implicit instantiations in the PCH and perform them at the end of the translation unit that
included the PCH, as God intended.

llvm-svn: 110324
2010-08-05 09:48:16 +00:00
Argyrios Kyrtzidis ee1afa3082 Support #pragma weak for PCH.
llvm-svn: 110323
2010-08-05 09:48:08 +00:00
Argyrios Kyrtzidis 4ba81b2ee4 Make sure C++ variable definitions are actually passed to the consumer when loaded from PCH.
llvm-svn: 110322
2010-08-05 09:47:59 +00:00
Sebastian Redl 51c79d8740 Activate selectors in chained PCH. Chained PCH now works for Objective-C.
llvm-svn: 110262
2010-08-04 22:21:29 +00:00
Argyrios Kyrtzidis 839bbacfb2 Apart from storing/retrieving the previous redeclaration from PCH, also store/retrieve the most recent
redeclaration. That way we are sure that the full redeclarations chain is loaded.

When using chained PCHs, first declarations point to the most recent redeclarations in the same PCH.
To address this use a REDECLS_UPDATE_LATEST record block to keep track of which first declarations need
to point to a most recent redeclaration in another PCH.

llvm-svn: 110125
2010-08-03 17:30:10 +00:00
Sebastian Redl 78f5177d37 Query only the latest version of an identifier in the PCH chain. Make sure this version holds the entire declaration chain. This is a much saner solution than trying to merge the info from all elements, and makes redeclarations work properly. Expand the declarations test case to cover more compliated cases.
llvm-svn: 110052
2010-08-02 18:30:12 +00:00
Argyrios Kyrtzidis 2d68810caf Read/write in PCH Sema's StdNamespace and StdBadAlloc and use a LazyDeclPtr for them that will deserialize them when needed.
llvm-svn: 110031
2010-08-02 07:14:54 +00:00
Sebastian Redl 671eee9e68 Correctly deal with using names for both functions and structs in chained PCH.
llvm-svn: 109871
2010-07-30 17:25:10 +00:00
Sebastian Redl 07a89a83d4 Make macro weirdness in chained PCH work. This required changing the way PCHReader and PCHWriter are initialized to correctly pick up all initializer. On the upside, this means that there is far less repetition in the dependent PCH now.
llvm-svn: 109823
2010-07-30 00:29:29 +00:00
Argyrios Kyrtzidis 6e03a7476f Weak references and variables that are not definitions are not required for early codegen/deserialization.
llvm-svn: 109796
2010-07-29 20:07:52 +00:00
Argyrios Kyrtzidis d67d4cc82f Implement PCH support for offsetof(base-specifier).
llvm-svn: 109785
2010-07-29 18:16:10 +00:00
Argyrios Kyrtzidis c81af03fb3 Merge PCHWriterDecl.cpp's isRequiredDecl and CodeGenModule::MayDeferGeneration into a new function,
DeclIsRequiredFunctionOrFileScopedVar.

This is essentially a CodeGen predicate that is also needed by the PCH mechanism to determine whether a decl
needs to be deserialized during PCH loading for codegen purposes.
Since this logic is shared by CodeGen and the PCH mechanism, move it to the ASTContext,
thus CodeGenModule's GetLinkageForFunction/GetLinkageForVariable and the GVALinkage enum is moved out of CodeGen.

This fixes current (and avoids future) codegen-from-PCH bugs.

llvm-svn: 109784
2010-07-29 18:15:58 +00:00
Sebastian Redl 04f5c31e98 Support extended vector types in chained PCH.
llvm-svn: 109675
2010-07-28 21:38:49 +00:00
Sebastian Redl 887d6b08fd Add a test case for tentative definitions in chained PCH. Fix a bug that completely messed up source locations and thus caused a crash whenever a diagnostic was emitted in chained PCH files.
llvm-svn: 109660
2010-07-28 21:07:02 +00:00
Ted Kremenek 038abf7db0 Add PTH test case for <rdar://problem/8227989>.
llvm-svn: 109555
2010-07-27 23:06:03 +00:00
Sebastian Redl 9891212476 Record macros in dependent PCHs. Also add various info tables to dependent PCHs; tests for this to follow.
llvm-svn: 109554
2010-07-27 23:01:28 +00:00
Argyrios Kyrtzidis c0279a9826 Revert r109546, it broke linux build.
llvm-svn: 109550
2010-07-27 22:37:14 +00:00
Argyrios Kyrtzidis 4fac280618 Merge PCHWriterDecl.cpp's isRequiredDecl and CodeGenModule::MayDeferGeneration into a new function,
DeclIsRequiredFunctionOrFileScopedVar.

This function is part of the public CodeGen interface since it's essentially a CodeGen predicate that is also
needed by the PCH mechanism to determine whether a decl needs to be deserialized during PCH loading for codegen purposes.
This fixes current (and avoids future) codegen-from-PCH bugs.

llvm-svn: 109546
2010-07-27 22:01:17 +00:00
Sebastian Redl 4b1f490860 Update the list of lexical decls in the TU for chained PCHs. This makes -ast-print show the decls from the dependent PCH.
llvm-svn: 109524
2010-07-27 18:24:41 +00:00
Argyrios Kyrtzidis 76314d1ea8 Always deserialize from PCH file scoped variables with non trivial constructor/destructor.
Fixes http://llvm.org/PR7692

llvm-svn: 109501
2010-07-27 12:56:10 +00:00
Douglas Gregor 3f4bea0646 Introduce basic support for loading a precompiled preamble while
reparsing an ASTUnit. When saving a preamble, create a buffer larger
than the actual file we're working with but fill everything from the
end of the preamble to the end of the file with spaces (so the lexer
will quickly skip them). When we load the file, create a buffer of the
same size, filling it with the file and then spaces. Then, instruct
the lexer to start lexing after the preamble, therefore continuing the
parse from the spot where the preamble left off.

It's now possible to perform a simple preamble build + parse (+
reparse) with ASTUnit. However, one has to disable a bunch of checking
in the PCH reader to do so. That part isn't committed; it will likely
be handled with some other kind of flag (e.g., -fno-validate-pch).

As part of this, fix some issues with null termination of the memory
buffers created for the preamble; we were trying to explicitly
NULL-terminate them, even though they were also getting implicitly
NULL terminated, leading to excess warnings about NULL characters in
source files.

llvm-svn: 109445
2010-07-26 21:36:20 +00:00
Sebastian Redl ff4a2951d9 Make declarations in the dependent PCH visible, for C at least.
llvm-svn: 109292
2010-07-23 23:49:55 +00:00
Fariborz Jahanian b59625ecea Test for selector-warning PCH patch.
radar 6507158.

llvm-svn: 109261
2010-07-23 20:32:57 +00:00
Sebastian Redl c67764eb4b Thread bitstream cursors all the way through the AST reading stuff. This way, reading a trivial 2-element chained file actually works.
llvm-svn: 109191
2010-07-22 22:43:28 +00:00
Argyrios Kyrtzidis 2d8891cd5d Read/write C++0x static_assert for PCH.
llvm-svn: 109123
2010-07-22 17:28:12 +00:00
Argyrios Kyrtzidis 47cd7a91f4 Support C++ try/catch statements for PCH.
llvm-svn: 109112
2010-07-22 16:03:56 +00:00
Argyrios Kyrtzidis 47470f2f3f Hide the specializations folding sets of ClassTemplateDecl as an implementation detail (InsertPos
leaks though) and add methods to its interface for adding/finding specializations.

Simplifies its users a bit and we no longer need to replace specializations in the folding set with
their redeclarations. We just return the most recent redeclarations.

As a bonus, it fixes http://llvm.org/PR7670.

llvm-svn: 108832
2010-07-20 13:59:28 +00:00
Argyrios Kyrtzidis 3816ed4d58 Fix http://llvm.org/PR7660
A ParmVarDecl instantiated from a FunctionProtoType may have Record as DeclContext,
in which case isStaticDataMember() will erroneously return true.

llvm-svn: 108692
2010-07-19 10:14:41 +00:00
Sebastian Redl 75fbb3b5e5 Make PCHReader cope with PCH files containing more than one predefines buffer.
llvm-svn: 108340
2010-07-14 17:49:11 +00:00
Argyrios Kyrtzidis b5fcdc21c2 Fix a regression of a previous commit of mine (rdar://8158953).
Some of the invariant checks for creating Record/Enum types don't hold true during PCH reading.
Introduce more suitable ASTContext::getRecordType() and getEnumType().

llvm-svn: 107598
2010-07-04 21:44:47 +00:00