summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Redesign the way anonymous fields are handled in designated-initializers.Francois Pichet2010-12-221-11/+0
| | | | | | Previously designated anonymous fields were found via name lookup. This redesign uses the fact that an IndirectFieldDecl declaration will always follow an anonymous implicit field to remove the special case of name lookup. llvm-svn: 122387
* Implement BlockDecl::getSourceRange(). The bogus source-rangeDouglas Gregor2010-12-211-0/+3
| | | | | | | information caused token-annotation to fail in funny ways. Fixes <rdar://problem/8595386>. llvm-svn: 122338
* Apply attributes to explicit specializations. Specializations whichJohn McCall2010-12-181-14/+34
| | | | | | | don't provide their own explicit visibility attributes should get them from the template. Fixes rdar://problem/8778497. llvm-svn: 122136
* Treat visibility on an enclosing namespace as a non-explicit source ofJohn McCall2010-12-101-0/+14
| | | | | | | | | | | visibility. Fixes PR8713. I've disabled a test which was testing that you can #pragma pop visibility to get out of a namespace's visibility attribute. We should probably just diagnose that as an error unless it's instrumental to someone's system headers. llvm-svn: 121459
* When an "inline" declaration was followed by a definition not markedDouglas Gregor2010-12-091-19/+18
| | | | | | | | | | | | | "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
* Cast CachedLinkage to linkage to avoid "comparison between signed and ↵Benjamin Kramer2010-12-071-5/+3
| | | | | | unsigned integer" warnings. llvm-svn: 121143
* Use the unused merge() function, fixing an minor, unintended change IDouglas Gregor2010-12-061-9/+5
| | | | | | introduced in r121023. llvm-svn: 121025
* Re-implement caching for the linkage calculation of declarations.Douglas Gregor2010-12-061-31/+83
| | | | | | | | | | | | | | | | | | | | | | 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-73/+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
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-4/+3
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
* Silence "comparison between signed and unsigned integer expressions" warnings.Benjamin Kramer2010-12-041-4/+4
| | | | llvm-svn: 120897
* Added struct/class syntactic info for c++0x scoped enum.Abramo Bagnara2010-12-031-3/+4
| | | | llvm-svn: 120828
* Implement caching for the linkage and visibility calculations ofDouglas Gregor2010-12-031-2/+73
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix a bunch of IndirectFieldDecl-related warnings.Benjamin Kramer2010-11-211-3/+4
| | | | | | - Negative ChainingSize doesn't make sense, make it unsigned. llvm-svn: 119943
* Major anonymous union/struct redesign.Francois Pichet2010-11-211-1/+7
| | | | | | | | | | | 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
* Remove broken support for variadic templates, along with the variousDouglas Gregor2010-11-071-6/+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
* Put class into an anonymous namespace.Benjamin Kramer2010-11-051-0/+2
| | | | llvm-svn: 118293
* Don't be so eager to replace UsingDecls in a DeclContext's lookup table;Argyrios Kyrtzidis2010-11-041-0/+4
| | | | | | check that the TargetNestedNameDecl is the same first. llvm-svn: 118239
* Unbreak private_extern, which apparently we had zero tests for.John McCall2010-11-021-2/+6
| | | | llvm-svn: 118034
* Ignore attributes on classes when calculating visibility for membersJohn McCall2010-11-021-49/+65
| | | | | | | with their own explicit visibility attributes. Basically we only want to apply a single visibility attribute from any particular ancestry. llvm-svn: 117998
* Only apply -fvisibility-inlines-hidden to definitions. ApparentlyJohn McCall2010-11-011-3/+9
| | | | | | | | isInlined() just gives meaningless results for non-definitions. Fixes rdar://problem/8614470 llvm-svn: 117887
* Better solution: calculate the visibility of functions and variablesJohn McCall2010-10-301-162/+107
| | | | | | | | | | independently of whether they're definitions, then teach IR generation to ignore non-explicit visibility when emitting declarations. Use this to make sure that RTTI, vtables, and VTTs get the right visibility. More of rdar://problem/8613093 llvm-svn: 117781
* GCC faithfully calculates visibility for variables independently ofJohn McCall2010-10-301-23/+19
| | | | | | | | whether it's a declaration or not, then ignores that information for declarations unless it was explicitly given. It's not totally clear how that should be mapped into a sane system, but make an effort. llvm-svn: 117780
* Restore r117644, this time properly ignoring -fvisibility and type visibilityJohn McCall2010-10-291-48/+133
| | | | | | | | | | | | | | | for namespace-scope variable declarations. Apply visibility in IR gen to variables that are merely declared and never defined. We were previously emitting these with default visibility unless they were declared with private_extern. Ignore global visibility settings when computing visibility for a declaration's context, and key several conditions on whether a visibility attribute exists anywhere in the hierarchy as opposed to whether it exists at the current level. llvm-svn: 117729
* Revert r117644, "Apply visibility in IR gen to variables that are merelyDaniel Dunbar2010-10-291-112/+45
| | | | | | declared", it breaks things. llvm-svn: 117653
* Apply visibility in IR gen to variables that are merely declaredJohn McCall2010-10-291-45/+112
| | | | | | | | | | | | and never defined. We were previously emitting these with default visibility unless they were declared with private_extern. Ignore global visibility settings when computing visibility for a declaration's context, and key several conditions on whether a visibility attribute exists anywhere in the hierarchy as opposed to whether it exists at the current level. llvm-svn: 117644
* When computing the visibility of a class member, calculate the visibilityJohn McCall2010-10-291-17/+31
| | | | | | | of its context without considering global settings like -fvisibility=hidden. Fixes PR8492. llvm-svn: 117628
* Don't apply -fvisibility-inlines-hidden to extern templates.John McCall2010-10-281-1/+3
| | | | | | Part 2 of rdar://problem/8595231 llvm-svn: 117567
* Abandon the type-visibility optimization for functions. GCC doesn't do it,John McCall2010-10-281-13/+8
| | | | | | and it's too much trouble to push for. Fixes PR8478. llvm-svn: 117532
* When computing visibility, use the latest declaration's explicit visibilityJohn McCall2010-10-281-8/+26
| | | | | | | | attribute. Part of rdar://problem/8595231 llvm-svn: 117526
* Don't override explicit visibility attributes on class members withJohn McCall2010-10-271-2/+3
| | | | | | type-based visibility. llvm-svn: 117500
* Lazily load the "next" namespace in the chain of NamespaceDecls, toDouglas Gregor2010-10-271-0/+5
| | | | | | eliminate some excessive recursion and deserialization. llvm-svn: 117476
* A couple of tweaks to the visibility rules: John McCall2010-10-261-3/+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
* Start fleshing out ASTMutationListener; notify when a tag definition is ↵Argyrios Kyrtzidis2010-10-241-0/+4
| | | | | | | | | 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
* Substantially revise how clang computes the visibility of a declaration toJohn McCall2010-10-221-126/+264
| | | | | | | | more closely parallel the computation of linkage. This gets us to a state much closer to what gcc emits, modulo bugs, which will undoubtedly arise in abundance. llvm-svn: 117147
* Always treat 'main' as an extern "C" function, so that we detectDouglas Gregor2010-10-211-1/+1
| | | | | | | | | redeclarations of main appropriately rather than allowing it to be overloaded. Also, disallowing declaring main as a template. Fixes GCC DejaGNU g++.old-deja/g++.other/main1.C. llvm-svn: 117029
* Putting back safe fixes 116836,116837,116838Andrew Trick2010-10-191-0/+2
| | | | llvm-svn: 116866
* Reverting 116836,116837,116838 until we resolve the getLangStandardForKind ↵Andrew Trick2010-10-191-2/+0
| | | | | | failures. llvm-svn: 116859
* Minor optimization; if we have a CXXRecordDecl we can get the definition ↵Argyrios Kyrtzidis2010-10-191-0/+2
| | | | | | decl directly without iterating over the redeclarations. llvm-svn: 116837
* Allow deserialization of just the fields of a record, when we want to ↵Argyrios Kyrtzidis2010-10-141-0/+33
| | | | | | | | | | | | | 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-4/+7
| | | | | | bit by me). llvm-svn: 116122
* Teach FunctionDecl::setPure() to (indirectly) mark the Abstract bit inDouglas Gregor2010-09-281-0/+7
| | | | | | CXXRecordDecl::DefinitionData, rather than having Sema mark the bit. llvm-svn: 114993
* Fix C++ PCH issue.Argyrios Kyrtzidis2010-09-091-8/+4
| | | | | | | | | 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
* Fix C++ PCH issues.Argyrios Kyrtzidis2010-09-081-28/+9
| | | | | | | | | | | 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
* Fix the source-range information for an EnumConstantDecl; previously,Douglas Gregor2010-09-011-0/+7
| | | | | | it did not include the initializer expression. llvm-svn: 112739
* Rename DeclContext::getLookupContext to getRedeclContext and change its ↵Sebastian Redl2010-08-311-3/+3
| | | | | | 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
* De-memberify the VarDecl and FunctionDecl StorageClass enums.John McCall2010-08-261-27/+27
| | | | | | This lets us remove Sema.h's dependency on Expr.h and Decl.h. llvm-svn: 112156
* A member function never has "C" linkage. Fixes <rdar://problem/8318976>.Douglas Gregor2010-08-171-0/+3
| | | | llvm-svn: 111238
* Properly give unique-external linkage to members of member templatesJohn McCall2010-08-131-15/+51
| | | | | | instantiated with unique-external parameters. llvm-svn: 111012
* Added locations and type source info for DeclarationName.Abramo Bagnara2010-08-111-4/+3
| | | | llvm-svn: 110860
OpenPOWER on IntegriCloud