summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Progress towards making isUsed() reflect whether a declaration is odr-used; ↵Eli Friedman2012-01-131-0/+1
| | | | | | | | don't set isUsed for local variables which are referenced in unevaluated contexts. Make other code use isReferenced() (which basically indicates that a declaration isn't dead) where appropriate. I was forced to change test/SemaCXX/linkage.cpp because we aren't actually modeling extern "C" in the AST the way that testcase expects; we were not printing a warning only because we skipped the relevant check. Someone who actually understands the semantics here should fix that. llvm-svn: 148158
* Pack UsingDecl more.Benjamin Kramer2012-01-071-1/+1
| | | | | | 88 -> 80 bytes on x86_64. llvm-svn: 147736
* Switch NamespaceDecl from its own hand-rolled redeclaration chain overDouglas Gregor2012-01-071-6/+3
| | | | | | | | | | | | to Redeclarable<NamespaceDecl>, so that we benefit from the improveed redeclaration deserialization and merging logic provided by Redeclarable<T>. Otherwise, no functionality change. As a drive-by fix, collapse the "inline" bit into the low bit of the original namespace/anonymous namespace, saving 8 bytes per NamespaceDecl on x86_64. llvm-svn: 147729
* Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bitsDouglas Gregor2012-01-061-2/+2
| | | | | | | | into the two unused lower bits of the NextDeclInContext link, dropping the number of bits in Decl down to 32, and saving 8 bytes per declaration on x86-64. llvm-svn: 147660
* Don't seed the ASTWriter's declaration -> ID mapping with the IDs ofDouglas Gregor2012-01-051-6/+12
| | | | | | | each deserialized declaration, since that information is already available in each declaration. llvm-svn: 147619
* Implement declaration merging for non-template functions fromDouglas Gregor2012-01-041-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | different modules. This implementation is a first approximation of what we want, using only the function type to determine equivalence. Later, we'll want to deal with some of the more subtle issues, including: - C allows a prototyped declaration and a non-prototyped declaration to be merged, which we should support - We may want to ignore the return type when merging, then complain if the return types differ. Or, we may want to leave it as it us, so that we only complain if overload resolution eventually fails. - C++ non-static member functions need to consider cv-qualifiers and ref-qualifiers. - Function templates need to consider the template parameters and return type. - Function template specializations will have special rules. - We can now (accidentally!) end up overloading in C, even without the "overloadable" attribute, and will need to detect this at some point. The actual detection of "is this an overload?" is implemented by Sema::IsOverload(), which will need to be moved into the AST library for re-use here. That will be a future refactor. llvm-svn: 147534
* Eliminate ObjCProtocolDecl's end-of-definition location. It is notDouglas Gregor2012-01-021-1/+0
| | | | | | used anywhere. llvm-svn: 147422
* Move ObjCProtocolDecl::EndLoc into its DefinitionData, and giveDouglas Gregor2012-01-021-1/+1
| | | | | | ObjCProtocolDecl proper source-range information. llvm-svn: 147420
* Eliminate the ForwardDecl/InitiallyForwardDecl bits from ObjCProtocolDecl. ↵Douglas Gregor2012-01-011-2/+0
| | | | | | They are no longer needed llvm-svn: 147419
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-14/+0
| | | | | | ObjCProtocolDecl modules forward declarations properly. llvm-svn: 147415
* Introduce the core infrastructure needed to model redeclaration chainsDouglas Gregor2012-01-011-0/+1
| | | | | | | | | | | | | | | 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-9/+16
| | | | | | | | | 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-8/+0
| | | | | | | covers both declarations (@class) and definitions (@interface) of an Objective-C class. llvm-svn: 147299
* Once we have fully deserialized a redeclaration chain for somethingDouglas Gregor2011-12-191-4/+4
| | | | | | | | | | | 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-41/+39
| | | | | | | | | | | | | | | | 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-39/+16
| | | | | | | | | | | 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/+7
| | | | | | into operations on TypedefNameDecl. No functionality change. llvm-svn: 146866
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-2/+5
| | | | | | | | | | | | | | | | | | | | | 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-31/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* Introduce the core infrastructure needed to model a completeDouglas Gregor2011-12-151-0/+1
| | | | | | | | | | | | | | | 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-26/+36
| | | | | | | | | | | | | | | | 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-2/+2
| | | | | | | members into ObjCClassDecl, saving ourselves one pointer per forward declaration. llvm-svn: 146564
* Tweak submodule ID handling in the AST writerDouglas Gregor2011-12-121-1/+0
| | | | llvm-svn: 146445
* Save category name loc in ObjCCategoryImplDecl, patch by Jason Haslam!Argyrios Kyrtzidis2011-12-091-0/+1
| | | | llvm-svn: 146213
* Introduce a module import declaration, so that we properly represent, e.g.,Douglas Gregor2011-12-021-0/+19
| | | | | | | | __import_module__ std.vector; in the AST. llvm-svn: 145725
* Infer the submodule ID for a given declaration based on the locationDouglas Gregor2011-12-011-0/+8
| | | | | | | of that declaration, and encode the submodule ID in each declaration stored in an AST file. llvm-svn: 145555
* [PCH] Check for isTopLevelDeclInObjCContainer when picking abbreviations.Argyrios Kyrtzidis2011-11-231-0/+5
| | | | llvm-svn: 145110
* [libclang] Fix operations (token annotation, getting cursor, etc.) with a ↵Argyrios Kyrtzidis2011-11-231-0/+8
| | | | | | | | | | | | | | | 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] Now that we store the location of a decl outside its recordArgyrios Kyrtzidis2011-10-311-1/+2
| | | | | | make sure that we keep track of locations of replaced decls as well. llvm-svn: 143341
* [PCH] In ASTWriter::associateDeclWithFile don't bother finding the file locArgyrios Kyrtzidis2011-10-281-4/+2
| | | | | | 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-3/+10
| | | | | | | | | | | | 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
* [PCH] Pull the location out of the serialized declarations and put it in the ↵Argyrios Kyrtzidis2011-10-271-10/+4
| | | | | | | | | | | 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-9/+11
| | | | | | | | | | | 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-0/+2
| | | | | | reference. llvm-svn: 142230
* [PCH] Serialize info about redeclared objc methods.Argyrios Kyrtzidis2011-10-141-0/+8
| | | | llvm-svn: 141964
* Rename TagDecl::isDefinition -> isCompleteDefinitionJohn McCall2011-10-071-4/+4
| | | | | | | for better self-documenting code, since the semantics are subtly different from getDefinition(). llvm-svn: 141355
* Added a flag to identify resolved overloaded function references.Abramo Bagnara2011-10-051-0/+1
| | | | llvm-svn: 141171
* Improve location fidelity of objc decls.Argyrios Kyrtzidis2011-10-041-2/+1
| | | | | | | | -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-0/+8
| | | | | | | | | | | | | 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
* Don't keep NumSelectorArgs in the ObjCMethodDecl, the number can be derived ↵Argyrios Kyrtzidis2011-10-031-1/+0
| | | | | | from the selector. llvm-svn: 140983
* Mark a TagDecl when it is free standing (e.g. "struct foo;")Argyrios Kyrtzidis2011-09-301-0/+3
| | | | llvm-svn: 140894
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-1/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-1/+1
| | | | llvm-svn: 140367
* Don't use TemplateArgumentListInfo inside AST nodes because it may leak.Argyrios Kyrtzidis2011-09-221-4/+5
| | | | | | Use ASTTemplateArgumentListInfo instead. llvm-svn: 140331
* [PCH] Fix a regression that r139441 introduced (decls were getting passedArgyrios Kyrtzidis2011-09-131-0/+3
| | | | | | | | | | | | | | | | | to the consumer without being fully deserialized). The regression was on compiling boost.python and it was too difficult to get a reduced test case unfortunately. Also modify the logic of how objc methods are getting passed to the consumer; codegen depended on receiving objc methods before the implementation decl. Since the interesting objc methods are ones with a body and such methods only exist inside an ObjCImplDecl, deserialize and pass to consumer all the methods of ObCImplDecl when we see one. Fixes http://llvm.org/PR10922 & rdar://10117105. llvm-svn: 139644
* Clean up our handling of Objective-C definitions in AST files. RatherDouglas Gregor2011-09-101-1/+1
| | | | | | | | | than having CodeGen check whether a declaration comes from an AST file (which it shouldn't know or care about), make sure that the AST writer and reader pass along "interesting" declarations that CodeGen needs to know about. llvm-svn: 139441
* Kill of the Decl::PCHLevel field entirely. We now only need to knowDouglas Gregor2011-09-101-15/+0
| | | | | | whether a Decl was deserialized from an AST file (any AST file). llvm-svn: 139438
OpenPOWER on IntegriCloud