summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Cleanup handling of UniqueExternalLinkage.Rafael Espindola2013-05-131-3/+7
| | | | | | | | | | | | | This patch renames getLinkage to getLinkageInternal. Only code that needs to handle UniqueExternalLinkage specially should call this. Linkage, as defined in the c++ standard, is provided by getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage. Most places in the compiler actually want isExternallyVisible, which handles UniqueExternalLinkage as internal. llvm-svn: 181677
* Fix stack overflow in linkage computation when a function with a deduced returnRichard Smith2013-05-121-3/+14
| | | | | | | | | | | | | | | type returns a lambda defined within itself. The computation of linkage for the function looked at the linkage of the lambda, and vice versa. This is solved by not checking whether an 'auto' in a function return type deduces to a type with unique external linkage. We don't need this check, because the type deduced for 'auto' doesn't affect whether two otherwise-identical declarations would name different functions, so we don't need to give an ostensibly external-linkage function internal linkage for this reason. (We also don't need unique-external linkage in C++11 onwards at all, but that's not implemented yet.) llvm-svn: 181675
* Make all 'is in extern "C"' tests use the lexical context.Rafael Espindola2013-05-051-11/+40
| | | | | | | I was not able to find a case (other than the fix in r181163) where this makes a difference, but it is a more obviously correct API to have. llvm-svn: 181165
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-1/+1
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Serialization for captured statementsBen Langmuir2013-05-031-1/+8
| | | | | | | | | | | Add serialization for captured statements and captured decls. Also add a const_capture_iterator to CapturedStmt. Test contributed by Wei Pan Differential Revision: http://llvm-reviews.chandlerc.com/D727 llvm-svn: 181048
* Move CapturedStmt parameters to CapturedDeclBen Langmuir2013-05-031-2/+4
| | | | | | | | | | | Move the creation of CapturedStmt parameters out of CodeGen and into Sema, making it easier to customize the outlined function. The ImplicitParamDecls are stored in the CapturedDecl using an ASTContext-allocated array. Differential Revision: http://llvm-reviews.chandlerc.com/D722 llvm-svn: 181043
* Add r180263 back, but fix hasBraces() to be correct during parsing.Rafael Espindola2013-04-261-6/+11
| | | | | | | | Original commit message: Fix a case in linkage computation that should check for single line extern "C". llvm-svn: 180591
* Revert r180263. It's causing failures.Bill Wendling2013-04-251-11/+6
| | | | llvm-svn: 180583
* Fix a case in linkage computation that should check for single line extern "C".Rafael Espindola2013-04-251-6/+11
| | | | llvm-svn: 180263
* Don't mark 'extern "C" void f(void)' as having extern storage class.Rafael Espindola2013-04-251-7/+10
| | | | | | | | | | Instead, we check for one line extern "C" context in linkage computation and when deciding if a variable is a definition. This hopefully completes the transition to having "as written" semantics for hasExternalStorage. llvm-svn: 180258
* Correct the range returned by ParmVarDecl::getSourceRange(), for parameters ↵Argyrios Kyrtzidis2013-04-171-0/+5
| | | | | | | | | | | | | | in ObjC methods with postfix types. For a parameter in a method like this: -(int)methodWithFn:(void (*)(int *p))fn; we would return the source range of the type and not include the parameter name. Fixes rdar://13668626. llvm-svn: 179660
* Sema for Captured StatementsTareq A. Siraj2013-04-161-0/+4
| | | | | | | | | | | | | Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 llvm-svn: 179618
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-1/+9
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Remove hasExternalLinkageUncached.Rafael Espindola2013-04-151-4/+0
| | | | | | | | It was being used correctly, but it is a very dangerous API to have around. Instead, move the logic from the filtering to when we are deciding if we should link two decls. llvm-svn: 179523
* 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
OpenPOWER on IntegriCloud