summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
* Remove a bogus assertion from the AST reader, which assumed thatDouglas Gregor2011-08-251-12/+6
| | | | | | | | | | redeclarations of a particular entity would occur in source order. Friend declarations that occur within class templates (or member classes thereof) do not follow this, nor would modules. Big thanks to Erik Verbruggen for reducing this problem from the Very Large Qt preamble testcase he found. llvm-svn: 138557
* Use the module manager's search facility to look for methods with aDouglas Gregor2011-08-251-47/+88
| | | | | | | | | given selector, rather than walking the chain backwards. Teach its visitor how to merge multiple result sets into a single result set, combining the results of selector lookup in several different modules into a single result set. llvm-svn: 138556
* Don't force the complete deserialization of the visible-declarationsDouglas Gregor2011-08-243-46/+1
| | | | | | | | | | table when serializing an AST file. This was a holdover from the days before chained PCH, and is a complete waste of time and storage now. It's a good thing it's useless, because I have no idea how I would have implemented MaterializeVisibleDecls efficiently in the presence of modules. llvm-svn: 138496
* Introduce a depth-first search of modules into the module manager,Douglas Gregor2011-08-241-24/+97
| | | | | | | | | | | | which supports both pre-order and post-order traversal via a visitor mechanism. Use this depth-first search with a post-order traversal to give predictable ordering semantics when walking all of the lexical declarations in the translation unit. Eventually, module imports will occur in the source code rather than at the beginning, and we'll have to revisit this walk. llvm-svn: 138490
* In the AST reader, switch name lookup within a DeclContect over to theDouglas Gregor2011-08-242-119/+126
| | | | | | | | | | | | | | | | | | module DAG-based lookup scheme. This required some reshuffling, so that each module stores its own mapping from DeclContexts to their lexical and visible sets for those DeclContexts (rather than one big "chain"). Overall, this allows simple qualified name lookup into the translation unit to gather results from multiple modules, with the lookup results in module B shadowing the lookup results in module A when B imports A. Walking all of the lexical declarations in a module DAG is still a mess; we'll end up walking the loaded module list backwards, which works fine for chained PCH but doesn't make sense in a DAG. I'll tackle this issue as a separate commit. llvm-svn: 138463
* Boost the efficiency of SourceManager::getMacroArgExpandedLocation.Argyrios Kyrtzidis2011-08-212-2/+7
| | | | | | | | | | | | | | | | | | Currently getMacroArgExpandedLocation is very inefficient and for the case of a location pointing at the main file it will end up checking almost all of the SLocEntries. Make it faster: -Use a map of macro argument chunks to their expanded source location. The map is for a single source file, it's stored in the file's ContentCache and lazily computed, like the source lines cache. -In SLocEntry's FileInfo add an 'unsigned NumCreatedFIDs' field that keeps track of the number of FileIDs (files and macros) that were created during preprocessing of that particular file SLocEntry. This is useful when computing the macro argument map in skipping included files while scanning for macro arg FileIDs that lexed from a specific source file. Due to padding, the new field does not increase the size of SLocEntry. llvm-svn: 138225
* Make the loading of multiple records for the same identifier (fromDouglas Gregor2011-08-201-1/+3
| | | | | | | | | | different modules) more robust. It already handled (simple) merges of the set of declarations attached to that identifier, so add a test case that shows us getting two different declarations for the same identifier (one struct, one function) from different modules, and are able to use both of them. llvm-svn: 138189
* Clean out some minor cruft in the AST reader; no functionality change.Douglas Gregor2011-08-201-2/+0
| | | | llvm-svn: 138188
* Introduce a module visitation function that starts at the top-levelDouglas Gregor2011-08-201-19/+116
| | | | | | | | | | | | | | | | | modules (those that no other module depends on) and performs a search over all of the modules, visiting a new module only when all of the modules that depend on it have already been visited. The visitor can abort the search for all modules that a module depends on, which allows us to minimize the number of lookups necessary when performing a search. Switch identifier lookup from a linear walk over the set of modules to this module visitation operation. The behavior is the same for simple PCH and chained PCH, but provides the proper search order for modules. Verified with printf debugging, since we don't have enough in place to actually test this. llvm-svn: 138187
* Remove unused function ModuleManager::exportLookup()Douglas Gregor2011-08-191-10/+0
| | | | llvm-svn: 138079
* Teach ModuleManager::addModule() to check whether a particular moduleDouglas Gregor2011-08-191-38/+66
| | | | | | | | | | | | | | | | | | has already been loaded before allocating a new Module structure. If the module has already been loaded (uniquing based on file name), then just return the existing module rather than trying to load it again. This allows us to load a DAG of modules. Introduce a simple test case that forms a diamond-shaped module graph, and illustrates that a source file importing the bottom of the diamond can see declarations in all four of the modules that make up the diamond. Note that this version moves the file-opening logic into the module manager, rather than splitting it between the module manager and the AST reader. More importantly, it properly handles the weird-but-possibly-useful case of loading an AST file from "-". llvm-svn: 138030
* Temporarily revert r137925 to appease buildbots. Original commit message:Chad Rosier2011-08-181-39/+14
| | | | | | | | | | | | | | Teach ModuleManager::addModule() to check whether a particular module has already been loaded before allocating a new Module structure. If the module has already been loaded (uniquing based on file name), then just return the existing module rather than trying to load it again. This allows us to load a DAG of modules. Introduce a simple test case that forms a diamond-shaped module graph, and illustrates that a source file importing the bottom of the diamond can see declarations in all four of the modules that make up the diamond. llvm-svn: 137971
* Teach ModuleManager::addModule() to check whether a particular moduleDouglas Gregor2011-08-181-14/+39
| | | | | | | | | | | | | has already been loaded before allocating a new Module structure. If the module has already been loaded (uniquing based on file name), then just return the existing module rather than trying to load it again. This allows us to load a DAG of modules. Introduce a simple test case that forms a diamond-shaped module graph, and illustrates that a source file importing the bottom of the diamond can see declarations in all four of the modules that make up the diamond. llvm-svn: 137925
* Keep track of which modules have been loaded directly (e.g., viaDouglas Gregor2011-08-182-27/+36
| | | | | | | | | | | | | -import-module) vs. loaded because some other module depends on them. As part of doing this, pass down the module that caused a module to be loaded directly, rather than assuming that we're loading a chain. Finally, write out all of the directly-loaded modules when serializing an AST file (using the new IMPORTS record), so that an AST file can depend on more than one other AST file, all of which will be loaded when that AST file is loaded. This allows us to form and load a tree of modules, but we can't yet load a DAG of modules. llvm-svn: 137923
* Remove an unnecessary assignment (to InstFromD).Argyrios Kyrtzidis2011-08-171-7/+3
| | | | | | Caught by the static analyzer! llvm-svn: 137878
* In the AST file format, eliminate the CHAINED_METADATA record. Instead,Douglas Gregor2011-08-172-28/+40
| | | | | | | | | | | | | all AST files have a normal METADATA record that has the same form regardless of whether we refer to a chained PCH or any other kind of AST file. Introduce the IMPORTS record, which describes all of the AST files that are imported by this AST file, and how (as a module, a PCH file, etc.). Currently, we emit at most one entry to this record, to support chained PCH. llvm-svn: 137869
* Add serialization support for ClassScopeFunctionSpecializationDecl.Francois Pichet2011-08-172-0/+18
| | | | llvm-svn: 137799
* [PCH] When writing out ExpansionInfo, make sure we don't lose track if it's ↵Argyrios Kyrtzidis2011-08-171-1/+2
| | | | | | a macro arg expansion or not. llvm-svn: 137792
* Track in the AST whether a function is constexpr.Richard Smith2011-08-152-1/+3
| | | | llvm-svn: 137653
* Implement function template specialization at class scope extension in ↵Francois Pichet2011-08-141-0/+4
| | | | | | | | | | | | | | | | | Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization. Example: template <class T> class A { public: template <class U> void f(U p) { } template <> void f(int p) { } // <== class scope specialization }; This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code. BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error. llvm-svn: 137573
* Switch the __int128_t and __uint128_t types over to predefined typesDouglas Gregor2011-08-122-4/+12
| | | | | | | in the AST format, which are built lazily by the ASTContext when requested. llvm-svn: 137437
* Switch the Objective-C 'SEL' type over to a predefined type in theDouglas Gregor2011-08-122-6/+6
| | | | | | | AST file format, lazily generating the actual declaration in ASTContext as needed. llvm-svn: 137434
* Switch the Objective-C 'Class' type over to a predefined type in theDouglas Gregor2011-08-122-7/+7
| | | | | | | AST file format, lazily generating the actual declaration in ASTContext as needed. llvm-svn: 137431
* Move the creation of the predefined typedef for Objective-C's 'id'Douglas Gregor2011-08-122-7/+7
| | | | | | | | | type over into the AST context, then make that declaration a predefined declaration in the AST format. This ensures that different AST files will at least agree on the (global) declaration ID for 'id', and eliminates one of the "special" types in the AST file format. llvm-svn: 137429
* Collapse ASTWriter::WriteASTChain into ASTWriter::WriteASTCore,Douglas Gregor2011-08-121-306/+103
| | | | | | | | eliminating a pile of redundant code (and probably some bugs in the process). The variation between chained and non-chained PCH is fairly small now anyway. llvm-svn: 137410
* In the serialized AST format, make the translation unit a "predefined"Douglas Gregor2011-08-124-56/+106
| | | | | | | | | | declaration that never actually gets serialized. Instead, serialize the various kinds of update records (lexical decls, visible decls, the addition of an anonymous namespace) for the translation unit, even if we're not chaining. This way, we won't have to deal with multiple loaded translation unit declarations. llvm-svn: 137395
* Fix a PCH crash bug where we kept a reference inside a DenseMap while the ↵Argyrios Kyrtzidis2011-08-111-1/+4
| | | | | | | | map was getting modified. No test case, sorry. It's one of those bugs where it's really really hard to make one. rdar://9910862. llvm-svn: 137383
* When initializing a context from a particular AST file, check whetherDouglas Gregor2011-08-111-34/+71
| | | | | | | | either "special" type has already been initialized. Previously, we did this check based on just the first special type (__builtin_va_list), but now we have some NULL special type entries to content with. llvm-svn: 137373
* The AST reader and writer don't need accessors for poking at the predefined ↵Douglas Gregor2011-08-112-8/+8
| | | | | | Objective-C types llvm-svn: 137366
* Renamings to consistently use 'Constexpr' not 'ConstExpr' when referring to ↵Richard Smith2011-08-102-2/+2
| | | | | | the C++0x 'constexpr' keyword. llvm-svn: 137230
* Move the creation of the record type for the state of Objective-C fastDouglas Gregor2011-08-092-4/+0
| | | | | | | | enumerations from the ASTContext into CodeGen, so that we don't need to serialize it to AST files. This appears to be the last of the low-hanging fruit for SpecialTypes. llvm-svn: 137124
* Don't serialize the block descriptor or block extended descriptorDouglas Gregor2011-08-092-7/+0
| | | | | | | types to AST files; they're only used by debug info generation anyway, and shouldn't ever exist in the AST anyway. llvm-svn: 137122
* Move the construction of the RecordDecl representing the runtimeDouglas Gregor2011-08-092-3/+0
| | | | | | | | layout of a constant NSString from the ASTContext over to CodeGen, since this is solely CodeGen's responsibility. Eliminates one of the unnecessary "special" types that we serialize. llvm-svn: 137121
* Migrate the serialization of ASTContext's AutoDeduceTy andDouglas Gregor2011-08-093-12/+18
| | | | | | | AutoRRefDeductTy from the "special types" block to predefined types. The latter behaves better when loading multiple AST files. llvm-svn: 137120
* Add workaround for built va list (and other builtins) so that running ↵Jonathan D. Turner2011-08-051-81/+84
| | | | | | ReadAST multiple times does not immediately throw an error. llvm-svn: 136995
* Clean up the debug dump for a Module, so the local->global maps areDouglas Gregor2011-08-041-8/+19
| | | | | | | clearly called out, and add the missing local -> global selector map output. llvm-svn: 136903
* Introduce local -> global mapping for preprocessed entity IDs. This isDouglas Gregor2011-08-042-15/+41
| | | | | | | | | the last of the ID/offset/index mappings that I know of. Unfortunately, the "gap" method of testing doesn't work here due to the way the preprocessing record performs iteration. We'll do more testing once multi-AST loading is possible. llvm-svn: 136902
* Remove the unset, unused return value ofDouglas Gregor2011-08-041-6/+6
| | | | | | ASTReader::ReadMacroRecord(). No functionality change. llvm-svn: 136893
* In the AST reader and writer, slide the preprocessed entity IDs by +1Douglas Gregor2011-08-042-10/+12
| | | | | | | so that we use ID zero as a sentinel for "no result". This matches the convention set by all of the other global IDs. llvm-svn: 136885
* Add some missing record names to the AST output. No functionality change, ↵Douglas Gregor2011-08-041-0/+3
| | | | | | but llvm-bcanalyzer will be a little more informative now for AST files llvm-svn: 136883
* Implement the local -> global remapping for macro definition IDs inDouglas Gregor2011-08-042-11/+40
| | | | | | the detailed preprocessing record. Tested with the standard "gaps" method. llvm-svn: 136882
* The AST reader was forgetting to parse ObjCInferRelatedReturnTypeDouglas Gregor2011-08-041-0/+1
| | | | llvm-svn: 136879
* Don't introduce a local -> global mapping for CXXBaseSpecifiers. TheDouglas Gregor2011-08-043-30/+14
| | | | | | | | IDs will never cross module boundaries, since they're tied to the CXXDefinitionData, so just use a local mapping throughout. Eliminate the global -> local tables and supporting data. llvm-svn: 136847
* Introduce local -> global selector ID mapping into the ASTDouglas Gregor2011-08-033-15/+38
| | | | | | reader. Tested with the usual "gaps" method. llvm-svn: 136839
* Introduce a local-to-global remapping for identifiers in the ASTDouglas Gregor2011-08-032-18/+46
| | | | | | | reader, and fix up the one (!) place where we were improperly mapping a local ID to a global ID. Tested via the usual "gaps" trick. llvm-svn: 136817
* Fix a few typosJonathan D. Turner2011-08-031-1/+1
| | | | llvm-svn: 136792
* Introduce a constant for the number of predefined declarations in anDouglas Gregor2011-08-032-7/+13
| | | | | | | | AST file, along with an enumeration naming those predefined declarations. No functionality change, but this will make it easier to introduce new predefined declarations, when/if we need them. llvm-svn: 136781
* Introduce the local -> global declaration ID mapping into the ASTDouglas Gregor2011-08-033-42/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | reader, to allow AST files to be loaded with their declarations remapped to different ID numbers. Fix a number of places where we were either failing to map local declaration IDs into global declaration IDs or where interpreting the local declaration IDs within the wrong module. I've tested this via the usual "random gaps" method. It works well except for the preamble tests, because our handling of the precompiled preamble requires declaration and preprocessed entity to be stable when parsing code and then loading that back into memory. This property will hold in general, but my randomized testing naturally breaks this property to get more coverage. In the future, I expect that the precompiled preamble logic won't need this property. I am very unhappy with the current handling of the translation unit, which is a rather egregious hack. We're going to have to do something very different here for loading multiple AST files, because we don't want to have to cope with merging two translation units. Likely, we'll just handle translation units entirely via "update" records, and predefine a single, fixed declaration ID for the translation unit. That will come later. llvm-svn: 136779
* Change the hashing function for DeclContext lookup within an AST fileDouglas Gregor2011-08-022-97/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | by eliminating the type ID from constructor, destructor, and conversion function names. There are several reasons for this change: - A given type (say, int*) isn't guaranteed to have a single, unique type ID within a chain of PCH files. Hence, we could end up hashing based on the wrong type ID, causing name lookup to fail. - The mapping from types back to type IDs required one DenseMap entry for every type that was ever deserialized, which was an unacceptable cost to support just the name lookup of constructors, destructors, and conversion functions. Plus, this mapping could never actually work with chained or multiple PCH, based on the first bullet. Once we have eliminated the type from the hash function, these problems go away, as does my horrible "reverse type remap" hack, which was doomed from the start (see bullet #1 above) and far too complicated. However, note that removing the type from the hash function means that all constructors, destructors, and conversion functions have the same hash key, so I've updated the caller to double-check that the declarations found have the appropriate name. llvm-svn: 136708
* Following up the earlier refactoring/cleanup work by fixing up how we manage ↵Jonathan D. Turner2011-08-022-11/+30
| | | | | | the virtual files the ASTReader has to handle. Specifically, this occurs when the reader is reading AST files that were created in memory and not written to disk. For example, when a user creates a chained PCH using command line flags. These virtual files are stored in MemoryBuffers in ChainIncludeSource.cpp, and then read back in by the ASTReader. This patch moves the management of these buffers into the ModuleManager, so that it becomes the authority on where these buffers are located. llvm-svn: 136697
OpenPOWER on IntegriCloud