summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Make sure to put template parameters into their owning template'sDouglas Gregor2011-03-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DeclContext once we've created it. This mirrors what we do for function parameters, where the parameters start out with translation-unit context and then are adopted by the appropriate DeclContext when it is created. Also give template parameters public access and make sure that they don't show up for the purposes of name lookup. Fixes PR9400, a regression introduced by r126920, which implemented substitution of default template arguments provided in template template parameters (C++ core issue 150). How on earth could the DeclContext of a template parameter affect the handling of default template arguments? I'm so glad you asked! The link is Sema::getTemplateInstantiationArgs(), which determines the outer template argument lists that correspond to a given declaration. When we're instantiating a default template argument for a template template parameter within the body of a template definition (not it's instantiation, per core issue 150), we weren't getting any outer template arguments because the context of the template template parameter was the translation unit. Now that the context of the template template parameter is its owning template, we get the template arguments from the injected-class-name of the owning template, so substitution works as it should. llvm-svn: 127004
* Provide a Decl::getNonClosureContext to look through any "closure" (i.e.John McCall2011-02-221-0/+16
| | | | | | block and, eventually, C++ lambda) contexts. llvm-svn: 126252
* Revert all of my commits that devirtualized the Decl hierarchy, whichDouglas Gregor2011-02-191-145/+2
| | | | | | | | lead to a serious slowdown (4%) on parsing of Cocoa.h. This memory optimization should be revisited later, when we have time to look at the generated code. llvm-svn: 126033
* Remove the last virtual member function from the Decl hierarchy,Douglas Gregor2011-02-171-3/+0
| | | | | | | | reducing the size of all declarations by one pointer. For a 64-bit Clang parsing Cocoa.h, this saves ~630k of memory (about 3.5% of ASTContext's memory usage for this header). llvm-svn: 125756
* Devirtualize Decl::getNextRedeclaration().Douglas Gregor2011-02-171-0/+72
| | | | llvm-svn: 125740
* Simple little optimization to Decl::getCanonicalDecl(), eliminating some ↵Douglas Gregor2011-02-171-4/+4
| | | | | | heavyweight machinery and indirection that we don't need llvm-svn: 125737
* Devirtualize Decl::getSourceRange()Douglas Gregor2011-02-171-1/+25
| | | | llvm-svn: 125736
* Devirtualize Decl::getCanonicalDecl().Douglas Gregor2011-02-171-0/+23
| | | | llvm-svn: 125735
* Step #1/N of implementing support for __label__: split labels intoChris Lattner2011-02-171-1/+2
| | | | | | | | | | | | | | | | | | | LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. llvm-svn: 125733
* Devirtualize Decl::getBody() and Decl::hasBody().Douglas Gregor2011-02-171-0/+18
| | | | llvm-svn: 125731
* De-virtualize Decl::isOutOfLine().Douglas Gregor2011-02-171-0/+9
| | | | llvm-svn: 125730
* Add Decl::isParameterPack(), which covers both function and templateDouglas Gregor2011-01-051-0/+7
| | | | | | | | parameter packs, along with ParmVarDecl::isParameterPack(), which looks for function parameter packs. Use these routines to fix some obvious FIXMEs. llvm-svn: 122904
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-051-1/+4
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Add an AST representation for non-type template parameterDouglas Gregor2010-12-231-1/+3
| | | | | | | | | | | | | | 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
* Revert r120808, my previous implementation of caching for the linkageDouglas Gregor2010-12-061-32/+0
| | | | | | | | | and visibility of declarations, because it was extremely messy and it increased the size of NamedDecl. An improved implementation is forthcoming. llvm-svn: 121012
* Implement caching for the linkage and visibility calculations ofDouglas Gregor2010-12-031-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Eliminate two uses of NDEBUG in headers that cause different symbolsDouglas Gregor2010-12-021-2/+2
| | | | | | to be available in debug vs. release builds. llvm-svn: 120629
* Major anonymous union/struct redesign.Francois Pichet2010-11-211-2/+3
| | | | | | | | | | | 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
* Use the ASTMutationListener to track when a named decl gets added to a ↵Argyrios Kyrtzidis2010-10-281-0/+7
| | | | | | | | DeclContext, meaning we need to rewrite its name lookup table in a chained PCH. llvm-svn: 117536
* A couple of tweaks to the visibility rules: John McCall2010-10-261-0/+11
| | | | | | | | | | | - tags with C linkage should ignore visibility=hidden - functions and variables with explicit visibility attributes should ignore the linkage of their types Either of these should be sufficient to fix PR8457. Also, FileCheck-ize a test case. llvm-svn: 117351
* Put the mechanism in place to track modifications in an AST entity that were ↵Argyrios Kyrtzidis2010-10-241-0/+4
| | | | | | | | | | | | 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
* Allow deserialization of just the fields of a record, when we want to ↵Argyrios Kyrtzidis2010-10-141-16/+30
| | | | | | | | | | | | | iterate over them, instead of deserializing the complete declaration context of the record. Iterating over the fields of a record is very common (e.g to determine the layout), unfortunately we needlessly deserialize every declaration that the declaration context of the record contains; this can be bad for large C++ classes that contain a lot of methods. Fix this by allow deserialization of just the fields when we want to iterate over them. Progress for rdar://7260160. llvm-svn: 116507
* Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked aDouglas Gregor2010-10-081-1/+1
| | | | | | bit by me). llvm-svn: 116122
* Centralize the handling ofDouglas Gregor2010-09-271-8/+5
| | | | | | | CXXRecordDecl::DefinitionData::DeclaredCopyAssignment, for copy-assignment operators. Another step toward <rdar://problem/8459981>. llvm-svn: 114899
* Clean up the handling of the DeclaredDefaultConstructor andDouglas Gregor2010-09-271-0/+8
| | | | | | | | | | | | | DeclaredCopyConstructor bits in CXXRecordDecl's DefinitionData structure. Rather than having Sema call addedConstructor or set the bits directly at semi-random places, move all of the logic for managing these bits into CXXRecordDecl itself and tie the addedConstructor call into DeclContext::addDecl(). This makes it easier for AST-building clients to get the right bits set in DefinitionData, and is one small part of <rdar://problem/8459981>. llvm-svn: 114889
* Decl::CheckAccessDeclContext() keeps asserting. Access is not set in some cases.Argyrios Kyrtzidis2010-09-081-4/+9
| | | | llvm-svn: 113419
* Re-enable CheckAccessDeclContext and make sure it doesn't trigger assertions.Argyrios Kyrtzidis2010-09-081-4/+6
| | | | llvm-svn: 113413
* Make inline namespace not be transparent after all. The concept simply ↵Sebastian Redl2010-08-311-10/+13
| | | | | | doesn't fit. Instead, special-case the few places where transparent contexts have the desired behavior for inline namespaces. Fixes a redeclaration issue in inline namespaces. llvm-svn: 112637
* Enable inline namespaces in the AST.Sebastian Redl2010-08-311-1/+1
| | | | llvm-svn: 112564
* Rename DeclContext::getLookupContext to getRedeclContext and change its ↵Sebastian Redl2010-08-311-6/+24
| | | | | | semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them. llvm-svn: 112563
* Decl::getEnclosingNamespaceContext has no reason to explicitly skip ↵Sebastian Redl2010-08-311-1/+1
| | | | | | transparent contexts, and would be wrong to do so with inline namespaces. llvm-svn: 112562
* Fix an issue with writing to PCH another included PCH, introduced by the ↵Argyrios Kyrtzidis2010-08-201-0/+28
| | | | | | | | | | | "using an AST on-disk hash table for name lookup" commit. When including a PCH and later re-emitting to another PCH, the name lookup tables of DeclContexts may be incomplete, since we now lazily deserialize the visible decls of a particular name. Fix the issue by iterating over the un-deserialized visible decls and completing the lookup tables of DeclContexts before writing them out. llvm-svn: 111698
* Use the AST on-disk hash table for name lookup inside a DeclContext.Argyrios Kyrtzidis2010-08-201-91/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | *Huge* improvement over the amount of deserializing that we do for C++ lookup. e.g, if he have the Carbon header precompiled and include it on a file containing this: int x; these are the before/after stats: BEFORE: *** AST File Statistics: 578 stat cache hits 4 stat cache misses 548/30654 source location entries read (1.787695%) 15907/16501 types read (96.400223%) 53525/59955 declarations read (89.275291%) 33993/43525 identifiers read (78.099945%) 41516/51891 statements read (80.006165%) 77/5317 macros read (1.448185%) 0/6335 lexical declcontexts read (0.000000%) 1/5424 visible declcontexts read (0.018437%) AFTER using the on-disk table: *** AST File Statistics: 578 stat cache hits 4 stat cache misses 548/30654 source location entries read (1.787695%) 10/16501 types read (0.060602%) 9/59955 declarations read (0.015011%) 161/43525 identifiers read (0.369902%) 20/51891 statements read (0.038542%) 6/5317 macros read (0.112846%) 0/6335 lexical declcontexts read (0.000000%) 2/5424 visible declcontexts read (0.036873%) There's only one issue affecting mostly the precompiled preambles which I will address soon. llvm-svn: 111636
* Generate Attr subclasses with TableGen.Alexis Hunt2010-08-181-16/+6
| | | | | | | | | | | | | | | | | | | | | | | | Now all classes derived from Attr are generated from TableGen. Additionally, Attr* is no longer its own linked list; SmallVectors or Attr* are used. The accompanying LLVM commit contains the updates to TableGen necessary for this. Some other notes about newly-generated attribute classes: - The constructor arguments are a SourceLocation and a Context&, followed by the attributes arguments in the order that they were defined in Attr.td - Every argument in Attr.td has an appropriate accessor named getFoo, and there are sometimes a few extra ones (such as to get the length of a variadic argument). Additionally, specific_attr_iterator has been introduced, which will iterate over an AttrVec, but only over attributes of a certain type. It can be accessed through either Decl::specific_attr_begin/end or the global functions of the same name. llvm-svn: 111455
* When we are deserializing the lexical decls of a DeclContext from PCH, ↵Argyrios Kyrtzidis2010-07-301-0/+3
| | | | | | | | | | | notify the PCHReader to hold off passing Decls to the consumer until the DeclContext is fully prepared. Before, due to recursive loading, we could be in a situation where we would try to deserialize the decls of a DeclContext which was already doing that, and bad things would happen. In the specific case I encountered, the lexical decls would form a cycle and we would enter infinite loop territory. llvm-svn: 109857
* - Fix recording of offsets of types in dependent PCHs.Sebastian Redl2010-07-271-0/+8
| | | | | | | - Stop reading in (and thus deserializing) every declaration in the TU when creating a dependent PCH. - Switch the storage of a decl context's lexical declarations to a blob containing the IDs instead of a record. This is the only sane way of supporting update records later on. llvm-svn: 109474
* Remove destructors from declaration nodesDouglas Gregor2010-07-251-6/+1
| | | | llvm-svn: 109380
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-43/+1
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Instantiate attributes when first building an instantiatedFariborz Jahanian2010-07-131-12/+0
| | | | | | VarDecl. llvm-svn: 108218
* Copy over attributes to instantiated variable.Fariborz Jahanian2010-07-121-0/+11
| | | | llvm-svn: 108195
* Remove Decl::getCompoundBody().Argyrios Kyrtzidis2010-07-071-4/+0
| | | | | | | | This has 2 (slight) advantages: -Make explicit at getBody()'s callsite that we expect/handle only CompoundStmt and not CXXTryStmt. -Better tracking of Decl::getBody()'s callsites. llvm-svn: 107771
* Simplify code. CompoundStmt's RBraceLoc can be found using its SourceRange too.Argyrios Kyrtzidis2010-07-071-8/+4
| | | | llvm-svn: 107770
* Introduce Decl::hasBody() and FunctionDecl::hasBody() and use them instead ↵Argyrios Kyrtzidis2010-07-071-0/+9
| | | | | | | | of getBody() when we are just checking the existence of a body, to avoid de-serialization of the body from PCH. Makes de-serialization of the function body even more "lazier". llvm-svn: 107768
* When adding a visible decl, deserialize the visible decls and add it.Argyrios Kyrtzidis2010-07-041-9/+10
| | | | | | | | | | Before this commit, visible decls added before deserialization were ignored. This was not an issue since name lookup (that usually comes before the addition) forces deserialization but it is an issue for lazily declared class implicit members. We can use a PCH'ed <string> now. llvm-svn: 107596
* Lazily declare default constructors. We now delay the construction ofDouglas Gregor2010-07-031-0/+6
| | | | | | | | | | | | | | | | | | declarations for implicit default constructors, copy constructors, copy assignment operators, and destructors. On a "simple" translation unit that includes a bunch of C++ standard library headers, we generate relatively few of these implicit declarations now: 4/159 implicit default constructors created 18/236 implicit copy constructors created 70/241 implicit copy assignment operators created 0/173 implicit destructors created And, on this translation unit, this optimization doesn't really provide any benefit. I'll do some more performance measurements soon, but this completes the implementation work for <rdar://problem/8151045>. llvm-svn: 107551
* Disable Decl::CheckAccessDeclContext() temporarily.Argyrios Kyrtzidis2010-07-021-4/+6
| | | | llvm-svn: 107478
* Given Decl::isUsed() a flag indicating when to consider the "used"Douglas Gregor2010-06-171-3/+3
| | | | | | | | | attribute as part of the calculation. Sema::MarkDeclReferenced(), and a few other places, want only to consider the "used" bit to determine, e.g, whether to perform template instantiation. Fixes a linkage issue with Boost.Serialization. llvm-svn: 106252
* Fix PCH issue. Attributes of a declaration were truncated to just one when ↵Argyrios Kyrtzidis2010-06-111-0/+11
| | | | | | the decl was read from a PCH file. llvm-svn: 105852
* Added AccessSpecDecl node.Abramo Bagnara2010-06-051-0/+1
| | | | llvm-svn: 105525
* Alter the ExternalASTSource interface to permit by-name lookups. PCH ↵John McCall2010-06-011-22/+85
| | | | | | | | | | | | | | continues to bring in the entire lookup table at once. Also, give ExternalSemaSource's vtable a home. This is important because otherwise any reference to it will cause RTTI to be emitted, and since clang is compiled with -fno-rtti, that RTTI will contain unresolved references (to ExternalASTSource's RTTI). So this change makes it possible to subclass ExternalSemaSource from projects compiled with RTTI, as long as the subclass's home is compiled with -fno-rtti. llvm-svn: 105268
OpenPOWER on IntegriCloud