summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
* Implicitly define a lambda's conversion functions (to functionDouglas Gregor2012-02-162-0/+4
| | | | | | | | | | | | | 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-144-3/+107
| | | | llvm-svn: 150491
* Within the body of a lambda expression, decltype((x)) for anDouglas Gregor2012-02-122-2/+5
| | | | | | | | | | | | | | | | id-expression 'x' will compute the type based on the assumption that 'x' will be captured, even if it isn't captured, per C++11 [expr.prim.lambda]p18. There are two related refactors that go into implementing this: 1) Split out the check that determines whether we should capture a particular variable reference, along with the computation of the type of the field, from the actual act of capturing the variable. 2) Always compute the result of decltype() within Sema, rather than AST, because the decltype() computation is now context-sensitive. llvm-svn: 150347
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-112-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Track whether a function type has a trailing return type as type sugar. Use thisRichard Smith2012-02-102-1/+2
| | | | | | | | | | | to pretty-print such function types better, and to fix a case where we were not instantiating templates in lexical order. In passing, move the Variadic bit from Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits. Also ensure that we always substitute the return type of a function when substituting explicitly-specified arguments, since that can cause us to bail out with a SFINAE error before we hit a hard error in parameter substitution. llvm-svn: 150241
* [PCH] Add some comments, per Ted's request.Argyrios Kyrtzidis2012-02-091-0/+4
| | | | llvm-svn: 150162
* Fix ASTReader::FinishedDeserializing().Argyrios Kyrtzidis2012-02-091-18/+14
| | | | | | | | | | | | | | | We were passing a decl to the consumer after all pending deserializations were finished but this was not enough; due to processing by the consumer we may end up into yet another deserialization process but the way FinishedDeserializing() was setup we would not ensure that everything was fully deserialized before returning to the consumer. Separate ASTReader::FinishedDeserializing() into two semantic actions. The first is ensuring that a deserialization process ends up will fully deserialized decls/types even if the process is started by the consumer. The second is pushing "interesting" decls to the consumer; we make sure that we don't re-enter this section recursively be checking a variable. llvm-svn: 150160
* [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
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-072-2/+0
| | | | | | | | | | | | | | | | | | operator overloads out of line. This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. llvm-svn: 150006
* Introduce basic ASTs for lambda expressions. This covers:Douglas Gregor2012-02-072-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | - Capturing variables by-reference and by-copy within a lambda - The representation of lambda captures - The creation of the non-static data members in the lambda class that store the captured variables - The initialization of the non-static data members from the captured variables - Pretty-printing lambda expressions There are a number of FIXMEs, both explicit and implied, including: - Creating a field for a capture of 'this' - Improved diagnostics for initialization failures when capturing variables by copy - Dealing with temporaries created during said initialization - Template instantiation - AST (de-)serialization - Binding and returning the lambda expression; turning it into a proper temporary - Lots and lots of semantic constraints - Parameter pack captures llvm-svn: 149977
* Added source location for the template keyword in ↵Abramo Bagnara2012-02-062-0/+2
| | | | | | | | | | DependentTemplateSpecializationTypeLoc nodes (DTSTLoc). The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp. Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions). llvm-svn: 149923
* Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / ↵Abramo Bagnara2012-02-062-4/+4
| | | | | | DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes. llvm-svn: 149889
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-062-4/+6
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-053-16/+16
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | llvm-svn: 149798
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Remove Diagnostic.h include from Preprocessor.h.Benjamin Kramer2012-02-041-0/+1
| | | | | | | - Move the offending methods out of line and fix transitive includers. - This required changing an enum in the PPCallback API into an unsigned. llvm-svn: 149782
* Move various diagnostic operator<< overloads out of line and remove includes ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | | of Diagnostic.h. Fix all the files that depended on transitive includes of Diagnostic.h. With this patch in place changing a diagnostic no longer requires a full rebuild of the StaticAnalyzer. llvm-svn: 149781
* Thread a TargetInfo through to the module map; we'll need it forDouglas Gregor2012-01-301-1/+2
| | | | | | target-specific module requirements. llvm-svn: 149224
* Introduce module attributes into the module map grammar, along with aDouglas Gregor2012-01-272-4/+8
| | | | | | | | | | | | | single attribute ("system") that allows us to mark a module as being a "system" module. Each of the headers that makes up a system module is considered to be a system header, so that we (for example) suppress warnings there. If a module is being inferred for a framework, and that framework directory is within a system frameworks directory, infer it as a system framework. llvm-svn: 149143
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-272-61/+71
| | | | llvm-svn: 149127
* Reimplement (de-)serialization of Objective-C categories to eliminateDouglas Gregor2012-01-275-172/+232
| | | | | | | | | | | | | | 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-262-13/+0
| | | | | | Objective-C class. The AST reader just throws away this data anyway! llvm-svn: 149067
* Introduce a generation number for selector lookups in the globalDouglas Gregor2012-01-251-4/+16
| | | | | | | method pool, so that we don't perform the same lookups into the same PCH/module file repeatedly. llvm-svn: 148895
* Rework the external Sema source's ReadMethodPool() so that it doesn'tDouglas Gregor2012-01-251-35/+27
| | | | | | | return pre-built lists. Instead, it feeds the methods it deserializes to Sema so that Sema can unique them, which keeps the chains shorter. llvm-svn: 148889
* Only mark an IdentifierInfo as having changed since deserializationDouglas Gregor2012-01-242-5/+15
| | | | | | | | when it actually has changed (and not, e.g., when we've simply attached a deserialized macro definition). Good for ~1.5% reduction in module file size, mostly in the identifier table. llvm-svn: 148808
* Optimize unqualified/global name lookup in modules by introducing aDouglas Gregor2012-01-183-15/+43
| | | | | | | | | | generational scheme for identifiers that avoids searching the hash tables of a given module more than once for a given identifier. Previously, loading any new module invalidated all of the previous lookup results for all identifiers, causing us to perform the lookups repeatedly. llvm-svn: 148412
* Rework the way in which we (de-)serialize the declarationsDouglas Gregor2012-01-172-10/+24
| | | | | | | | | | | | | | | | corresponding to TagType and ObjCInterfaceType. Previously, we would serialize the definition (if available) or the canonical declaration (if no definition was available). However, this can end up forcing the deserialization of the definition even through we might not want to yet. Instead, always serialize the canonical declaration reference in the TagType/ObjCInterfaceType entry, and as part of loading a pending definition, update the "decl" pointer within the type node to point at the definition. This is more robust in hard-to-isolate cases where the *Type gets built and filled in before we see the definition. llvm-svn: 148323
* 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
* Delay the creation of the built-in Objective-C class 'Protocol' byDouglas Gregor2012-01-172-7/+6
| | | | | | | moving it from a "special type" to a predefined declaration, as we do for id, Class, and SEL. llvm-svn: 148313
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-172-18/+5
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-172-4/+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-152-39/+14
| | | | | | | | | | 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-153-98/+25
| | | | | | | | | | | | | | | 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-155-136/+154
| | | | | | | | | | | | | | | | 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-142-11/+11
| | | | | | | | | | | | 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
* 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-143-87/+47
| | | | | | | | | | | 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
* 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
* Add IsImplicit field in ObjCMessageExpr that is true when the messageArgyrios Kyrtzidis2012-01-122-0/+2
| | | | | | | | | | was constructed, e.g. for a property access. This allows the selector identifier locations machinery for ObjCMessageExpr to function correctly, in that there are not real locations to handle/report for such a message. llvm-svn: 148013
* 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-092-10/+55
| | | | | | | | | 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-072-2/+2
| | | | | | 88 -> 80 bytes on x86_64. llvm-svn: 147736
* Switch NamespaceDecl from its own hand-rolled redeclaration chain overDouglas Gregor2012-01-072-24/+31
| | | | | | | | | | | | 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
OpenPOWER on IntegriCloud