summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Completely re-implement (de-)serialization of redeclarationDouglas Gregor2012-01-151-21/+72
| | | | | | | | | | | | | | | | chains, again. The prior implementation was very linked-list oriented, and the list-splicing logic was both fairly convoluted (when loading from multiple modules) and failed to preserve a reasonable ordering for the redeclaration chains. This new implementation uses a simpler strategy, where we store the ordered redeclaration chains in an array-like structure (indexed based on the first declaration), and use that ordering to add individual deserialized declarations to the end of the existing chain. That way, the chain mimics the ordering from its modules, and a bug somewhere is far less likely to result in a broken linked list. llvm-svn: 148222
* Don't seed the ASTWriter's declaration -> ID mapping with the IDs ofDouglas Gregor2012-01-051-4/+11
| | | | | | | each deserialized declaration, since that information is already available in each declaration. llvm-svn: 147619
* When we deserialize a declaration from a module file, allocate extraDouglas Gregor2012-01-051-1/+1
| | | | | | | | | | | | | | | storage for the global declaration ID. Declarations that are parsed (rather than deserialized) are unaffected, so the number of declarations that pay this cost tends to be relatively small (since relatively few declarations are ever deserialized). This replaces a largish DenseMap within the AST reader. It's not strictly a win in terms of memory use---not every declaration was added to that DenseMap in the first place---but it's cleaner to have this information available for every deserialized declaration, so that future clients can rely on it. llvm-svn: 147617
* Store the submodules of a module in source order, as they are storedDouglas Gregor2012-01-041-15/+6
| | | | | | | | in the module map. This provides a bit more predictability for the user, as well as eliminating the need to sort the submodules when serializing them. llvm-svn: 147564
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-1/+0
| | | | | | ObjCProtocolDecl modules forward declarations properly. llvm-svn: 147415
* Don't bother rewriting an Objective-C class or protocol declaration to the ↵Douglas Gregor2012-01-011-2/+0
| | | | | | module file when we've merely added a definition llvm-svn: 147414
* Eliminate ASTMutationListener::UpdatedAttributeList, which is noDouglas Gregor2012-01-011-7/+0
| | | | | | longer needed now that we aren't back-patching ObjCProtocolDecls. llvm-svn: 147413
* Introduce the core infrastructure needed to model redeclaration chainsDouglas Gregor2012-01-011-0/+19
| | | | | | | | | | | | | | | for Objective-C protocols, including: - Using the first declaration as the canonical declaration - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and that we know which declaration is the definition - Serialization support for redeclaration chains and for adding definitions to already-serialized declarations. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCProtocolDecls. llvm-svn: 147410
* Implement support for module requirements, which indicate the languageDouglas Gregor2011-12-311-0/+14
| | | | | | | | | features needed for a particular module to be available. This allows mixed-language modules, where certain headers only work under some language variants (e.g., in C++, std.tuple might only be available in C++11 mode). llvm-svn: 147387
* Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDeclDouglas Gregor2011-12-271-1/+0
| | | | | | | covers both declarations (@class) and definitions (@interface) of an Objective-C class. llvm-svn: 147299
* Serialize the AST reader's mapping from canonical declarations to theDouglas Gregor2011-12-221-1/+21
| | | | | | | | | | | | | | | | set of (previously-canonical) declaration IDs to the module file, so that future AST reader instances that load the module know which declarations are merged. This is important in the fairly tricky case where a declaration of an entity, e.g., @class X; occurs before the import of a module that also declares that entity. We merge the declarations, and record the fact that the declaration of X loaded from the module was merged into the (now canonical) declaration of X that we parsed. llvm-svn: 147181
* When we make a previously-deserialized module definition visible,Douglas Gregor2011-12-201-1/+6
| | | | | | | notify the AST deserialization listener so that the AST writer knows that it can write the macro definition. llvm-svn: 146994
* Detect when mapping a #include/#import over to a submodule ends upDouglas Gregor2011-12-201-1/+0
| | | | | | | | | | | | | hitting a submodule that was never actually created, e.g., because that header wasn't parsed. In such cases, complain (because the module's umbrella headers don't cover everything) and fall back to including the header. Later, we'll add a warning at module-build time to catch all such cases. However, this fallback is important to eliminate assertions in the ASTWriter when this happens. llvm-svn: 146933
* Eliminate the first->last redeclaration map from the AST fileDouglas Gregor2011-12-191-16/+5
| | | | | | | format. It's no longer being used, now that we have a new implementation of redeclaration chains. llvm-svn: 146905
* Begin adding AVX2 intrinsics. Necessitated increasing the number of bits ↵Craig Topper2011-12-191-0/+1
| | | | | | used to store builtinID when serializing identifier table. llvm-svn: 146855
* Completely re-implement (de-)serialization of declarationDouglas Gregor2011-12-171-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | chains. The previous implementation relied heavily on the declaration chain being stored as a (circular) linked list on disk, as it is in memory. However, when deserializing from multiple modules, the different chains could get mixed up, leading to broken declaration chains. The new solution keeps track of the first and last declarations in the chain for each module file. When we load a declaration, we search all of the module files for redeclarations of that declaration, then splice together all of the lists into a coherent whole (along with any redeclarations that were actually parsed). As a drive-by fix, (de-)serialize the redeclaration chains of TypedefNameDecls, which had somehow gotten missed previously. Add a test of this serialization. This new scheme creates a redeclaration table that is fairly large in the PCH file (on the order of 400k for Cocoa.h's 12MB PCH file). The table is mmap'd in and searched via a binary search, but it's still quite large. A future tweak will eliminate entries for declarations that have no redeclarations anywhere, and should drastically reduce the size of this table. llvm-svn: 146841
* Introduce the core infrastructure needed to model a completeDouglas Gregor2011-12-151-3/+20
| | | | | | | | | | | | | | | redeclaration chain for Objective-C classes, including: - Using the first declaration as the canonical declaration. - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and the definition knows that it is the definition. - Serialization support for when a definition gets added to a declaration that comes from an AST file. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCInterfaceDecls. llvm-svn: 146667
* Tweak submodule ID handling in the AST writerDouglas Gregor2011-12-121-5/+9
| | | | llvm-svn: 146445
* Implement umbrella directories for modules, which are similar toDouglas Gregor2011-12-081-3/+13
| | | | | | | | | | | | | | | umbrella headers in the sense that all of the headers within that directory (and eventually its subdirectories) are considered to be part of the module with that umbrella directory. However, unlike umbrella headers, which are expected to include all of the headers within their subdirectories, Clang will automatically include all of the headers it finds in the named subdirectory. The intent here is to allow a module map to trivially turn a subdirectory into a module, where the module's structure can mimic the directory structure. llvm-svn: 146165
* Within the module representation, generalize the notion of an umbrellaDouglas Gregor2011-12-081-2/+2
| | | | | | | | | | header to also support umbrella directories. The umbrella directory for an umbrella header is the directory in which the umbrella header resides. No functionality change yet, but it's coming. llvm-svn: 146158
* Implement inferred submodules support, which (when requested)Douglas Gregor2011-12-061-13/+26
| | | | | | | implicitly generates submodules corresponding to the headers that fall within a module. llvm-svn: 145887
* Parse inferred submodules in module maps, track their contents inDouglas Gregor2011-12-051-0/+6
| | | | | | | Module, and (de-)serialize this information. Semantics of inferred submodules to follow. llvm-svn: 145864
* Implement support for wildcard exports in modules, allowing a moduleDouglas Gregor2011-12-051-1/+2
| | | | | | | | to re-export anything that it imports. This opt-in feature makes a module behave more like a header, because it can be used to re-export the transitive closure of a (sub)module's dependencies. llvm-svn: 145811
* Actually add a useful bit to the comment pre-FIXMEDouglas Gregor2011-12-051-1/+1
| | | | llvm-svn: 145809
* When writing a module file, keep track of the set of (sub)modules thatDouglas Gregor2011-12-051-16/+32
| | | | | | | it imports, establishing dependencies at the (sub)module granularity. This is not a user-visible change (yet). llvm-svn: 145808
* Module files representing actual modules don't need to know the set of ↵Douglas Gregor2011-12-031-19/+20
| | | | | | modules they import, since that information isn't actually used. Drop it from the AST file llvm-svn: 145738
* Implement support for precompiled headers, preambles, and serializedDouglas Gregor2011-12-031-0/+21
| | | | | | | | "main" files that import modules. When loading any of these kinds of AST files, we make the modules that were imported visible into the translation unit that loaded the PCH file or preamble. llvm-svn: 145737
* Implement (de-)serialization of the set of exported modules in aDouglas Gregor2011-12-021-1/+14
| | | | | | module map. llvm-svn: 145695
* Notify the AST writer (via ASTDeserializationListener) when aDouglas Gregor2011-12-021-0/+5
| | | | | | | (sub)module is read from an AST file. This makes sure that the AST writer knows how to map all modules to their global IDs. llvm-svn: 145685
* Implement name hiding for macro definitions within modules, such thatDouglas Gregor2011-12-021-3/+6
| | | | | | | | only the macro definitions from visible (sub)modules will actually be visible. This provides the same behavior for macros that r145640 provided for declarations. llvm-svn: 145683
* Implement name hiding for declarations deserialized from a non-visibleDouglas Gregor2011-12-011-0/+4
| | | | | | module. When that module becomes visible, so do those declarations. llvm-svn: 145640
* Infer the submodule ID for a given declaration based on the locationDouglas Gregor2011-12-011-4/+40
| | | | | | | of that declaration, and encode the submodule ID in each declaration stored in an AST file. llvm-svn: 145555
* Switch the ID numbers used for submodule IDs in the AST reader over toDouglas Gregor2011-12-011-4/+27
| | | | | | | | a standard global/local scheme, so that submodule definitions will eventually be able to refer to submodules in other top-level modules. We'll need this functionality soonish. llvm-svn: 145549
* Promote ModuleMap::Module to a namespace-scope class in the BasicDouglas Gregor2011-11-301-6/+6
| | | | | | | | | library, since modules cut across all of the libraries. Rename serialization::Module to serialization::ModuleFile to side-step the annoying naming conflict. Prune a bunch of ModuleMap.h includes that are no longer needed (most files only needed the Module type). llvm-svn: 145538
* Implement (de-)serialization of the description of a module and itsDouglas Gregor2011-11-301-1/+84
| | | | | | | | | submodules. This information will eventually be used for name hiding when dealing with submodules. For now, we only use it to ensure that the module "key" returned when loading a module will always be a module (rather than occasionally being a FileEntry). llvm-svn: 145497
* When writing a module file, pass the module through to the ASTDouglas Gregor2011-11-301-5/+6
| | | | | | writer. No functionality change. llvm-svn: 145479
* Implement (de-)serialization of the buffer contents for an overriddenDouglas Gregor2011-11-161-4/+16
| | | | | | | | | | file in the source manager. This allows us to properly create and use modules described by module map files without umbrella headers (or with incompletely umbrella headers). More generally, we can actually build a PCH file that makes use of file -> buffer remappings, which could be useful in libclang in the future. llvm-svn: 144830
* Add a -cc1-level option -fmodule-name=<name>, which will be used whenDouglas Gregor2011-11-151-0/+3
| | | | | | building modules. llvm-svn: 144680
* [PCH] Do not crash if a class extension in a chained PCH ↵Argyrios Kyrtzidis2011-11-141-0/+14
| | | | | | introduces/redeclares a property. llvm-svn: 144520
* [PCH] In ASTWriter::WriteChainedObjCCategories use getDeclID since the declsArgyrios Kyrtzidis2011-11-141-6/+5
| | | | | | should have been already emitted. llvm-svn: 144519
* [PCH] When chaining a PCH and serializing HeaderSearch, make sure the ↵Argyrios Kyrtzidis2011-11-131-4/+6
| | | | | | | | | HeaderFileInfos from the primary PCH is deserialized, otherwise we lose info that headers were already #imported/#included. llvm-svn: 144510
* Fix the signature of the getcontext builtin. Patch by Dimitry Andric.Rafael Espindola2011-11-131-0/+1
| | | | llvm-svn: 144505
* Add a method in ASTMutationListener for the last use of Decl's ↵Argyrios Kyrtzidis2011-11-121-8/+8
| | | | | | | | [is/set]ChangedSinceDeserialization and remove them. llvm-svn: 144466
* [PCH] When completing an objc forward reference, do not serialize the chain ↵Argyrios Kyrtzidis2011-11-121-16/+15
| | | | | | | | | | | | | | | of its categories because it is going to be rewritten (and the chain will be serialized again), otherwise we may form a cycle in its categories list when deserializing. Also introduce ASTMutationListener::CompletedObjCForwardRef to notify that a forward reference was completed; using Decl's isChangedSinceDeserialization/setChangedSinceDeserialization is bug inducing and kinda gross, we should phase it out. Fixes infinite loop in rdar://10418538. llvm-svn: 144465
* Rework the AST for the initializer of a delegating constructor, soDouglas Gregor2011-11-011-2/+2
| | | | | | | | | that it retains source location information for the type. Aside from general goodness (being able to walk the types described in that information), we now have a proper representation for dependent delegating constructors. Fixes PR10457 (for real). llvm-svn: 143410
* [PCH] Now that we store the location of a decl outside its recordArgyrios Kyrtzidis2011-10-311-3/+4
| | | | | | make sure that we keep track of locations of replaced decls as well. llvm-svn: 143341
* [PCH] Sort the file decls by file offset not raw source location.Argyrios Kyrtzidis2011-10-281-4/+5
| | | | | | | Currently sorting by raw source location does work as intended but who knows what may change in the future.. llvm-svn: 143256
* [PCH] In ASTWriter::associateDeclWithFile don't bother finding the file locArgyrios Kyrtzidis2011-10-281-4/+7
| | | | | | if we are not interested in the decl. llvm-svn: 143255
* [PCH] Keep track of file-level declarations that are contained by files.Argyrios Kyrtzidis2011-10-281-43/+127
| | | | | | | | | | | | Introduce a FILE_SORTED_DECLS [de]serialization record that contains a file sorted array of file-level DeclIDs in a PCH/Module. The rationale is to allow "targeted" deserialization of decls inside a range of a source file. Cocoa PCH increased by 0.8% Difference of creation time for Cocoa PCH is below the noise level. llvm-svn: 143238
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-18/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AST file more lazy, so that we don't eagerly load that information for all known identifiers each time a new AST file is loaded. The eager reloading made some sense in the context of precompiled headers, since very few identifiers were defined before PCH load time. With modules, however, a huge amount of code can get parsed before we see an @import, so laziness becomes important here. The approach taken to make this information lazy is fairly simple: when we load a new AST file, we mark all of the existing identifiers as being out-of-date. Whenever we want to access information that may come from an AST (e.g., whether the identifier has a macro definition, or what top-level declarations have that name), we check the out-of-date bit and, if it's set, ask the AST reader to update the IdentifierInfo from the AST files. The update is a merge, and we now take care to merge declarations before/after imports with declarations from multiple imports. The results of this optimization are fairly dramatic. On a small application that brings in 14 non-trivial modules, this takes modules from being > 3x slower than a "perfect" PCH file down to 30% slower for a full rebuild. A partial rebuild (where the PCH file or modules can be re-used) is down to 7% slower. Making the PCH file just a little imperfect (e.g., adding two smallish modules used by a bunch of .m files that aren't in the PCH file) tips the scales in favor of the modules approach, with 24% faster partial rebuilds. This is just a first step; the lazy scheme could possibly be improved by adding versioning, so we don't search into modules we already searched. Moreover, we'll need similar lazy schemes for all of the other lookup data structures, such as DeclContexts. llvm-svn: 143100
OpenPOWER on IntegriCloud