summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Convert DeclNodes to use TableGen.Alexis Hunt2010-05-301-49/+61
| | | | | | | | The macros required for DeclNodes use have changed to match the use of StmtNodes. The FooFirst enumerator constants have been named firstFoo to match usage elsewhere. llvm-svn: 105165
* Fixes for compilation with Microsoft Visual Studio 2010, from Steven Watanabe!Douglas Gregor2010-05-111-2/+2
| | | | llvm-svn: 103458
* Recommit my change to how C++ does elaborated type lookups, now withJohn McCall2010-04-231-8/+16
| | | | | | two bugfixes which fix selfhost and (hopefully) the nightly tests. llvm-svn: 102198
* Revert "C++ doesn't really use "namespaces" for different kinds of names the ↵Daniel Dunbar2010-04-231-16/+8
| | | | | | same", which seems to break most C++ nightly test apps. llvm-svn: 102174
* C++ doesn't really use "namespaces" for different kinds of names the sameJohn McCall2010-04-231-8/+16
| | | | | | | | | | | | | way that C does. Among other differences, elaborated type specifiers are defined to skip "non-types", which, as you might imagine, does not include typedefs. Rework our use of IDNS masks to capture the semantics of different kinds of declarations better, and remove most current lookup filters. Removing the last remaining filter is more complicated and will happen in a separate patch. Fixes PR 6885 as well some spectrum of unfiled bugs. llvm-svn: 102164
* Make TemplateDecl and ObjCContainerDecl abstractDouglas Gregor2010-04-221-2/+0
| | | | llvm-svn: 102145
* Kill off IDNS_ObjCImplementation and IDNS_ObjCCategoryName; theyDouglas Gregor2010-04-221-8/+4
| | | | | | | aren't and never were used. There's a gap in the bit pattern for IDNS now, but I'm sure *someone* will fill it. llvm-svn: 102143
* Remove the AST statistics tracking I added yesterday; it didn't pan out.Douglas Gregor2010-03-311-7/+0
| | | | llvm-svn: 100027
* Introduce new AST statistics that keep track of the number of isa (orDouglas Gregor2010-03-301-0/+7
| | | | | | | | | | | | | | | | | | | | | dyn_cast) invocations for C++ and Objective-C types, declarations, expressions, and statements. The statistics will be printed when -print-stats is provided to Clang -cc1, with results such as: 277073 clang - Number of checks for C++ declaration nodes 13311 clang - Number of checks for C++ expression nodes 18 clang - Number of checks for C++ statement nodes 174182 clang - Number of checks for C++ type nodes 92300 clang - Number of checks for Objective-C declaration nodes 9800 clang - Number of checks for Objective-C expression nodes 7 clang - Number of checks for Objective-C statement nodes 65733 clang - Number of checks for Objective-C type nodes The statistics are only gathered when NDEBUG is not defined, since they introduce potentially-expensive operations into very low-level routines (isa). llvm-svn: 99912
* When copying a partial diagnostic into a DependentDiagnostic, allocateDouglas Gregor2010-03-291-13/+6
| | | | | | | | | storage for that partial diagnostic via the ASTContext's BumpPtrAllocator rather than using up slots in the ASTContext's cache. Now that we do this, we don't have to worry about destroying dependent diagnostics when destroying a DependentStoredDeclsMap. llvm-svn: 99854
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-0/+2
| | | | | | | | | | | | | | cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. llvm-svn: 99849
OpenPOWER on IntegriCloud