summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriterDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [PCH] When we are replacing a decl in a chained PCH that is also a DeclContext,Argyrios Kyrtzidis2012-03-221-13/+24
| | | | | | | | | make sure to fully load its external lexical and visible declarations before re-writing it. rdar://10914192 llvm-svn: 153254
* Fix Objective-C compilation-time performance regression introduced in r152608.Richard Smith2012-03-161-3/+1
| | | | | | | | | | | | | | | | Reintroduce lazy name lookup table building, ensuring that the lazy building step produces the same lookup table that would be built by the eager step. Avoid building a lookup table for the translation unit outside C++, even in cases where we can't recover the contents of the table from the declaration chain on the translation unit, since we're not going to perform qualified lookup into it anyway. Continue to support lazily building such lookup tables for now, though, since ASTMerge uses them. In my tests, this performs very similarly to ToT with r152608 backed out, for C, Obj-C and C++, and does not suffer from PR10447. llvm-svn: 152905
* Instantiating a class template should not instantiate the definition of anyRichard Smith2012-03-141-1/+7
| | | | | | | | scoped enumeration members. Later uses of an enumeration temploid as a nested name specifier should cause its instantiation. Plus some groundwork for explicit specialization of member enumerations of class templates. llvm-svn: 152750
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-0/+1
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. llvm-svn: 152491
* Allow serializing an invalid ParmVarDecl and don't set access to public forArgyrios Kyrtzidis2012-03-091-8/+8
| | | | | | | | invalid ParmVarDecls. Part of rdar://11007039. llvm-svn: 152437
* objective-c: provide fixit hint when atomic property does notFariborz Jahanian2012-02-291-0/+1
| | | | | | | have matching user defined setter/getter and a warning is issued. In this case, a fixit note is displayed. // rdar://10267155 llvm-svn: 151766
* Generate an AST for the conversion from a lambda closure type to aDouglas Gregor2012-02-221-2/+0
| | | | | | | | | | | | | | | block pointer that returns a block literal which captures (by copy) the lambda closure itself. Some aspects of the block literal are left unspecified, namely the capture variable (which doesn't actually exist) and the body (which will be filled in by IRgen because it can't be written as an AST). Because we're switching to this model, this patch also eliminates tracking the copy-initialization expression for the block capture of the conversion function, since that information is now embedded in the synthesized block literal. -1 side tables FTW. llvm-svn: 151131
* modern objc translator. Finish off first cut of theFariborz Jahanian2012-02-201-0/+4
| | | | | | | modern meta-data translation by commenting out private ivar declarations in user source. Also, added several tests. llvm-svn: 150985
* Implicitly define a lambda's conversion functions (to functionDouglas Gregor2012-02-161-0/+2
| | | | | | | | | | | | | pointers and block pointers). We use dummy definitions to keep the invariant that an implicit, used definition has a body; IR generation will substitute the actual contents, since they can't be represented as C++. For the block pointer case, compute the copy-initialization needed to capture the lambda object in the block, which IR generation will need later. llvm-svn: 150645
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Reimplement (de-)serialization of Objective-C categories to eliminateDouglas Gregor2012-01-271-3/+9
| | | | | | | | | | | | | | 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
* Don't separately serialize the list of instance variables in anDouglas Gregor2012-01-261-6/+0
| | | | | | Objective-C class. The AST reader just throws away this data anyway! llvm-svn: 149067
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-1/+0
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
* Now that deserializing a definition of a C++ class/Objective-CDouglas Gregor2012-01-151-14/+6
| | | | | | | | | | class/Objective-C protocol suffices get all of the redeclarations of that declaration wired to the definition, we no longer need to record the identity of the definition in every declaration. Instead, just record a bit to indicate whether a particular declaration is the definition. llvm-svn: 148224
* Completely re-implement (de-)serialization of redeclarationDouglas Gregor2012-01-151-21/+17
| | | | | | | | | | | | | | | | 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
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-10/+10
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* Revert accidental commitDouglas Gregor2012-01-141-3/+1
| | | | llvm-svn: 148183
* Add a FIXME for mutation of the common pointer of a ↵Douglas Gregor2012-01-141-1/+3
| | | | | | RedeclarableTemplateDecl. It is not clear that it's worth delaying the allocation of said pointer llvm-svn: 148182
* Reimplement RedeclarableTemplateDecl in terms ofDouglas Gregor2012-01-141-26/+5
| | | | | | | | | | | 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
* 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
OpenPOWER on IntegriCloud