summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Introduce module attributes into the module map grammar, along with aDouglas Gregor2012-01-271-3/+5
| | | | | | | | | | | | | single attribute ("system") that allows us to mark a module as being a "system" module. Each of the headers that makes up a system module is considered to be a system header, so that we (for example) suppress warnings there. If a module is being inferred for a framework, and that framework directory is within a system frameworks directory, infer it as a system framework. llvm-svn: 149143
* Reimplement (de-)serialization of Objective-C categories to eliminateDouglas Gregor2012-01-271-22/+28
| | | | | | | | | | | | | | the direct serialization of the linked-list structure. Instead, use a scheme similar to how we handle redeclarations, with redeclaration lists on the side. This addresses several issues: - In cases involving mixing and matching of many categories across many modules, the linked-list structure would not be consistent across different modules, and categories would get lost. - If a module is loaded after the class definition and its other categories have already been loaded, we wouldn't see any categories in the newly-loaded module. llvm-svn: 149112
* Introduce a generation number for selector lookups in the globalDouglas Gregor2012-01-251-4/+16
| | | | | | | method pool, so that we don't perform the same lookups into the same PCH/module file repeatedly. llvm-svn: 148895
* Rework the external Sema source's ReadMethodPool() so that it doesn'tDouglas Gregor2012-01-251-35/+27
| | | | | | | return pre-built lists. Instead, it feeds the methods it deserializes to Sema so that Sema can unique them, which keeps the chains shorter. llvm-svn: 148889
* Only mark an IdentifierInfo as having changed since deserializationDouglas Gregor2012-01-241-5/+12
| | | | | | | | when it actually has changed (and not, e.g., when we've simply attached a deserialized macro definition). Good for ~1.5% reduction in module file size, mostly in the identifier table. llvm-svn: 148808
* Optimize unqualified/global name lookup in modules by introducing aDouglas Gregor2012-01-181-11/+38
| | | | | | | | | | generational scheme for identifiers that avoids searching the hash tables of a given module more than once for a given identifier. Previously, loading any new module invalidated all of the previous lookup results for all identifiers, causing us to perform the lookups repeatedly. llvm-svn: 148412
* Rework the way in which we (de-)serialize the declarationsDouglas Gregor2012-01-171-8/+22
| | | | | | | | | | | | | | | | corresponding to TagType and ObjCInterfaceType. Previously, we would serialize the definition (if available) or the canonical declaration (if no definition was available). However, this can end up forcing the deserialization of the definition even through we might not want to yet. Instead, always serialize the canonical declaration reference in the TagType/ObjCInterfaceType entry, and as part of loading a pending definition, update the "decl" pointer within the type node to point at the definition. This is more robust in hard-to-isolate cases where the *Type gets built and filled in before we see the definition. llvm-svn: 148323
* Delay the creation of the built-in Objective-C class 'Protocol' byDouglas Gregor2012-01-171-6/+4
| | | | | | | moving it from a "special type" to a predefined declaration, as we do for id, Class, and SEL. llvm-svn: 148313
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-16/+5
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Completely re-implement (de-)serialization of redeclarationDouglas Gregor2012-01-151-13/+10
| | | | | | | | | | | | | | | | 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
* Reimplement RedeclarableTemplateDecl in terms ofDouglas Gregor2012-01-141-8/+18
| | | | | | | | | | | Redeclarable<RedeclarableTemplateDecl>, eliminating a bunch of redeclaration-chain logic both in RedeclarableTemplateDecl and especially in its (de-)serialization. As part of this, eliminate the RedeclarableTemplate<> class template, which was an abstraction that didn't actually save anything. llvm-svn: 148181
* Implement redeclaration merging for namespaces defined in distinctDouglas Gregor2012-01-091-7/+35
| | | | | | | | | modules. Teach name lookup into namespaces to search in each of the merged DeclContexts as well as the (now-primary) DeclContext. This supports the common case where two different modules put something into the same namespace. llvm-svn: 147778
* Introduce a "Hidden" bit into Decl, to track whether that declarationDouglas Gregor2012-01-061-1/+1
| | | | | | | | | | is hidden from name lookup. The previous hack of tweaking the ModulePrivate bit when loading a declaration from a hidden submodule was brittle. Note that we now have 34 bits in Decl. I'll fix that next. llvm-svn: 147658
* Teach DeclContext deserialization to pay attention to endianness, fromDouglas Gregor2012-01-061-1/+1
| | | | | | David Fang and Takumi Nakamura. Fixes many PCH failures on PowerPC. llvm-svn: 147657
* When loading an AST file, set SourceManager::MainFileID to the main file of ↵Argyrios Kyrtzidis2012-01-051-7/+10
| | | | | | | | the AST file, as suggested by Tom Honermann. llvm-svn: 147612
* Store the submodules of a module in source order, as they are storedDouglas Gregor2012-01-041-4/+4
| | | | | | | | 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
* Introduce the core infrastructure needed to model redeclaration chainsDouglas Gregor2012-01-011-7/+17
| | | | | | | | | | | | | | | 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/+18
| | | | | | | | | 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
* Serialize the AST reader's mapping from canonical declarations to theDouglas Gregor2011-12-221-0/+10
| | | | | | | | | | | | | | | | 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 deserializing an Objective-C class, check whether we have anotherDouglas Gregor2011-12-221-1/+1
| | | | | | | | | | | | | | | | declaration of that same class that either came from some other module or occurred in the translation unit loading the module. In this case, we need to merge the two redeclaration chains immediately so that all such declarations have the same canonical declaration in the resulting AST (even though they don't in the module files we've imported). Focusing on Objective-C classes until I'm happy with the design, then I'll both (1) extend this notion to other kinds of declarations, and (2) optimize away this extra checking when we're not dealing with modules. For now, doing this checking for PCH files/preambles gives us better testing coverage. llvm-svn: 147123
* When we make a previously-deserialized module definition visible,Douglas Gregor2011-12-201-2/+8
| | | | | | | notify the AST deserialization listener so that the AST writer knows that it can write the macro definition. llvm-svn: 146994
* Fix off-by-one error in an assert condition. No functionality change, but betterRichard Smith2011-12-201-1/+1
| | | | | | error detection. llvm-svn: 146962
* Detect when mapping a #include/#import over to a submodule ends upDouglas Gregor2011-12-201-0/+1
| | | | | | | | | | | | | 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-10/+0
| | | | | | | format. It's no longer being used, now that we have a new implementation of redeclaration chains. llvm-svn: 146905
* Remove ASTReader's PendingForwardRefs, which is now handled by theDouglas Gregor2011-12-191-3/+0
| | | | | | (more general) fix-up of definition data pointers. llvm-svn: 146903
* Once we have fully deserialized a redeclaration chain for somethingDouglas Gregor2011-12-191-0/+23
| | | | | | | | | | | with a definition pointer (e.g., C++ and Objective-C classes), zip through the redeclaration chain to make sure that all of the declarations point to the definition data. As part of this, realized again why the first redeclaration of an entity in a file is important, and brought back that idea. llvm-svn: 146886
* The submodule offset map can introduce "empty" remapping entries forDouglas Gregor2011-12-191-11/+13
| | | | | | | | | | imported modules that don't introduce any new entities of a particular kind. Allow these entries to be replaced with entries for another loaded module. In the included test case, selectors exhibit this behavior. llvm-svn: 146870
* Begin adding AVX2 intrinsics. Necessitated increasing the number of bits ↵Craig Topper2011-12-191-2/+2
| | | | | | used to store builtinID when serializing identifier table. llvm-svn: 146855
* Completely re-implement (de-)serialization of declarationDouglas Gregor2011-12-171-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [PCH] Don't deserialize bodies of interesting decls while iteratingArgyrios Kyrtzidis2011-12-171-41/+49
| | | | | | | | | over them because more interesting decls can be added during body deserialization. Should fix msvc build tests. llvm-svn: 146824
* [PCH] In ASTReader::FinishedDeserializing fully load the interesting decls,Argyrios Kyrtzidis2011-12-171-0/+9
| | | | | | | | | including deserializing their bodies, so that any other declarations that get referenced in the body will be fully deserialized by the time we pass them to the consumer. Could not reduce to a test case unfortunately. rdar://10587158. llvm-svn: 146817
* Make sure we're always setting the previous declaration of an ObjCInterfaceDeclDouglas Gregor2011-12-161-1/+1
| | | | llvm-svn: 146763
* Use llvm::sys::fs::equivalent rather than comparing inodes, becauseDouglas Gregor2011-12-091-6/+5
| | | | | | comparing inodes doesn't actually work on Windows. llvm-svn: 146260
* Move a free function from the Frontend library into the Lex library asChandler Carruth2011-12-091-2/+2
| | | | | | | | part of HeaderSearch. This function just normalizes filenames for use inside of a synthetic include directive, but it is used in both the Frontend and Serialization libraries so it needs a common home. llvm-svn: 146227
* Separate the serialization library's diagnostics from the frontend'sChandler Carruth2011-12-091-1/+1
| | | | | | | diagnostics. Conflating them was highly confusing and makes it harder to establish a firm layering separation between these two libraries. llvm-svn: 146207
* Implement umbrella directories for modules, which are similar toDouglas Gregor2011-12-081-1/+23
| | | | | | | | | | | | | | | 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
* Remove unused-but-set variable.Benjamin Kramer2011-12-071-2/+0
| | | | llvm-svn: 146034
* Implement inferred submodules support, which (when requested)Douglas Gregor2011-12-061-16/+15
| | | | | | | 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-1/+12
| | | | | | | 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-10/+59
| | | | | | | | 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
* When writing a module file, keep track of the set of (sub)modules thatDouglas Gregor2011-12-051-14/+37
| | | | | | | it imports, establishing dependencies at the (sub)module granularity. This is not a user-visible change (yet). llvm-svn: 145808
* 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
* Only perform checking of the predefines buffer when loading aDouglas Gregor2011-12-021-2/+2
| | | | | | | | | | | | | precompiled header. Previously, we were trying to gather predefines buffers from all kinds of AST files (which doesn't make sense) and were performing some validation when AST files were loaded as main files. With these tweaks, using PCH files that import modules no longer fails immediately (due to mismatched predefines buffers). However, module visibility is lost, so this feature does not yet work. llvm-svn: 145709
* When making a module visible, also make any of its exported modulesDouglas Gregor2011-12-021-0/+12
| | | | | | | visible, allowing one to create modules that import (and then re-export) other modules. llvm-svn: 145696
* Implement (de-)serialization of the set of exported modules in aDouglas Gregor2011-12-021-0/+37
| | | | | | module map. llvm-svn: 145695
* Notify the AST writer (via ASTDeserializationListener) when aDouglas Gregor2011-12-021-0/+6
| | | | | | | (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-8/+34
| | | | | | | | 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-1/+20
| | | | | | module. When that module becomes visible, so do those declarations. llvm-svn: 145640
* Introduce the notion of name visibility into modules. For a givenDouglas Gregor2011-12-011-0/+32
| | | | | | | | | | | | | | (sub)module, all of the names may be hidden, just the macro names may be exposed (for example, after the preprocessor has seen the import of the module but the parser has not), or all of the names may be exposed. Importing a module makes its names, and the names in any of its non-explicit submodules, visible to name lookup (transitively). This commit only introduces the notion of name visible and marks modules and submodules as visible when they are imported. The actual name-hiding logic in the AST reader will follow (along with test cases). llvm-svn: 145586
OpenPOWER on IntegriCloud