summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Merge storage classes even when contexts don't match.Rafael Espindola2012-12-181-2/+6
| | | | | | | | This fixes the storage class of extern decls that are merged with file level statics. The patch also fixes the linkage computation so that they are considered internal. llvm-svn: 170406
* Fix isThisDeclarationADefinition for extern following tentative.Rafael Espindola2012-12-171-1/+1
| | | | | | | | An extern declaration following a tentative definition should not itself be considered a tentative definition. Fixes pr14614. llvm-svn: 170377
* Properly compute triviality for explicitly-defaulted or deleted special members.Richard Smith2012-12-081-7/+0
| | | | | | | | | | | | | | Remove pre-standard restriction on explicitly-defaulted copy constructors with 'incorrect' parameter types, and instead just make those special members non-trivial as the standard requires. This required making CXXRecordDecl correctly handle classes which have both a trivial and a non-trivial special member of the same kind. This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the new triviality computation technology. llvm-svn: 169667
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+3
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer2012-12-011-3/+12
| | | | | | | | | pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
* Now that the underlying problem has been fixed, add r168411 back.Rafael Espindola2012-11-291-6/+4
| | | | | | | | Original commit message: Remove redundant code. llvm-svn: 168900
* Revert r168411 for now.Rafael Espindola2012-11-271-4/+6
| | | | llvm-svn: 168667
* Remove redundant code.Rafael Espindola2012-11-211-6/+4
| | | | llvm-svn: 168411
* Remove redundant code.Rafael Espindola2012-11-211-24/+3
| | | | llvm-svn: 168410
* Provide the correct mangling and linkage for certain unnamed nested classes.David Blaikie2012-11-141-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This corrects the mangling and linkage of classes (& their member functions) in cases like this: struct foo { struct { void func() { ... } } x; }; we were accidentally giving this nested unnamed struct 'no' linkage where it should've had the linkage of the outer class. The mangling was incorrecty too, mangling as TU-wide unnamed type mangling of $_X rather than class-scoped mangling of UtX_. This also fixes -Wunused-member-function which would incorrectly diagnose 'func' as unused due to it having no linkage & thus appearing to be TU-local when in fact it might be correctly used in another TU. Similar mangling should be applied to function local classes in similar cases but I've deferred that for a subsequent patch. Review/discussion by Richard Smith, John McCall, & especially Eli Friedman. llvm-svn: 167906
* Remove calls to getMostRecentDecl. The case they were added for in r117526 areRafael Espindola2012-11-121-4/+2
| | | | | | now covered by attribute merging. llvm-svn: 167714
OpenPOWER on IntegriCloud