summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [PCH] Use DenseMap instead of std::map to keep track of SwitchCases.Argyrios Kyrtzidis2012-05-041-2/+2
| | | | | | Part of rdar://11353109. llvm-svn: 156185
* [PCH] Really, pinky swear, fix for PR12689Argyrios Kyrtzidis2012-05-041-2/+5
| | | | | | rdar://11353109 llvm-svn: 156145
* [PCH] Clear switch case IDs when deserializing a objc method body.Argyrios Kyrtzidis2012-05-031-0/+2
| | | | | | Fixes rdar://11353109 & http://llvm.org/bugs/show_bug.cgi?id=12689 llvm-svn: 156056
* Use forward declarations for ASTDeclContextNameLookupTable and add a missing ↵Benjamin Kramer2012-04-151-1/+4
| | | | | | | | delete. It would be nice to use OwningPtr here, but DeclContextInfo is stored in a DenseMap. llvm-svn: 154763
* Serialize and deserialize some missing bits from BlockDecl.John McCall2012-04-131-0/+4
| | | | llvm-svn: 154676
* 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
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* 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
* Teach CXXRecordDecl::hasIrrelevantDestructor to check the base classes andRichard Smith2012-02-251-0/+8
| | | | | | | | | data members for deleted or user-provided destructors. Now it's computed in advance, serialize it, and in passing fix all the other record DefinitionData flags whose serialization was missing. llvm-svn: 151441
* 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
* Improve our handling of lambda expressions that occur within defaultDouglas Gregor2012-02-211-1/+2
| | | | | | | | | | | | | | | | | | | arguments. There are two aspects to this: - Make sure that when marking the declarations referenced in a default argument, we don't try to mark local variables, both because it's a waste of time and because the semantics are wrong: we're not in a place where we could capture these variables again even if it did make sense. - When a lambda expression occurs in a default argument of a function template, make sure that the corresponding closure type is considered dependent, so that it will get properly instantiated. The second bit is a bit of a hack; to fix it properly, we may have to rearchitect our handling of default arguments, parsing them only after creating the function definition. However, I'd like to separate that work from the lambdas work. llvm-svn: 151076
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-0/+1
| | | | | | | | | | | | | | | | default arguments of function parameters. This simple-sounding task is complicated greatly by two issues: (1) Default arguments aren't actually a real context, so we need to maintain extra state within lambda expressions to track when a lambda was actually in a default argument. (2) At the time that we parse a default argument, the FunctionDecl doesn't exist yet, so lambda closure types end up in the enclosing context. It's not clear that we ever want to change that, so instead we introduce the notion of the "effective" context of a declaration for the purposes of name mangling. llvm-svn: 151011
* 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
* Basic support for name mangling of C++11 lambda expressions. BecauseDouglas Gregor2012-02-201-0/+1
| | | | | | | | | | | | | | | name mangling in the Itanium C++ ABI for lambda expressions is so dependent on context, we encode the number used to encode each lambda as part of the lambda closure type, and maintain this value within Sema. Note that there are a several pieces still missing: - We still get the linkage of lambda expressions wrong - We aren't properly numbering or mangling lambda expressions that occur in default function arguments or in data member initializers. - We aren't (de-)serializing the lambda numbering tables llvm-svn: 150982
* 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
* Implement AST (de-)serialization for lambda expressions.Douglas Gregor2012-02-141-1/+27
| | | | llvm-svn: 150491
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [PCH] Add some comments, per Ted's request.Argyrios Kyrtzidis2012-02-091-0/+4
| | | | llvm-svn: 150162
* [PCH] Set the DeclContext before doing any deserialization, to make sure ↵Argyrios Kyrtzidis2012-02-091-0/+4
| | | | | | | | | internal calls to Decl::getASTContext() by Decl's methods will find the TranslationUnitDecl without crashing due to a parent declaration context still deserializing. llvm-svn: 150153
* [PCH] Avoid using Decl::setAttrs() and Decl::setLexicalDeclContext() from ↵Argyrios Kyrtzidis2012-02-091-9/+9
| | | | | | | | | the ASTReaderDecl directly; they internally call Decl::getASTContext() which may crash if a declaration context parent is still deserializing. llvm-svn: 150137
* Reimplement (de-)serialization of Objective-C categories to eliminateDouglas Gregor2012-01-271-115/+136
| | | | | | | | | | | | | | 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-7/+0
| | | | | | Objective-C class. The AST reader just throws away this data anyway! llvm-svn: 149067
* When collecting all of the redeclarations of a declaration loaded fromDouglas Gregor2012-01-171-1/+4
| | | | | | | | a module file, be sure to also add the first (potentially canonical) declarations to the chain. This isn't guaranteed to occur because the first declaration is not listed in the stored redeclaration chain. llvm-svn: 148314
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-3/+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-25/+8
| | | | | | | | | | 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
* When deserializing the definition of a C++ class/ObjC class/ObjCDouglas Gregor2012-01-151-36/+24
| | | | | | | | | | | | | | | protocol, record the definition pointer in the canonical declaration for that entity, and then propagate that definition pointer from the canonical declaration to all other deserialized declarations. This approach works well even when deserializing declarations that didn't know about the original definition, which can occur with modules. A nice bonus from this definition-deserialization approach is that we no longer need update records when a definition is added, because the redeclaration chains ensure that the if any declaration is loaded, the definition will also get loaded. llvm-svn: 148223
* Completely re-implement (de-)serialization of redeclarationDouglas Gregor2012-01-151-80/+54
| | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | 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
* Introduce Decl::getPreviousDecl() and Decl::getMostRecentDecl(),Douglas Gregor2012-01-141-42/+2
| | | | | | | | virtual functions that provide previous/most recent redeclaration information for any declaration. Use this to eliminate the redundant, less efficient getPreviousDecl() functions. llvm-svn: 148184
* Reimplement RedeclarableTemplateDecl in terms ofDouglas Gregor2012-01-141-53/+24
| | | | | | | | | | | 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
* (Implicit) parameters deserialized as part of a function type must notDouglas Gregor2012-01-131-2/+4
| | | | | | | get added to the identifier chains as part of deserialization, because they should not be visible to name lookup. llvm-svn: 148159
* When deserializing an anonymous namespace from a module, do not attachDouglas Gregor2012-01-091-8/+16
| | | | | | | | the anonymous namespace to its parent. Semantically, this means that the anonymous namespaces defined in one module are distinct from the anonymous namespaces defined in another module. llvm-svn: 147782
* Implement merging of namespace-scope declarations across modules, soDouglas Gregor2012-01-091-5/+11
| | | | | | | | | | that we can merge, for example, two occurrences of namespace N { void f(); } in two disjoint modules. llvm-svn: 147780
* Implement redeclaration merging for namespaces defined in distinctDouglas Gregor2012-01-091-3/+20
| | | | | | | | | 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
* 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-18/+28
| | | | | | | | | | | | 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
* During name lookup, use redecl_iterator to walk over the redeclarationDouglas Gregor2012-01-061-2/+5
| | | | | | | | | | | | | chain to determine whether any declaration of the given entity is visible, eliminating the redundant (and less efficient) getPreviousDeclaration() implementation. This tweak uncovered an omission in the handling of RedeclarableTemplateDecl, where we weren't making sure to search for additional redeclarations of a template in other module files. Things would be cleaner if RedeclarableTemplateDecl actually used Redeclarable. llvm-svn: 147687
* Revert r147664; it's breaking clang regression tests.Eli Friedman2012-01-061-2/+2
| | | | llvm-svn: 147681
* Silence GCC warnings.Jakub Staszak2012-01-061-2/+2
| | | | llvm-svn: 147664
* Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bitsDouglas Gregor2012-01-061-4/+4
| | | | | | | | 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
* Introduce a "Hidden" bit into Decl, to track whether that declarationDouglas Gregor2012-01-061-4/+4
| | | | | | | | | | 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
* When we deserialize a declaration from a module file, allocate extraDouglas Gregor2012-01-051-19/+1
| | | | | | | | | | | | | | | storage for the global declaration ID. Declarations that are parsed (rather than deserialized) are unaffected, so the number of declarations that pay this cost tends to be relatively small (since relatively few declarations are ever deserialized). This replaces a largish DenseMap within the AST reader. It's not strictly a win in terms of memory use---not every declaration was added to that DenseMap in the first place---but it's cleaner to have this information available for every deserialized declaration, so that future clients can rely on it. llvm-svn: 147617
* When creating declarations that are deserialized from an module file,Douglas Gregor2012-01-051-101/+53
| | | | | | | go through a central allocation routine Decl::AllocateDeserializedDecl(). No actual functionality change (yet). llvm-svn: 147614
* Implement declaration merging for variables in disjoint modules.Douglas Gregor2012-01-041-1/+16
| | | | llvm-svn: 147535
* Implement declaration merging for non-template functions fromDouglas Gregor2012-01-041-25/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement declaration merging for typedefs loaded from disjointDouglas Gregor2012-01-041-6/+18
| | | | | | | | | | | modules, so long as the typedefs refer to the same underlying type. This ensures that the typedefs end up in the same redeclaration chain. To test this, fix name lookup for C/Objective-C to properly deal with multiple declarations with the same name in the same scope. llvm-svn: 147533
* Implement cross-module declaration merging for tag declarations, soDouglas Gregor2012-01-031-2/+38
| | | | | | | | | | | | that if two modules A and B both contain a declaration of a tag such as struct X; and those two modules are unrelated, the two declarations of X will be merged into a single redeclaration chain. llvm-svn: 147488
* 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
OpenPOWER on IntegriCloud