summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't attempt to merge a deserialized declaration with existingDouglas Gregor2012-01-031-0/+4
| | | | | | | declarations in the AST unless modules are enabled. This case doesn't come up with precompiled headers, and it isn't cheap. llvm-svn: 147451
* Factor the merging of declarations in the AST reader out to a separateDouglas Gregor2012-01-031-78/+48
| | | | | | | | member function template, since the behavior is identical for ObjCInterfaceDecl and ObjCProtocolDecl. It's expected that all redeclarable entities will have the same behavior. llvm-svn: 147450
* Eliminate ObjCProtocolDecl's end-of-definition location. It is notDouglas Gregor2012-01-021-2/+0
| | | | | | used anywhere. llvm-svn: 147422
* Move ObjCProtocolDecl::EndLoc into its DefinitionData, and giveDouglas Gregor2012-01-021-1/+2
| | | | | | ObjCProtocolDecl proper source-range information. llvm-svn: 147420
* Eliminate the ForwardDecl/InitiallyForwardDecl bits from ObjCProtocolDecl. ↵Douglas Gregor2012-01-011-3/+1
| | | | | | They are no longer needed llvm-svn: 147419
* Implement declaration merging for Objective-C protocols acrossDouglas Gregor2012-01-011-3/+45
| | | | | | | multiple, disjoint modules. There is far too much duplicating with the ObjCInterfaceDecl case here, which I'll eliminate shortly. llvm-svn: 147417
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-19/+0
| | | | | | ObjCProtocolDecl modules forward declarations properly. llvm-svn: 147415
* Wire up redeclaration chains for Objective-C protocols, so that bothDouglas Gregor2012-01-011-1/+1
| | | | | | | forward declarations and definitions of an Objective-C protocol are represented within a single chain of ObjCProtocolDecls. llvm-svn: 147412
* Introduce the core infrastructure needed to model redeclaration chainsDouglas Gregor2012-01-011-2/+22
| | | | | | | | | | | | | | | 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
* Move the data that corresponds to the definition of a protocol into aDouglas Gregor2012-01-011-11/+23
| | | | | | | | | separately-allocated DefinitionData structure. Introduce various functions that will help with the separation of declarations from definitions (isThisDeclarationADefinition(), hasDefinition(), getDefinition()). llvm-svn: 147408
* Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDeclDouglas Gregor2011-12-271-10/+0
| | | | | | | covers both declarations (@class) and definitions (@interface) of an Objective-C class. llvm-svn: 147299
* Make a note for an optimization that I'd like to implement, when the ASTs ↵Douglas Gregor2011-12-221-0/+8
| | | | | | for local externs are sound llvm-svn: 147185
* Serialize the AST reader's mapping from canonical declarations to theDouglas Gregor2011-12-221-5/+33
| | | | | | | | | | | | | | | | 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
* If we end up merging an Objective-C class with an existing Objective-CDouglas Gregor2011-12-221-2/+16
| | | | | | | class that comes from a different module file, make sure that we load all of the pending declarations for the original declaration. llvm-svn: 147168
* When deserializing an Objective-C class, check whether we have anotherDouglas Gregor2011-12-221-28/+224
| | | | | | | | | | | | | | | | 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
* Implement a trivial, obvious optimization for deserialization ofDouglas Gregor2011-12-211-2/+2
| | | | | | | | | | redeclaration chains: only ever have the reader search for redeclarations of the first (canonical) declaration, since we only ever record redeclaration ranges for the that declaration. Searching for redeclarations of non-canonical declarations will never find anything, so it's a complete waste of time. llvm-svn: 147055
* Remove ASTReader's PendingForwardRefs, which is now handled by theDouglas Gregor2011-12-191-54/+8
| | | | | | (more general) fix-up of definition data pointers. llvm-svn: 146903
* Once we have fully deserialized a redeclaration chain for somethingDouglas Gregor2011-12-191-11/+27
| | | | | | | | | | | 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
* Re-implement (de-)serialization of redeclaration chains forDouglas Gregor2011-12-191-65/+54
| | | | | | | | | | | | | | | | redeclaration templates (RedeclarableTemplateDecl), similarly to the way (de-)serialization is implemented for Redeclarable<T>. In the process, found a simpler formulation for handling redeclaration chains and implemented that in both places. The new test establishes that we're building the redeclaration chains properly. However, the FIXME indicates where we're tickling a different bug that has to do with us not setting the DefinitionData pointer properly in redeclarations that we detected after the definition itself was deserialized. The (separable) fix for that bug is forthcoming. llvm-svn: 146883
* Optimize serialized representation of redeclarable declarations forDouglas Gregor2011-12-191-1/+13
| | | | | | | | | | | which there are no redeclarations. This reduced by size of the PCH file for Cocoa.h by ~650k: ~536k of that was in the new LOCAL_REDECLARATIONS table, which went from a ridiculous 540k down to an acceptable 3.5k, while the rest was due to the more compact abbreviated representation of redeclarable declaration kinds (which no longer need to store the 'first' declaration ID). llvm-svn: 146869
* Combine common (de-)serialization logic for typedefs and type aliasesDouglas Gregor2011-12-191-5/+8
| | | | | | into operations on TypedefNameDecl. No functionality change. llvm-svn: 146866
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-1/+7
| | | | | | | | | | | | | | | | | | | | | variable is initialized by a non-constant expression, and pass in the variable being declared so that earlier-initialized fields' values can be used. Rearrange VarDecl init evaluation to make this possible, and in so doing fix a long-standing issue in our C++ constant expression handling, where we would mishandle cases like: extern const int a; const int n = a; const int a = 5; int arr[n]; Here, n is not initialized by a constant expression, so can't be used in an ICE, even though the initialization expression would be an ICE if it appeared later in the TU. This requires computing whether the initializer is an ICE eagerly, and saving that information in PCH files. llvm-svn: 146856
* Completely re-implement (de-)serialization of declarationDouglas Gregor2011-12-171-54/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix chaining of ObjCInterfaceDecl redeclarationsDouglas Gregor2011-12-161-9/+14
| | | | llvm-svn: 146722
* Move ObjCInterfaceDecl's "EndLoc" into DefinitionData, since it onlyDouglas Gregor2011-12-151-2/+2
| | | | | | | | applies to an actual definition. Plus, clarify the purpose of this field and give the accessor a different name, since getLocEnd() is supposed to be the same as getSourceRange().getEnd(). llvm-svn: 146694
* Keep track of all declarations of an Objective-C class (both forwardDouglas Gregor2011-12-151-1/+0
| | | | | | | | | | declarations and definitions) as ObjCInterfaceDecls within the same redeclaration chain. This new representation matches what we do for C/C++ variables/functions/classes/templates/etc., and makes it possible to answer the query "where are all of the declarations of this class?" llvm-svn: 146679
* Extend ObjCInterfaceDecl::DefinitionData to contain a pointer to theDouglas Gregor2011-12-151-5/+5
| | | | | | | definition, and implement ObjCInterfaceDecl::getDefinition() efficiently based on that. llvm-svn: 146669
* Introduce the core infrastructure needed to model a completeDouglas Gregor2011-12-151-3/+16
| | | | | | | | | | | | | | | 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
* Move the definition-specific data of ObjCInterfaceDecl into aDouglas Gregor2011-12-151-33/+70
| | | | | | | | | | | | | | | | separately-allocated DefinitionData structure, which we manage the same way as CXXRecordDecl::DefinitionData. This prepares the way for making ObjCInterfaceDecls redeclarable, to more accurately model forward declarations of Objective-C classes and eliminate the mutation of ObjCInterfaceDecl that causes us serious trouble in the AST reader. Note that ObjCInterfaceDecl's accessors are fairly robust against being applied to forward declarations, because Clang (and Sema in particular) doesn't perform RequireCompleteType/hasDefinition() checks everywhere it has to. Each of these overly-robust cases is marked with a FIXME, which we can tackle over time. llvm-svn: 146644
* Eliminate the vistigial ObjCClassDecl::ObjCClassRef, and inline itsDouglas Gregor2011-12-141-3/+2
| | | | | | | members into ObjCClassDecl, saving ourselves one pointer per forward declaration. llvm-svn: 146564
* Save category name loc in ObjCCategoryImplDecl, patch by Jason Haslam!Argyrios Kyrtzidis2011-12-091-1/+2
| | | | llvm-svn: 146213
* Introduce a module import declaration, so that we properly represent, e.g.,Douglas Gregor2011-12-021-0/+20
| | | | | | | | __import_module__ std.vector; in the AST. llvm-svn: 145725
* Implement name hiding for declarations deserialized from a non-visibleDouglas Gregor2011-12-011-4/+27
| | | | | | 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-0/+4
| | | | | | | of that declaration, and encode the submodule ID in each declaration stored in an AST file. llvm-svn: 145555
* Promote ModuleMap::Module to a namespace-scope class in the BasicDouglas Gregor2011-11-301-17/+17
| | | | | | | | | 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
* [libclang] Fix operations (token annotation, getting cursor, etc.) with a ↵Argyrios Kyrtzidis2011-11-231-0/+1
| | | | | | | | | | | | | | | file region inside an objc container that "contains" other file-level declarations. When getting the array of file-level declarations that overlap with a file region, we failed to report that the region overlaps with an objc container, if the container had other file-level declarations declared lexically inside it. Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST and handling them appropriately. llvm-svn: 145109
* Use Decl's isImplicit field to indicate whether an ObjCInterfaceDecl is ↵Argyrios Kyrtzidis2011-11-151-1/+0
| | | | | | | | 'ImplicitInterfaceDecl', no need to store it in another field. llvm-svn: 144624
* [PCH] Load the chained objc categories only after recursive loading is finishedArgyrios Kyrtzidis2011-11-141-2/+4
| | | | | | otherwise we may crash. llvm-svn: 144524
* [PCH] When completing an objc forward reference, do not serialize the chain ↵Argyrios Kyrtzidis2011-11-121-2/+2
| | | | | | | | | | | | | | | 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
* [PCH] Now that we store the location of a decl outside its recordArgyrios Kyrtzidis2011-10-311-2/+4
| | | | | | make sure that we keep track of locations of replaced decls as well. llvm-svn: 143341
* [PCH] Pull the location out of the serialized declarations and put it in the ↵Argyrios Kyrtzidis2011-10-271-8/+14
| | | | | | | | | | | array of decl bit offsets. This allows us to easily get at the location of a decl without deserializing it. It increases size of Cocoa PCH by only 0.2%. llvm-svn: 143123
* Eliminate a hang while loading a sequence of redeclarable entities. InDouglas Gregor2011-10-261-8/+27
| | | | | | | | | | | essence, the redeclaration chain for a class could end up in an inconsistent state while deserializing multiple declarations in that chain, where the circular linked list was not, in fact, circular. Since only two redeclarations of the same entity will get loaded when we're in this state, restore circularity when both have been loaded. Fixes <rdar://problem/10324940> / PR11195. llvm-svn: 143037
* Keep track when a ObjC interface/protocol was initially created as a forward ↵Argyrios Kyrtzidis2011-10-171-1/+3
| | | | | | reference. llvm-svn: 142230
* [PCH] Serialize info about redeclared objc methods.Argyrios Kyrtzidis2011-10-141-0/+7
| | | | llvm-svn: 141964
* Rename TagDecl::isDefinition -> isCompleteDefinitionJohn McCall2011-10-071-2/+2
| | | | | | | for better self-documenting code, since the semantics are subtly different from getDefinition(). llvm-svn: 141355
* Improve location fidelity of objc decls.Argyrios Kyrtzidis2011-10-041-8/+8
| | | | | | | | -Add the location of the class name to all objc container decls, not just ObjCInterfaceDecl. -Make objc decls consistent with the rest of the NamedDecls and have getLocation() point to the class name, not the location of '@'. llvm-svn: 141061
* Allow getting all source locations of selector identifiers in a ObjCMethodDecl.Argyrios Kyrtzidis2011-10-031-2/+9
| | | | | | | | | | | | | Instead of always storing all source locations for the selector identifiers we check whether all the identifiers are in a "standard" position; "standard" position is -Immediately before the arguments: -(id)first:(int)x second:(int)y; -With a space between the arguments: -(id)first: (int)x second: (int)y; -For nullary selectors, immediately before ';': -(void)release; In such cases we infer the locations instead of storing them. llvm-svn: 140989
* Pass from the parser the locations of selector identifiers when creatingArgyrios Kyrtzidis2011-10-031-0/+1
| | | | | | | | objc method decls. They are not stored in the AST yet. llvm-svn: 140984
* Don't keep NumSelectorArgs in the ObjCMethodDecl, the number can be derived ↵Argyrios Kyrtzidis2011-10-031-3/+1
| | | | | | from the selector. llvm-svn: 140983
* Mark a TagDecl when it is free standing (e.g. "struct foo;")Argyrios Kyrtzidis2011-09-301-0/+1
| | | | llvm-svn: 140894
OpenPOWER on IntegriCloud