summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add hasExternalLinkageUncached back with the test that Richard provided, butRafael Espindola2013-04-041-0/+4
| | | | | | keep the call at the current location. llvm-svn: 178741
* Avoid computing the linkage instead of avoiding caching it.Rafael Espindola2013-04-041-4/+0
| | | | | | | | | | | | | | This mostly reverts 178733, but keeps the tests. I don't claim to understand how hidden sub modules work or when we need to see them (is that documented?), but this has the same semantics and avoids adding hasExternalLinkageUncached which has the same foot gun potential as the old hasExternalLinkage. Last but not least, not computing linkage when it is not needed is more efficient. llvm-svn: 178739
* Fix 41 of the 61 tests which fail with modules enabled: we were computing andRichard Smith2013-04-041-0/+4
| | | | | | | | | caching the linkage for a declaration before we set up its redeclaration chain, when determining whether a declaration could be a redeclaration of something from an unimported submodule. We actually want to look at the declaration as if it were not a redeclaration here, so compute the linkage but don't cache it. llvm-svn: 178733
* Add 178663 back.Rafael Espindola2013-04-031-55/+41
| | | | | | | | | | | http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green before it processed the reverted 178663, so it could not have been the culprit. Revert "Revert 178663." This reverts commit 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41. llvm-svn: 178682
* Revert 178663.Rafael Espindola2013-04-031-41/+55
| | | | | | | | | | Looks like it broke http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb Revert "Don't compute a patched/semantic storage class." This reverts commit 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05. llvm-svn: 178681
* Don't compute a patched/semantic storage class.Rafael Espindola2013-04-031-55/+41
| | | | | | | | | | | For variables and functions clang used to store two storage classes. The one "as written" in the code and a patched one, which, for example, propagates static to the following decls. This apparently is from the days clang lacked linkage computation. It is now redundant and this patch removes it. llvm-svn: 178663
* Avoid computing the linkage too early. Don't invalidate it.Rafael Espindola2013-03-141-44/+30
| | | | | | | | | | | | | | | | | | Before this patch we would compute the linkage lazily and cache it. When the AST was modified in ways that could change the value, we would invalidate the cache. That was fairly brittle, since any code could ask for the a linkage before the correct value was available. We should change the API to one where the linkage is computed explicitly and trying to get it when it is not available asserts. This patch is a first step in that direction. We still compute the linkage lazily, but instead of invalidating a cache, we assert that the AST modifications didn't change the result. llvm-svn: 176999
* Whitespace cleanup.Rafael Espindola2013-03-121-4/+4
| | | | llvm-svn: 176896
* Correctly compute linkage of decls forward declared extern C.Rafael Espindola2013-03-121-2/+1
| | | | | | | | | | | | | | This fixes a crash in namespace { struct X {}; } extern "C" X test2_b; X test2_b before we would assign different linkages to each of the test2_b decls. llvm-svn: 176869
* Add TagDecl::hasNameForLinkage(), which is true if the tagJohn McCall2013-03-091-1/+1
| | | | | | is non-anonymous or is defined in a typedef of itself. llvm-svn: 176742
* Add a hasExternalStorageAsWritten helper. No functionality change.Rafael Espindola2013-03-071-5/+3
| | | | | | | | It is possible that some of the current uses of "getStorageClassAsWritten() == SC_Extern" should use this but I don't know enough about SC_PrivateExtern to change and test them. llvm-svn: 176606
* Rename methods to comply with the LLVM Coding Standards.Rafael Espindola2013-02-271-18/+19
| | | | llvm-svn: 176159
* Change Type::getLinkageAndVisibility to return a LinkageInfo.Rafael Espindola2013-02-271-11/+6
| | | | llvm-svn: 176157
* Move LinkageInfo out of NamedDecl so that it can be used in Type.h.Rafael Espindola2013-02-271-2/+0
| | | | | | | Everything that cares about visibility also cares about linkage, so I just moved it to Visibility.h instead of creating a new .h. llvm-svn: 176155
* Use the most recent decl in getExplicitVisibility.Rafael Espindola2013-02-261-29/+26
| | | | | | | | | | | | | | | | | | | Now that implicitly hidden template arguments can make an instantiation hidden, it is important to look at more than just the canonical decl of the argument in order to see if an attribute is available in a more recent decl. This has the disadvantage of exposing when getExplicitVisibility is called, but lets us handle cases like template <typename T> struct __attribute__((visibility("default"))) barT { static void zed() {} }; class foo; class __attribute__((visibility("default"))) foo; template struct barT<foo>; llvm-svn: 176112
* Add streamed versions of getQualifiedNameAsString.Benjamin Kramer2013-02-231-7/+25
| | | | | | Move the cold virtual method getNameForDiagnostic out of line. llvm-svn: 175966
* [Sema] Semantic analysis for empty-declaration and attribute-declaration.Michael Han2013-02-221-0/+11
| | | | | | | | Introduce a new AST Decl node "EmptyDecl" to model empty-declaration. Have attributes from attribute-declaration appertain to the EmptyDecl node by creating the AST representations of these attributes and attach them to the EmptyDecl node so these attributes can be sema checked just as attributes attached to "normal" declarations. llvm-svn: 175900
* Streamify getNameForDiagnostic and remove the string versions of ↵Benjamin Kramer2013-02-221-15/+10
| | | | | | PrintTemplateArgumentList. llvm-svn: 175894
* Decl.cpp/mergeTemplateLV(): Tweak a description. [-Wdocumentation]NAKAMURA Takumi2013-02-221-1/+1
| | | | llvm-svn: 175859
* Ignore visibility from enclosing template argumentsJohn McCall2013-02-211-57/+141
| | | | | | for explicit member specializations. llvm-svn: 175827
* Use None rather than Optional<T>() where possible.David Blaikie2013-02-211-4/+4
| | | | llvm-svn: 175705
* Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie2013-02-201-21/+17
| | | | | | Post-commit CR feedback from Jordan Rose regarding r175594. llvm-svn: 175679
* Add a new 'type_visibility' attribute to allow users toJohn McCall2013-02-201-62/+165
| | | | | | | | | | | | | | control the visibility of a type for the purposes of RTTI and template argument restrictions independently of how visibility propagates to its non-type member declarations. Also fix r175326 to not ignore template argument visibility on a template explicit instantiation when a member has an explicit attribute but the instantiation does not. The type_visibility work is rdar://11880378 llvm-svn: 175587
* Add support for -fvisibility-ms-compat.John McCall2013-02-191-5/+12
| | | | | | | | | | | | | | | We treat this as an alternative to -fvisibility=<?> which changes the default value visibility to "hidden" and the default type visibility to "default". Expose a -cc1 option for changing the default type visibility, repurposing -fvisibility as the default value visibility option (also setting type visibility from it in the absence of a specific option). rdar://13079314 llvm-svn: 175480
* Rework the visibility computation algorithm in preparationJohn McCall2013-02-161-186/+303
| | | | | | | | | | | | | | | | for distinguishing type vs. value visibility. The changes to the visibility of explicit specializations are intentional. The change to the "ugly" test case is a consequence of a sensible implementation, and I am happy to argue that this is better behavior. Other changes may or may not be intended; it is quite difficult to divine intent from some of the code I altered. I've left behind a comment which I hope explains the philosophy behind visibility computation. llvm-svn: 175326
* Make helper functions static.Benjamin Kramer2013-02-151-2/+1
| | | | llvm-svn: 175265
* merge hasCLanguageLinkage and isExternC. Keep the shorter name.Rafael Espindola2013-02-141-42/+10
| | | | | | | | | | I added hasCLanguageLinkage while fixing some language linkage bugs some time ago so that I wouldn't have to check all users of isExternC. It turned out to be a much longer detour than expected, but this patch finally merges the two again. The isExternC function now implements just the standard notion of having C language linkage. llvm-svn: 175119
* Add a getLanguageLinkage method to VarDecls and FunctionDecls. Use it to fixRafael Espindola2013-02-141-11/+24
| | | | | | | | | | | | | | | some cases where functions with no language linkage were being treated as having C language linkage. In particular, don't warn in extern "C" { static NonPod foo(); } Since getLanguageLinkage checks the language linkage, the linkage computation cannot use the language linkage. Break the loop by checking just the context in the linkage computation. llvm-svn: 175117
* Fix a bug reduced from a crash when trying to use modules with libc++. We checkRichard Smith2013-02-121-4/+1
| | | | | | | | the linkage of functions and variables while merging declarations from modules, and we don't necessarily have enough of the rest of the AST loaded at that point to allow us to compute linkage, so serialize it instead. llvm-svn: 174943
* Ensure that type definitions present in just-loaded modules areDouglas Gregor2013-02-091-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | visible. The basic problem here is that a given translation unit can use forward declarations to form pointers to a given type, say, class X; X *x; and then import a module that includes a definition of X: import XDef; We will then fail when attempting to access a member of X, e.g., x->method() because the AST reader did not know to look for a default of a class named X within the new module. This implementation is a bit of a C-centric hack, because the only definitions that can have this property are enums, structs, unions, Objective-C classes, and Objective-C protocols, and all of those are either visible at the top-level or can't be defined later. Hence, we can use the out-of-date-ness of the name and the identifier-update mechanism to force the update. In C++, we will not be so lucky, and will need a more advanced solution, because the definitions could be in namespaces defined in two different modules, e.g., // module 1 namespace N { struct X; } // module 2 namespace N { struct X { /* ... */ }; } One possible implementation here is for C++ to extend the information associated with each identifier table to include the declaration IDs of any definitions associated with that name, regardless of context. We would have to eagerly load those definitions. llvm-svn: 174794
* Remove unneeded const_castsDmitri Gribenko2013-02-031-4/+2
| | | | llvm-svn: 174287
* Semantic analysis and CodeGen support for C11's _Noreturn. This is modeled asRichard Smith2013-01-301-0/+1
| | | | | | an attribute for consistency with our other noreturn mechanisms. llvm-svn: 173898
* patch for PR9027 and // rdar://11861085Fariborz Jahanian2013-01-251-0/+1
| | | | | | | | | | | Title: [PR9027] volatile struct bug: member is not loaded at -O; This is caused by last flag passed to @llvm.memcpy being false, not honoring that aggregate has at least one 'volatile' data member (even though aggregate itself has not been qualified as 'volatile'. As a result, optimization optimizes away the memcpy altogether. Patch review by John MaCall (I still need to fix up a test though). llvm-svn: 173535
* Clean up: since we have FunctionDecl::IsInline, make it store the right valueRichard Smith2013-01-251-34/+6
| | | | | | | | | | | | for template instantiations, and use it to simplify the implementation of FunctionDecl::isInlined(). This incidentally changes the result of isInlined on a declared-but-not-defined non-inline member function from true to false. This is sort of a bug fix, but currently isInlined is only called on function definitions, so it has no visible effects. llvm-svn: 173397
* Fix a bug in VarDecl::getSourceRange() for static member arrays with an elementNico Weber2013-01-221-1/+3
| | | | | | | | type with an implicit initializer expression. Patch from Will Wilson <will@indefiant.com>! llvm-svn: 173170
* Implement C++11 semantics for [[noreturn]] attribute. This required splittingRichard Smith2013-01-171-0/+5
| | | | | | | | it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as affecting the function type, whereas [[noreturn]] does not). llvm-svn: 172691
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-7/+7
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* commentRafael Espindola2013-01-121-0/+3
| | | | llvm-svn: 172317
* barRafael Espindola2013-01-121-0/+3
| | | | llvm-svn: 172316
* Disable caching of visibility.Rafael Espindola2013-01-121-40/+43
| | | | | | | | | | | | | | The testcase in pr14929 shows that this is extremely hard to do. If we choose to apply the attribute, that causes the visibility of some decls to change and that can happen really late (during codegen). Current gcc warns and ignores the attribute in this testcase with a warning. This suggest that the correct solution is to find a point in the compilation where we can compute the visibility and * assert it was never computed before * reject any attempts to compute it again in the future (with warnings). llvm-svn: 172305
* Handle static functions being redeclared in function scope.Rafael Espindola2013-01-091-0/+4
| | | | | | Fixes pr14861. llvm-svn: 171978
* Assert that redeclarations have the same linkage.Rafael Espindola2013-01-051-3/+28
| | | | | | | It is somewhat hard to test linkage, so I decided to try to add an assert. This already found some interesting cases where there were different. llvm-svn: 171585
* Style fix: We don't use lowercase-and-underscored template parameter names.Rafael Espindola2013-01-041-3/+3
| | | | | | Thanks for dgregor for noticing it. llvm-svn: 171532
* Fix typo. Thanks to dgregor for noticing it.Rafael Espindola2013-01-041-1/+1
| | | | llvm-svn: 171521
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-4/+4
| | | | llvm-svn: 171367
* Don't get confused if a extern "C" builtin function is redeclared withoutRafael Espindola2012-12-301-1/+1
| | | | | | the extern "C". llvm-svn: 171260
* Reject overloading of two static extern C functions.Rafael Espindola2012-12-281-0/+30
| | | | | | | | This patch moves hasCLanguageLinkage to be VarDecl and FunctionDecl methods so that they can be used from SemaOverload.cpp and then fixes the logic in Sema::IsOverload. llvm-svn: 171193
* Add 171048 back but invalidate the cache of all redeclarations when settingRafael Espindola2012-12-251-28/+37
| | | | | | | | | | | | | | | | | | the body of a functions. The problem was that hasBody looks at the entire chain and causes problems to -fvisibility-inlines-hidden if the cache was not invalidated. Original message: Cache visibility of decls. This unifies the linkage and visibility caching. I first implemented this when working on pr13844, but the previous fixes removed the performance advantage of this one. This is still a step in the right direction for making linkage and visibility cheap to use. llvm-svn: 171053
* Revert r171048, "Cache visibility of decls."NAKAMURA Takumi2012-12-251-35/+28
| | | | | | It broke stage2. llvm-svn: 171050
* Cache visibility of decls.Rafael Espindola2012-12-251-28/+35
| | | | | | | | | | | This unifies the linkage and visibility caching. I first implemented this when working on pr13844, but the previous fixes removed the performance advantage of this one. This is still a step in the right direction for making linkage and visibility cheap to use. llvm-svn: 171048
OpenPOWER on IntegriCloud