summaryrefslogtreecommitdiffstats
path: root/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Calling setVisibility directly only makes (some) sense when the visibility isRafael Espindola2012-04-181-3/+3
| | | | | | explicit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154969 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify calls to mergeVisibility* by passing in the LinkageInfo. NoRafael Espindola2012-04-171-3/+2
| | | | | | functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154940 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r154749 for now at John McCall's request.Rafael Espindola2012-04-161-19/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154846 91177308-0d34-0410-b5e6-96231b3b80d8
* Use ordering and the explicit visibility bit instead of modifyingRafael Espindola2012-04-161-44/+36
| | | | | | ConsiderGlobalVisibility. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154843 91177308-0d34-0410-b5e6-96231b3b80d8
* Add another constructor to LVFlags and use it to simplify the code a bit.Rafael Espindola2012-04-161-18/+10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154814 91177308-0d34-0410-b5e6-96231b3b80d8
* Consider visibility attributes last, so that they take precedence.Rafael Espindola2012-04-141-21/+21
| | | | | | I am working on a cleaner fix, but this gets the case in PR12552 passing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154749 91177308-0d34-0410-b5e6-96231b3b80d8
* When we form a new function/class template specialization, we firstDouglas Gregor2012-03-281-16/+1
| | | | | | | | | | | | | search for the specialization (in a folding set) and, if not found form a *Decl that is then inserted into that folding set. In rare cases, the folding set may be reallocated between the search and the insertion, causing a crash. No test case, because triggering rehashing consistently in a small test case is not feasible. Fixes <rdar://problem/11115071>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153575 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a new libclang API to determine the parent context of a codeDouglas Gregor2012-03-271-1/+1
| | | | | | | | | | completion item. For example, if the code completion itself represents a declaration in a namespace (say, std::vector), then this API retrieves the cursor kind and name of the namespace (std). Implements <rdar://problem/11121951>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153545 91177308-0d34-0410-b5e6-96231b3b80d8
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-231-0/+18
| | | | | | | | class template's definition, and for explicit specializations of such enum members. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153304 91177308-0d34-0410-b5e6-96231b3b80d8
* Instantiating a class template should not instantiate the definition of anyRichard Smith2012-03-141-0/+13
| | | | | | | | | scoped enumeration members. Later uses of an enumeration temploid as a nested name specifier should cause its instantiation. Plus some groundwork for explicit specialization of member enumerations of class templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152750 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-22/+22
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* The type of a definition should not increase its visibility. Fixes PR12221.Rafael Espindola2012-03-101-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152493 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] Reduce Decl::getASTContext() calls.Daniel Dunbar2012-03-091-8/+10
| | | | | | | - This function is not at all free; pass it around along some hot paths instead of recomputing it deep inside various VarDecl methods. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152363 91177308-0d34-0410-b5e6-96231b3b80d8
* Untangle getUnderlyingDeclImpl, no functionality change.Benjamin Kramer2012-03-081-9/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152339 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] Change NamedDecl::getUnderlyingDecl() to inline the fast (and ↵Daniel Dunbar2012-03-081-1/+1
| | | | | | incredibly common) path. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152321 91177308-0d34-0410-b5e6-96231b3b80d8
* Loosen the precondition of isCXXInstanceMember() to simply returnDouglas Gregor2012-03-081-3/+3
| | | | | | | "false" for declarations that aren't members of classes. Fixes PR12106. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152284 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] VarDecl::hasDefinition() - Early exit if we find a strong definition.Daniel Dunbar2012-03-061-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152166 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] FunctionDecl::getBuiltinID() - Eliminate spurious calls to getASTContextDaniel Dunbar2012-03-061-2/+5
| | | | | | -- which is very much not free -- in the common case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152165 91177308-0d34-0410-b5e6-96231b3b80d8
* Ensure that we instantiate static reference data members of class templatesRichard Smith2012-03-021-6/+13
| | | | | | | | | | early, since their values can be used in constant expressions in C++11. For odr-use checking, the opposite change is required, since references are odr-used whether or not they satisfy the requirements for appearing in a constant expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151881 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r151638 and r151641.James Molloy2012-02-291-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation. These are now fixed, with regression tests added to catch them both (not Darwin-specific). Original log: ==================== Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. ==================== git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151712 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r151638 because it causes assertion hit on PCH creation for Cocoa.hArgyrios Kyrtzidis2012-02-281-10/+0
| | | | | | | | | | | | | | | | | | | | Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151667 91177308-0d34-0410-b5e6-96231b3b80d8
* Correctly track tags and enum members defined in the prototype of a ↵James Molloy2012-02-281-0/+10
| | | | | | | | | | | | | | | | | function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151638 91177308-0d34-0410-b5e6-96231b3b80d8
* Two fixes to how we compute visibility:Rafael Espindola2012-02-231-19/+25
| | | | | | | | | | | | * Handle some situations where we should never make a decl more visible, even when merging in an explicit visibility. * Handle attributes in members of classes that are explicitly specialized. Thanks Nico for the report and testing, Eric for the initial review, and dgregor for the awesome test27 :-) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151236 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement non-internal linkage for lambda closure types that need aDouglas Gregor2012-02-211-0/+26
| | | | | | | | | | | stable mangling, since these lambdas can end up in multiple translation units. Sema is responsible for deciding when this is the case, because it's already responsible for choosing the mangling number. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151029 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-071-15/+0
| | | | | | | | | | | | | | | | | | operator overloads out of line. This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150006 91177308-0d34-0410-b5e6-96231b3b80d8
* Make FunctionDecl::doesDeclarationForceExternallyVisibleDefinition use the ↵Eli Friedman2012-02-071-26/+68
| | | | | | same logic as FunctionDecl::isInlineDefinitionExternallyVisible to figure out whether to emit a definition. Based on work by Anton Yartsev. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149963 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the result of VarDecl::checkInitIsICE so it is consistently accurate in ↵Eli Friedman2012-02-061-1/+1
| | | | | | C++11 mode. PR11928. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149908 91177308-0d34-0410-b5e6-96231b3b80d8
* Move various diagnostic operator<< overloads out of line and remove includes ↵Benjamin Kramer2012-02-041-0/+15
| | | | | | | | | of Diagnostic.h. Fix all the files that depended on transitive includes of Diagnostic.h. With this patch in place changing a diagnostic no longer requires a full rebuild of the StaticAnalyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149781 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new compiler warning, which flags anti-patterns used as the sizeAnna Zaks2012-02-011-0/+7
| | | | | | | | | | | argument in strncat. The warning is ignored by default since it needs more qualification. TODO: The warning message and the note are messy when strncat is a builtin due to the macro expansion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149524 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-3/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148577 91177308-0d34-0410-b5e6-96231b3b80d8
* Constify FunctionDecl::getmemoryFunctionKind().Anna Zaks2012-01-181-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148369 91177308-0d34-0410-b5e6-96231b3b80d8
* Use Builtin ID as the return valueAnna Zaks2012-01-171-23/+26
| | | | | | | | | | for FunctionDecl::getMemoryFunctionKind(). This is a follow up on the Chris's review for r148142: We don't want to pollute FunctionDecl with an extra enum. (To make this work, added memcmp and family to the library builtins.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148267 91177308-0d34-0410-b5e6-96231b3b80d8
* Change linkage computation so it doesn't depend on FunctionDecl::isExternC ↵Eli Friedman2012-01-151-39/+27
| | | | | | | | | | or VarDecl::isExternC, and instead queries what it actually cares about: whether the given declaration is inside an extern "C" context. Fundamentally, figuring out whether a function/variable uses C linkage requires knowing the linkage, and the logic in FunctionDecl::isExternC and VarDecl::isExternC was getting it wrong. Given that, fix FunctionDecl::isExternC and VarDecl::isExternC to use much simpler implementations that depend on the fixed linkage computation. Fixes a regression to test/SemaCXX/linkage.cpp caused by a new warning exposing the fact that the internal state was wrong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148207 91177308-0d34-0410-b5e6-96231b3b80d8
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-13/+13
| | | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148187 91177308-0d34-0410-b5e6-96231b3b80d8
* constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,Richard Smith2012-01-141-5/+10
| | | | | | | | | | | | | | | | | | | | | APValue::Array and APValue::MemberPointer. All APValue values can now be emitted as constants. Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other entrypoints dealing with constant member pointers are no longer necessary and will be removed in a later change. Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to VarDecl::evaluateValue. This performs caching and deals with the nasty cases in C++11 where a non-const object's initializer can refer indirectly to previously-initialized fields within the same object. Building the intermediate APValue object incurs a measurable performance hit on pathological testcases with huge initializer lists, so we continue to build IR directly from the Expr nodes for array and record types outside of C++11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148178 91177308-0d34-0410-b5e6-96231b3b80d8
* Remember if a type has its visibility set explicitly or implicitly.Rafael Espindola2012-01-141-32/+26
| | | | | | | | With that, centralize the way we merge visibility, always preferring explicit over implicit and then picking the most restrictive one. Fixes pr10113 and pr11690. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148163 91177308-0d34-0410-b5e6-96231b3b80d8
* Move identification of memory setting and copying functions (memset,Anna Zaks2012-01-131-0/+77
| | | | | | | memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic could be reused in the analyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148142 91177308-0d34-0410-b5e6-96231b3b80d8
* When creating declarations that are deserialized from an module file,Douglas Gregor2012-01-051-20/+82
| | | | | | | | go through a central allocation routine Decl::AllocateDeserializedDecl(). No actual functionality change (yet). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147614 91177308-0d34-0410-b5e6-96231b3b80d8
* The value of a const weak variable is not an integer constant.John McCall2012-01-051-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147575 91177308-0d34-0410-b5e6-96231b3b80d8
* Test "merging" of typedef types across distinct modules. At present,Douglas Gregor2012-01-031-0/+6
| | | | | | | | | | | | | the AST reader doesn't actually perform a merge, because name lookup knows how to merge identical typedefs together. As part of this, teach C/Objective-C name lookup to return multiple results in all cases, rather than first digging through the attributes to see if the value is overloadable. This way, we'll catch ambiguous lookups in C/Objective-C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147498 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a non-uglified syntax for module imports in Objective-C:Douglas Gregor2012-01-031-8/+8
| | | | | | | | @import identifier [. identifier]* ; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147452 91177308-0d34-0410-b5e6-96231b3b80d8
* Small cosmetic cleanups in code I will change anyway.Rafael Espindola2012-01-021-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147424 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-1/+0
| | | | | | | ObjCProtocolDecl modules forward declarations properly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147415 91177308-0d34-0410-b5e6-96231b3b80d8
* Consider visibility attributes in namespaces as being explicit. I.e., theyRafael Espindola2012-01-011-1/+1
| | | | | | take precedence over command line options. Fixes PR10113. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147405 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a isa+cast with a dyn_cast.Rafael Espindola2012-01-011-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147401 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the visibility of methods of explicit template instantiation definitionRafael Espindola2011-12-271-0/+1
| | | | | | | | | when using -fvisibility-inlines-hidden. This matches gcc's behavior and documentation. Fixes PR11642. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147295 91177308-0d34-0410-b5e6-96231b3b80d8
* C++11 half of r147023: In C++11, additionally eagerly instantiate:Richard Smith2011-12-211-0/+20
| | | | | | | | | - constexpr function template instantiations - variables of reference type - constexpr variables git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147031 91177308-0d34-0410-b5e6-96231b3b80d8
* Unweaken vtables as per ↵David Blaikie2011-12-201-0/+21
| | | | | | http://llvm.org/docs/CodingStandards.html#ll_virtual_anch git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146959 91177308-0d34-0410-b5e6-96231b3b80d8
* constexpr handling improvements. Produce detailed diagnostics when a 'constexpr'Richard Smith2011-12-191-1/+88
| | | | | | | | | | | | | | | | | | | | | | variable is initialized by a non-constant expression, and pass in the variable being declared so that earlier-initialized fields' values can be used. Rearrange VarDecl init evaluation to make this possible, and in so doing fix a long-standing issue in our C++ constant expression handling, where we would mishandle cases like: extern const int a; const int n = a; const int a = 5; int arr[n]; Here, n is not initialized by a constant expression, so can't be used in an ICE, even though the initialization expression would be an ICE if it appeared later in the TU. This requires computing whether the initializer is an ICE eagerly, and saving that information in PCH files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146856 91177308-0d34-0410-b5e6-96231b3b80d8
* Keep track of all of the import declarations that are parsed orDouglas Gregor2011-12-031-2/+4
| | | | | | | | implicitly generated in a translation unit. Modules will need this information to identify the actual imports that occurred. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145734 91177308-0d34-0410-b5e6-96231b3b80d8