summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [C++11] Replacing iterators attr_begin() and attr_end() with iterator_range ↵Aaron Ballman2014-03-071-9/+6
| | | | | | attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203236
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-6/+3
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. llvm-svn: 203179
* Tests for DR370-380.Richard Smith2014-03-051-2/+2
| | | | | | | Also promote a couple of Warnings on ill-formed code found by this testing to ExtWarns. llvm-svn: 203021
* AST: Remove layering violation with SemaDavid Majnemer2014-03-051-4/+8
| | | | | | Scope lives in Sema and cannot be used in AST. Shuffle things around. llvm-svn: 202993
* [-cxx-abi microsoft] Implement local manglings accuratelyDavid Majnemer2014-03-051-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVC ABI appears to mangle the lexical scope into the names of statics. Specifically, a counter is incremented whenever a scope is entered where things can be declared in such a way that an ambiguity can arise. For example, a class scope inside of a class scope doesn't do anything interesting because the nested class cannot collide with another nested class. There are problems with this scheme: - It is unreliable. The counter is only incremented when a previously never encountered scope is entered. There are cases where this will cause ambiguity amongst declarations that have the same name where one was introduced in a deep scope while the other was introduced right after in the previous lexical scope. - It is wasteful. Statements like: {{{{{{{ static int foo = a; }}}}}}} will make the mangling of "foo" larger than it need be because the scope counter has been incremented many times. Because of these problems, and practical implementation concerns. We choose not to implement this scheme if the local static or local type isn't visible. The mangling of these declarations will look very similar but the numbering will make far more sense, this scheme is lifted from the Itanium ABI implementation. Reviewers: rsmith, doug.gregor, rnk, eli.friedman, cdavis5x Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2953 llvm-svn: 202951
* Add [extern_c] attribute for modules, allowing a C module to be imported ↵Richard Smith2014-03-021-1/+35
| | | | | | within an extern "C" block in C++ code. llvm-svn: 202615
* argument -> parameter terminology fixes for FunctionTypeInfoAlp Toker2014-02-261-20/+19
| | | | | | This is a continuation of r199686. llvm-svn: 202307
* Sema: Definition of dllimport globals is not allowedNico Rieck2014-02-261-0/+7
| | | | | | | Upgrades the warning to an error and clarifies the message by treating the definition as error instead of the attribute. llvm-svn: 202300
* [Win32 ABI] Defer operator delete checks until vtable is marked usedHans Wennborg2014-02-241-9/+0
| | | | | | | | | | We were previously checking at every destructor declaration, but that was a bit excessive. Since the deleting destructor is emitted with the vtable, do the check when the vtable is marked used. Differential Revision: http://llvm-reviews.chandlerc.com/D2851 llvm-svn: 202046
* Do not add enums to prototype scope in C++ modes.Peter Collingbourne2014-02-221-23/+7
| | | | | | | | | | | | | | The language forbids defining enums in prototypes, so this check is normally redundant, but if an enum is defined during template instantiation it should not be added to the prototype scope. While at it, clean up the code that deals with tag definitions in prototype scope and expand the visibility warning to cover the case where an anonymous enum is defined. Differential Revision: http://llvm-reviews.chandlerc.com/D2742 llvm-svn: 201927
* OpenCL: fix for the restriction on pointers to functions.Pekka Jaaskelainen2014-02-201-6/+19
| | | | | | Patch from Anastasia Stulova! llvm-svn: 201788
* Implement DR577David Majnemer2014-02-191-17/+0
| | | | | | | | DR18 previously forebode typedefs to be used as parameter types if they were of type 'void'. DR577 allows 'void' to be used as a function parameter type regardless from where it came. llvm-svn: 201631
* Enable correcting a member declaration where the type is class template,Kaelyn Uhrain2014-02-131-9/+15
| | | | | | | | | and the class name is shadowed by another member. Recovery still needs to be figured out, which is non-trivial since the parser has already gone down a much different path than if it had recognized the class template as type instead of seeing the member that shadowed the class template. llvm-svn: 201360
* MS ABI: Add support for #pragma pointers_to_membersDavid Majnemer2014-02-101-2/+3
| | | | | | | | | | | | | | | | | | | Introduce a notion of a 'current representation method' for pointers-to-members. When starting out, this is set to 'best case' (representation method is chosen by examining the class, selecting the smallest representation that would work given the class definition or lack thereof). This pragma allows the translation unit to dictate exactly what representation to use, similar to how the inheritance model keywords operate. N.B. PCH support is forthcoming. Differential Revision: http://llvm-reviews.chandlerc.com/D2723 llvm-svn: 201105
* Clarify comment. Remove braces from single-statement block.David Blaikie2014-02-091-4/+4
| | | | llvm-svn: 201040
* MS ABI: Don't be so hasty to judge an inheritance modelDavid Majnemer2014-02-071-1/+1
| | | | | | | | If we are in the middle of defining the class, don't attempt to validate previously annotated declarations. We may not have seen base specifiers or virtual method declarations yet. llvm-svn: 200959
* DR101, PR12770: If a function is declared in the same context as aRichard Smith2014-02-061-12/+28
| | | | | | | | using-declaration, and they declare the same function (either because the using-declaration is in the same namespace as the declaration it imports, or because they're both extern "C"), they do not conflict. llvm-svn: 200897
* Add implicit declarations of allocation functions when looking them up forRichard Smith2014-02-041-13/+16
| | | | | | | | redeclaration, not just when looking them up for a use -- we need the implicit declaration to appropriately check various properties of them (notably, whether they're deleted). llvm-svn: 200729
* Diagnose typedef names for linkage purposes that would changeJohn McCall2014-01-301-0/+21
| | | | | | | | | | | | | | a previously-computed linkage as an unsupportable error condition. Per discussion on cfe-commits, this appears to be a difficult-to-resolve flaw in our implementation approach; we may pursue this as a language defect, but for now it's better to diagnose it as unsupported than to produce inconsistent results (or assertions). Anything that we can do to limit how often this diagnostic fires, such as the changes in r200380, is probably for the best, though. llvm-svn: 200438
* Sema: Diagnose improper application of inheritance keywordsDavid Majnemer2014-01-291-1/+10
| | | | | | | | | | | We would previously allow inappropriate inheritance keywords to appear on class declarations. We would also allow inheritance keywords on templates which were not fully specialized; this was divergent from MSVC. Differential Revision: http://llvm-reviews.chandlerc.com/D2585 llvm-svn: 200423
* Short-circuit a couple of queries (and avoid corruptingJohn McCall2014-01-291-1/+7
| | | | | | | | | | | | | | the linkage cache) when type-checking static local variables. There's a very deep problem here where the linkage of a declaration can suddenly massively change as soon as it's given a typedef name; these fixes, while optimizations in their own right, are really just targeted workarounds. rdar://15928125 llvm-svn: 200380
* Rename getResultLoc() tooAlp Toker2014-01-251-2/+2
| | | | | | | | Follow up to r200082. Spotted by Dmitri llvm-svn: 200105
* PR18530: Don't assert when performing error recovery after a missing ↵Richard Smith2014-01-251-12/+7
| | | | | | 'template<>' on a variable template explicit specialization. llvm-svn: 200099
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-47/+48
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Allow clang to compile the "extern" storage class in OpenCL 1.2. Pekka Jaaskelainen2014-01-231-1/+1
| | | | | | Patch from Fraser Cormack! llvm-svn: 199906
* Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker2014-01-221-36/+14
| | | | | | | | | | | | | | Lift the getFunctionDecl() utility out of the parser into a general Decl::getAsFunction() and use it to simplify other parts of the implementation. Reduce isFunctionOrFunctionTemplate() to a simple type check that works the same was as the other is* functions and move unwrapping of shadowed decls to callers so it doesn't get run twice. Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer. There's no need to query when we already know the body can't be skipped. llvm-svn: 199794
* Enforce restrictions that 'main' is not allowed to be deleted, or to be used byRichard Smith2014-01-221-2/+5
| | | | | | | | the program, in C++. (We allow the latter as an extension, since we've always permitted it, and GCC does the same, and our supported C++ ABIs don't do anything special in main.) llvm-svn: 199782
* Delay attribute checking until auto types are deducedNico Rieck2014-01-211-1/+6
| | | | | | | | | Checking in ActOnVariableDeclarator computes and caches the linkage using the non-deduced auto type which defaults to external linkage. Depending on how the auto type is deduced linkage can change and conflict with the cached linkage, hitting asserts. llvm-svn: 199774
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-20/+19
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Exposed a declarative way to specify that an attribute can be duplicated ↵Aaron Ballman2014-01-201-29/+2
| | | | | | when merging attributes on a declaration. This replaces some hard-coded functionality from Sema. llvm-svn: 199677
* Restrict redeclaration of tags introduced by using decls to MSVCCompatAlp Toker2014-01-181-2/+3
| | | | | | | This limits the facility added in r199490 while we seek clarification on the standard. llvm-svn: 199531
* Permit redeclaration of tags introduced by using declsAlp Toker2014-01-171-2/+3
| | | | | | | This valid construct appears in MSVC headers where it's used to provide a definition for the '::type_info' compiler builtin type. llvm-svn: 199490
* Clean up variable template handling a bit, and correct the behavior of nameRichard Smith2014-01-161-117/+84
| | | | | | lookup when declaring a variable template specialization. llvm-svn: 199438
* Distinguish between attributes explicitly written at the request of the ↵Aaron Ballman2014-01-161-27/+31
| | | | | | | | user, and attributes implicitly generated to assist in bookkeeping by the compiler. This is done so by table generating a CreateImplicit method for each attribute. Additionally, remove the optional nature of the spelling list index when creating attributes. This is supported by table generating a Spelling enumeration when the spellings for an attribute are distinct enough to warrant it. llvm-svn: 199378
* Fix for PR9812: warn about bool instead of _Bool.Erik Verbruggen2014-01-151-7/+9
| | | | llvm-svn: 199311
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* Fix "regression" caused by updating our notion of POD to better match the C++11Richard Smith2014-01-111-3/+8
| | | | | | | | rules: instead of requiring flexible array members to be POD, require them to be trivially-destructible. This seems to be the only constraint that actually matters here (and even then, it's questionable whether this matters). llvm-svn: 198983
* Have attribute 'objc_precise_lifetime' suppress -Wunused.Ted Kremenek2014-01-091-1/+2
| | | | | | | | | | Fixes <rdar://problem/15596883> In ARC, __attribute__((objc_precise_lifetime)) guarantees that the object stored in it will survive to the end of the variable's formal lifetime. It is therefore useful even if it completely unused. llvm-svn: 198888
* PR18400: ignore cv-qualifiers on the underlying type of an enumeration.Richard Smith2014-01-081-1/+1
| | | | llvm-svn: 198723
* PR18234: Mark a tag definition as invalid early if it appears in aRichard Smith2014-01-081-1/+13
| | | | | | | | type-specifier in C++. Some checks will assert in this case otherwise (in particular, the access specifier may be missing if this happens inside a class definition, due to a violation of an AST invariant). llvm-svn: 198721
* Highlight the previous underlying enum type when diagnosing a mismatchAlp Toker2014-01-061-1/+3
| | | | | | | | | | | | | | enum-scoped.cpp:93:6: error: enumeration redeclared with different underlying type 'short' (was 'int') enum Redeclare6 : short; ^ enum-scoped.cpp:92:6: note: previous declaration is here enum Redeclare6 : int; ^ ~~~ The redeclaration source range is still missing but this is a step forward, potentially edging towards a FixIt. llvm-svn: 198601
* Diagnose enum redeclarations properlyAlp Toker2014-01-061-3/+3
| | | | | | | | | | | | | | | | | | In all three checks, the note indicates a previous declaration and never a 'use'. Before: enum-scoped.cpp:92:6: note: previous use is here enum Redeclare6 : int; ^ After: enum-scoped.cpp:92:6: note: previous declaration is here enum Redeclare6 : int; ^ llvm-svn: 198600
* [OpenCL] Produce an error if an address space is used on the returnJoey Gouly2014-01-061-0/+13
| | | | | | type of a function. llvm-svn: 198597
* Fix 'declartion' typosAlp Toker2014-01-051-2/+2
| | | | llvm-svn: 198549
* [objc] Refactor and improve functionality for the -Wunused-property-ivar ↵Argyrios Kyrtzidis2014-01-031-1/+0
| | | | | | | | | | | | | | warning. - Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor - Don't check immediately after the method body is finished, check when the @implementation is finished. This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor. - Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self. rdar://15727325 llvm-svn: 198432
* Removing an unneeded typecast. getScopeRep() already returns a ↵Aaron Ballman2014-01-031-1/+1
| | | | | | NestedNameSpecifier. llvm-svn: 198419
* [OpenCL] Variables in the constant address space must be initialized.Joey Gouly2014-01-031-0/+10
| | | | llvm-svn: 198417
* It turns out the problem was a bit more wide-spread. Removing a lot of ↵Aaron Ballman2014-01-031-1/+1
| | | | | | | | unneeded typecasts. getScopeRep() already returns a NestedNameSpecifier. No functional changes intended. llvm-svn: 198414
* Removing some more unnecessary manual quotes from diagnostics. Updated the ↵Aaron Ballman2014-01-031-1/+1
| | | | | | related test case to ensure correctness. llvm-svn: 198412
* Removing some more unnecessary manual quotes from diagnostics.Aaron Ballman2014-01-031-2/+2
| | | | llvm-svn: 198395
OpenPOWER on IntegriCloud