summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* In the latest episode of "Deserializing bugs caused by accessors" the series ↵Argyrios Kyrtzidis2011-01-031-9/+9
| | | | | | | | | | reached a thrilling climax when FunctionDecl::setPure crashed a poor user's code. Remove the use of this accessor when deserializing, along with several other in the neighborhood. Fixes rdar://8759653. llvm-svn: 122756
* Add an AST representation for non-type template parameterDouglas Gregor2010-12-231-1/+2
| | | | | | | | | | | | | | packs, e.g., template<typename T, unsigned ...Dims> struct multi_array; along with semantic analysis support for finding unexpanded non-type template parameter packs in types, expressions, and so on. Template instantiation involving non-type template parameter packs probably doesn't work yet. That'll come soon. llvm-svn: 122527
* Eliminate the branching in QualType::getTypePtr() by providing aDouglas Gregor2010-12-101-2/+2
| | | | | | | | | | | | | | | | | | | | common base for ExtQuals and Type that stores the underlying type pointer. This results in a 2% performance win for -emit-llvm on a typical C file, with 1% memory growth in the AST. Note that there is an API change in this optimization: QualType::getTypePtr() can no longer be invoked on a NULL QualType. If the QualType might be NULL, use QualType::getTypePtrOrNull(). I've audited all uses of getTypePtr() in the code base and changed the appropriate uses over to getTypePtrOrNull(). A future optimization opportunity would be to distinguish between cast/dyn_cast and cast_or_null/dyn_cast_or_null; for the former, we could use getTypePtr() rather than getTypePtrOrNull(), to take another branch out of the cast/dyn_cast implementation. llvm-svn: 121489
* When an "inline" declaration was followed by a definition not markedDouglas Gregor2010-12-091-1/+2
| | | | | | | | | | | | | "inline", we weren't giving the definition weak linkage because the "inline" bit wasn't propagated. This was a longstanding FIXME that, somehow, hadn't triggered a bug in the wild. Fix this problem by tracking whether any declaration was marked "inline", and clean up the semantics of GNU's "extern inline" semantics calculation based on this change. Fixes <rdar://problem/8740363>. llvm-svn: 121373
* Re-implement caching for the linkage calculation of declarations.Douglas Gregor2010-12-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | My previous attempt at solving the compile-time problem with many redeclarations of the same entity cached both linkage and visibility, while this patch only tackles linkage. There are several reasons for this difference: - Linkage is a language concept, and is evaluated many times during semantic analysis and codegen, while visibility is only a code-generation concept that is evaluated only once per (unique) declaration. Hence, we *must* optimize linkage calculations but don't need to optimize visibility computation. - Once we know the linkage of a declaration, subsequent redeclarations can't change that linkage. Hence, cache invalidation is far simpler than for visibility, where a later redeclaration can completely change the visibility. - We have 3 spare bits in Decl to store the linkage cache, so the cache doesn't increase the size of declarations. With the visibility+linkage cache, NamedDecl got larger. llvm-svn: 121023
* Revert r120808, my previous implementation of caching for the linkageDouglas Gregor2010-12-061-2/+2
| | | | | | | | | and visibility of declarations, because it was extremely messy and it increased the size of NamedDecl. An improved implementation is forthcoming. llvm-svn: 121012
* Added struct/class syntactic info for c++0x scoped enum.Abramo Bagnara2010-12-031-0/+1
| | | | llvm-svn: 120828
* Implement caching for the linkage and visibility calculations ofDouglas Gregor2010-12-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | declarations. The motivation for this patch is that linkage/visibility computations are linear in the number of redeclarations of an entity, and we've run into a case where a single translation unit has > 6500 redeclarations of the same (unused!) external variable. Since each redeclaration involves a linkage check, the resulting quadratic behavior makes Clang slow to a crawl. With this change, a simple test with 512 redeclarations of a variable syntax-checks ~20x faster than before. That said, I hate this change, and will probably end up reverting it in a few hours. Reasons to hate it: - It makes NamedDecl larger, since we don't have enough free bits in Decl to squeeze in the extra information about caching. - There are way too many places where we need to invalidate this cache, because the visibility of a declaration can change due to redeclarations (!). Despite self-hosting and passing the testsuite, I have no confidence that I've found all of places where this cache needs to be invalidated. llvm-svn: 120808
* Major anonymous union/struct redesign.Francois Pichet2010-11-211-0/+16
| | | | | | | | | | | A new AST node is introduced: def IndirectField : DDecl<Value>; IndirectFields are injected into the anonymous's parent scope and chain back to the original field. Name lookup for anonymous entities now result in an IndirectFieldDecl instead of a FieldDecl. There is no functionality change, the code generated should be the same. llvm-svn: 119919
* For an Objective-C @synthesize statement, e.g.,Douglas Gregor2010-11-171-3/+5
| | | | | | | | | @synthesize foo = _foo; keep track of the location of the ivar ("_foo"). Teach libclang to visit the ivar as a member reference. llvm-svn: 119447
* Replace UsingDecl's SmallPtrSet of UsingShadowDecls with a linked list to ↵Argyrios Kyrtzidis2010-11-101-11/+2
| | | | | | | | avoid leaking memory. Fixes rdar://8649963. llvm-svn: 118674
* Remove broken support for variadic templates, along with the variousDouglas Gregor2010-11-071-3/+5
| | | | | | | | | | | | | abstractions (e.g., TemplateArgumentListBuilder) that were designed to support variadic templates. Only a few remnants of variadic templates remain, in the parser (parsing template type parameter packs), AST (template type parameter pack bits and TemplateArgument::Pack), and Sema; these are expected to be used in a future implementation of variadic templates. But don't get too excited about that happening now. llvm-svn: 118385
* Make the deserialization of C++ base class specifiers lazy, improvingDouglas Gregor2010-10-291-14/+8
| | | | | | the performance of C++ PCH and reducing stack depth in the reader. llvm-svn: 117732
* Remove an assertion that hit on legitimate cases. A redeclaration may have ↵Argyrios Kyrtzidis2010-10-281-6/+0
| | | | | | | | location before the first one if the redeclaration comes from a friend decl. llvm-svn: 117537
* Use the ASTMutationListener to track added template specializations in a ↵Argyrios Kyrtzidis2010-10-281-14/+4
| | | | | | chained PCH. llvm-svn: 117533
* Make AST deserialization for class template specializations lazier, byDouglas Gregor2010-10-271-16/+31
| | | | | | | not loading the specializations of a class template until some AST consumer needs them. llvm-svn: 117498
* Lazily load the next friend in the chain of FriendDecls, to eliminateDouglas Gregor2010-10-271-1/+1
| | | | | | some excessive recursion and deserialization. llvm-svn: 117480
* Lazily load the "next" namespace in the chain of NamespaceDecls, toDouglas Gregor2010-10-271-4/+3
| | | | | | eliminate some excessive recursion and deserialization. llvm-svn: 117476
* Keep track in chained PCH of implicit members that were added after the ↵Argyrios Kyrtzidis2010-10-241-0/+4
| | | | | | definition was completed. llvm-svn: 117240
* Start fleshing out ASTMutationListener; notify when a tag definition is ↵Argyrios Kyrtzidis2010-10-241-1/+13
| | | | | | | | | completed. In that case a chained PCH will record the updates to the DefinitionData pointer of forward references. If a forward reference mutated into a definition re-write it into the chained PCH, this is too big of a change. llvm-svn: 117239
* Refactoring.Argyrios Kyrtzidis2010-10-241-8/+23
| | | | | | | - Pass around RecordDataImpl instead of the concrete RecordData so that any SmallVector can be used. - Move ASTDeclWriter::WriteCXXDefinitionData to ASTWriter::AddCXXDefinitionData. llvm-svn: 117236
* Put the mechanism in place to track modifications in an AST entity that were ↵Argyrios Kyrtzidis2010-10-241-0/+29
| | | | | | | | | | | | committed after its initial creation/deserialization and store the changes in a chained PCH. The idea is that the AST entities call methods on the ASTMutationListener to give notifications of changes; the PCHWriter implements the ASTMutationListener interface and stores the incremental changes of the updated entity. WIP llvm-svn: 117235
* Simplify and "robust-ify" the way that CXXRecord references point to the ↵Argyrios Kyrtzidis2010-10-241-40/+27
| | | | | | | | definition data when loaded from PCH. Temporary disable 'test/PCH/chain-cxx.cpp' until a better way to fix it is in place. llvm-svn: 117234
* Minor refactoring; Pull reading/writing DefinitionData out into a function.Argyrios Kyrtzidis2010-10-241-49/+54
| | | | llvm-svn: 117233
* Modify the assumptions of an assert; the updated latest redeclaration can ↵Argyrios Kyrtzidis2010-10-201-6/+6
| | | | | | | | have the same location if it's a template specialization pointing at the template. llvm-svn: 116974
* Minor optimization; Try to iterator over redeclarations only when necessary.Argyrios Kyrtzidis2010-10-201-9/+8
| | | | llvm-svn: 116930
* Fix issue with chained PCH where forward references did not pick up later ↵Argyrios Kyrtzidis2010-10-201-0/+18
| | | | | | definition in the chained PCH. llvm-svn: 116887
* Read/write declaration attributes from/to PCH properly. Embed them in the ↵Argyrios Kyrtzidis2010-10-181-16/+5
| | | | | | | | | declaration block instead of trying to create another block. The new block was messing with the assumption that after decls block comes the stmts block. Fixes http://llvm.org/PR8406 llvm-svn: 116737
* White-listing templated-scope friend decls is a good idea, but doing itJohn McCall2010-10-161-0/+1
| | | | | | | | by marking the decl invalid isn't. Make some steps towards supporting these and then hastily shut them down at the last second by marking them as unsupported. llvm-svn: 116661
* Read/write to/from PCH DeclarationNameLocs, DeclarationNameInfos and ↵Argyrios Kyrtzidis2010-10-151-10/+30
| | | | | | QualifierInfos (rdar://8513756). llvm-svn: 116598
* Store in PCH the key function of C++ class to avoid deserializing the ↵Argyrios Kyrtzidis2010-10-141-0/+9
| | | | | | | | complete declaration context in order to compute it. Progress for rdar://7260160. llvm-svn: 116508
* Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked aDouglas Gregor2010-10-081-1/+6
| | | | | | bit by me). llvm-svn: 116122
* Serialize the "inline" bit for namespaces. Fixes <rdar://problem/8515069>.Douglas Gregor2010-10-051-0/+1
| | | | llvm-svn: 115667
* Give every file that ASTReader loads a type: module, PCH, precompiled ↵Sebastian Redl2010-10-051-1/+1
| | | | | | preamble or main file. Base Decls' PCHLevel on this to make it more sane. llvm-svn: 115626
* Thread PerFileData through the ASTReader again, this time with the LLVM changes.Sebastian Redl2010-10-051-98/+110
| | | | llvm-svn: 115625
* Revert r115336 ("Thread PerFileData through everything."), becauseDouglas Gregor2010-10-011-110/+98
| | | | | | we're missing the corresponding changes in the LLVM repository. llvm-svn: 115340
* Thread PerFileData through everything. This allows us to remap stuff later.Sebastian Redl2010-10-011-98/+110
| | | | llvm-svn: 115336
* Kill FunctionDecl's IsCopyAssignment bit; it duplicated what couldDouglas Gregor2010-09-271-1/+0
| | | | | | | | already be determined by isCopyAssignmentOperator(), and was set too late in the process for all clients to see the appropriate value. Cleanup only; no functionality change. llvm-svn: 114916
* Fix C++ PCH issue.Argyrios Kyrtzidis2010-09-131-3/+7
| | | | | | | | The canonical FunctionTemplateDecl contains the specializations but we cannot use getCanonicalDecl on Template because it may still be initializing. Write and read it from PCH. Fixes http://llvm.org/PR8134 llvm-svn: 113744
* Avoid setters in ASTDeclReader::VisitClassTemplatePartialSpecializationDecl.Argyrios Kyrtzidis2010-09-131-11/+13
| | | | llvm-svn: 113743
* Avoid setters in ASTDeclReader::VisitClassTemplateSpecializationDecl.Argyrios Kyrtzidis2010-09-131-12/+21
| | | | llvm-svn: 113742
* Avoid setters in ASTDeclReader::VisitCXXRecordDecl.Argyrios Kyrtzidis2010-09-131-4/+5
| | | | llvm-svn: 113741
* Fix C++ PCH issue.Argyrios Kyrtzidis2010-09-091-14/+21
| | | | | | | | | Another beating by boost in this test case: http://llvm.org/PR8117 A function specialization wasn't properly initialized if it wasn't canonical. I wish there was a nice little test case but this was boost. llvm-svn: 113481
* Re-enable CheckAccessDeclContext and make sure it doesn't trigger assertions.Argyrios Kyrtzidis2010-09-081-2/+1
| | | | llvm-svn: 113413
* Fix C++ PCH issues.Argyrios Kyrtzidis2010-09-081-13/+32
| | | | | | | | | | | PCH got a severe beating by the boost-using test case reported here: http://llvm.org/PR8099 Fix issues like: -When PCH reading, make sure Decl's getASTContext() doesn't get called since a Decl in the parent hierarchy may be initializing. -In ASTDeclReader::VisitFunctionDecl VisitRedeclarable should be called before using FunctionDecl's isCanonicalDecl() -In ASTDeclReader::VisitRedeclarableTemplateDecl CommonOrPrev must be initialized before anything else. llvm-svn: 113391
* Implement libclang support for using declarations. Clang actually usesDouglas Gregor2010-09-011-4/+4
| | | | | | | | | | | | | | | | three different kinds of AST nodes to represent using declarations: UsingDecl, UnresolvedUsingValueDecl, and UnresolvedUsingTypenameDecl. These three are collapsed into a single cursor kind for using declarations, since libclang clients don't need the distinction. Several related changes here: - Cursor visitation of the three AST nodes for using declarations - Proper source-range computation for these AST nodes - Using declarations have no USRs, since they don't actually declare any entities. llvm-svn: 112730
* Implement libclang support for using directives (cursor + visitation +Douglas Gregor2010-09-011-7/+6
| | | | | | | | suppressing USRs). Also, fix up the source location information for using directives so that the declaration location refers to the namespace name. llvm-svn: 112693
* Split ObjCInterfaceDecl::ReferencedProtocols into two lists: ↵Ted Kremenek2010-09-011-0/+13
| | | | | | | | | | | | | ReferencedProtocols and AllReferencedProtocols. ReferencedProtocols (and thus protocol_begin(), protocol_end()) now only contains the list of protocols that were directly referenced in an @interface declaration. 'all_referenced_protocol_[begin,end]()' now returns the set of protocols that were referenced in both the @interface and class extensions. The latter is needed for semantic analysis/codegen, while the former is needed to maintain the lexical information of the original source. Fixes <rdar://problem/8380046>. llvm-svn: 112691
* Improve location information in the representation of namespaceDouglas Gregor2010-09-011-4/+3
| | | | | | | | | | | | | | | | aliases. Previously, the location of the alias was at the "namespace" keyword. Now, it's on the identifier being declared (as is the custom for Clang), and we keep a separate source location for the "namespace" keyword. Also, added a getSourceRange() member function to NamespaceAliasDecl to correctly compute the source range. Finally, removed a bunch of setters from NamespaceAliasDecl and gave ASTReaderDecl friendship so that it could set the corresponding fields directly. llvm-svn: 112681
* De-memberify the VarDecl and FunctionDecl StorageClass enums.John McCall2010-08-261-6/+6
| | | | | | This lets us remove Sema.h's dependency on Expr.h and Decl.h. llvm-svn: 112156
OpenPOWER on IntegriCloud