summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Adds Microsoft compatiable C++ record layout code to clang.Warren Hunt2013-10-111-2/+1
| | | | llvm-svn: 192494
* -Wmicrosoft: Don't warn on non-inline pure virtual method definitionsReid Kleckner2013-10-081-1/+1
| | | | | | | | | | | | | | | MSVC and clang with -fms-extensions allow pure virtual methods to be defined inline after the "= 0" tokens. Clang warns on these because it is not standard, but incorrectly warns on out-of-line definitions, which are standard. With this change, clang will only warn on inline definitions of pure virtual methods. Fixes some self-host warnings on out-of-line definitions of pure virtual destructors. llvm-svn: 192244
* Remove transient code I did not mean to check in.Ted Kremenek2013-10-081-12/+0
| | | | llvm-svn: 192211
* Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a ↵Ted Kremenek2013-10-081-8/+17
| | | | | | holdover from the long-dead Action interface. llvm-svn: 192203
* [ms-cxxabi] Fix the calling convention for operator new in recordsReid Kleckner2013-10-081-4/+2
| | | | | | | | | | | | | | | | | | Summary: Operator new, new[], delete, and delete[] are all implicitly static when declared inside a record. CXXMethodDecl already knows this, but we need to account for that before we pick the calling convention for the function type. Fixes PR17371. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1761 llvm-svn: 192150
* Sema: Only merge typedef attributes if the previous decl is a typedefJustin Bogner2013-10-081-5/+5
| | | | | | | | | | | | In r186373, we started merging attributes on typedefs, but this causes us to try to merge attributes even if the previous declaration was not a typedef. Only merge the attributes if the previous decl was also a typedef. Fixes rdar://problem/15044218 llvm-svn: 192146
* Remove an unnecessary overload from ASTLambda.h Faisal Vali2013-09-291-1/+1
| | | | | | | As Richard pointed out to me, dyn_cast is very cheap - there is no real benefit from adding cluttery overloads to only avoid that cast. No functionality change. llvm-svn: 191646
* Per latest drafting, switch to implementing init-captures as if by declaringRichard Smith2013-09-281-2/+5
| | | | | | and capturing a variable declaration, and complete the implementation of them. llvm-svn: 191605
* Variable templates: handle instantiation of static data member templatesRichard Smith2013-09-271-1/+2
| | | | | | appropriately, especially when they appear within class templates. llvm-svn: 191548
* Fix error recovery when a return type correction includes a new name specifier.Kaelyn Uhrain2013-09-261-1/+6
| | | | llvm-svn: 191459
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-09-261-3/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - generic lambdas within template functions and nested within other generic lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware (Although I have gotten some useful feedback on my patches of the above and will be incorporating that as I submit those patches for commit) As an example of what compiles through this commit: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. This patch has been reviewed by Doug and Richard. Minor changes (non-functionality affecting) have been made since both of them formally looked at it, but the changes involve removal of supernumerary return type deduction changes (since they are now redundant, with richard having committed a recent patch to address return type deduction for C++11 lambdas using C++14 semantics). Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that SemaType.cpp::ConvertDeclSpecToType may use it to immediately generate a template-parameter-type when 'auto' is parsed in a generic lambda parameter context. (i.e we do NOT use AutoType deduced to a template parameter type - Richard seemed ok with this approach). We encode that this template type was generated from an auto by simply adding $auto to the name which can be used for better diagnostics if needed. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - various tests were added - but much more will be needed. There is obviously more work to be done, and both Richard (weakly) and Doug (strongly) have requested that LambdaExpr be removed form the CXXRecordDecl LambdaDefinitionaData in a future patch which is forthcoming. A greatful thanks to all reviewers including Eli Friedman, James Dennett, and especially the two gracious wizards (Richard Smith and Doug Gregor) who spent hours providing feedback (in person in Chicago and on the mailing lists). And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 191453
* Fix -Wmissing-variable-declarations regression.Eli Friedman2013-09-241-1/+1
| | | | | | | | This issue was introduced in r181677. PR17349. llvm-svn: 191339
* Parse: Don't crash during parsing if we lack a simple-type-specifierDavid Majnemer2013-09-221-0/+1
| | | | | | | | | | | | | | | | | Summary: Parsing cast expressions during error recovery can put us in a bad state. Check to see if the token for a simple-type-specifier makes sense before further parsing. Fixes PR17255. Reviewers: rsmith, doug.gregor, CornedBee, eli.friedman CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1696 llvm-svn: 191159
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-33/+87
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* Remove a bogus diagnostic preventing static data member templates from beingRichard Smith2013-09-181-15/+0
| | | | | | defined with no initializer. llvm-svn: 190970
* Revert "Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately""David Majnemer2013-09-171-2/+10
| | | | | | This reverts commit r190895 which reverted r190892. llvm-svn: 190904
* Revert "[-cxx-abi microsoft] Mangle local TagDecls appropriately"David Majnemer2013-09-171-10/+2
| | | | | | This reverts commit r190892. llvm-svn: 190895
* [-cxx-abi microsoft] Mangle local TagDecls appropriatelyDavid Majnemer2013-09-171-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Summary: When selecting a mangling for an anonymous tag type: - We should first try it's typedef'd name. - If that doesn't work, we should mangle in the name of the declarator that specified it as a declaration specifier. - If that doesn't work, fall back to a static mangling of <unnamed-type>. This should make our anonymous type mangling compatible. This partially fixes PR16994; we would need to have an implementation of scope numbering to get it right (a separate issue). Reviewers: rnk, rsmith, rjmccall, cdavis5x CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1540 llvm-svn: 190892
* [-cxx-abi microsoft] Correctly identify Win32 entry pointsDavid Majnemer2013-09-161-1/+27
| | | | | | | | | | | | | | | | | | | Summary: This fixes several issues with the original implementation: - Win32 entry points cannot be in namespaces - A Win32 entry point cannot be a function template, diagnose if we it. - Win32 entry points cannot be overloaded. - Win32 entry points implicitly return, similar to main. Reviewers: rnk, rsmith, whunt, timurrrr Reviewed By: rnk CC: cfe-commits, nrieck Differential Revision: http://llvm-reviews.chandlerc.com/D1683 llvm-svn: 190818
* Fix regression from r190382.Eli Friedman2013-09-101-8/+0
| | | | | | | | | Make sure we perform the correct "referenced-but-not-used" check for static member constants. Fixes bug reported on cfe-commits by Alexey Samsonov. llvm-svn: 190437
* [ms-cxxabi] Implement guard variables for static initializationReid Kleckner2013-09-101-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Static locals requiring initialization are not thread safe on Windows. Unfortunately, it's possible to create static locals that are actually externally visible with inline functions and templates. As a result, we have to implement an initialization guard scheme that is compatible with TUs built by MSVC, which makes thread safety prohibitively difficult. MSVC's scheme is that every function that requires a guard gets an i32 bitfield. Each static local is assigned a bit that indicates if it has been initialized, up to 32 bits, at which point a new bitfield is created. MSVC rejects inline functions with more than 32 static locals, and the externally visible mangling (?_B) only allows for one guard variable per function. On Eli's recommendation, I used MangleNumberingContext to track which bit each static corresponds to. Implements PR16888. Reviewers: rjmccall, eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1416 llvm-svn: 190427
* Make -Wunused warning rules more consistent.Eli Friedman2013-09-101-16/+26
| | | | | | | | | | | | | | | This patch does a few different things. This patch improves unused var diags for const vars: we no longer unconditionally suppress diagnostics for const vars, instead only suppressing the diagnostic when the declaration appears to be useful. This patch also makes us more consistently use whether a variable/function is declared in the main file to suppress diagnostics where appropriate. Fixes <rdar://problem/14907887>. llvm-svn: 190382
* Preserve exception specs in function decl merging.Eli Friedman2013-09-061-2/+4
| | | | | | | | | Exception specs are not part of the canonical type, but we shouldn't drop them just because we merged a noreturn attribute. Fixes PR17110. llvm-svn: 190206
* Note when a decl is used in AST files.Eli Friedman2013-09-051-4/+2
| | | | | | | | | | | | | | | When an AST file is built based on another AST file, it can use a decl from the fist file, and therefore mark the "isUsed" bit. We need to note this in the AST file so that the bit is set correctly when the second AST file is loaded. This patch introduces the distinction between setIsUsed() and markUsed() so that we don't call into the ASTMutationListener callback when it wouldn't be appropriate. Fixes PR16635. llvm-svn: 190016
* Switched FormatAttr to using an IdentifierArgument instead of a ↵Aaron Ballman2013-09-031-3/+5
| | | | | | StringArgument since that is a more accurate modeling. llvm-svn: 189851
* Refactor computation of whether a variable declaration's type should be mergedRichard Smith2013-09-031-39/+35
| | | | | | with a prior declaration. No functionality change intended. llvm-svn: 189850
* Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don'tRichard Smith2013-08-291-6/+1
| | | | | | do anything useful. llvm-svn: 189548
* Delete CC_Default and use the target default CC everywhereReid Kleckner2013-08-271-50/+46
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Makes functions with implicit calling convention compatible with function types with a matching explicit calling convention. This fixes things like calls to qsort(), which has an explicit __cdecl attribute on the comparator in Windows headers. Clang will now infer the calling convention from the declarator. There are two cases when the CC must be adjusted during redeclaration: 1. When defining a non-inline static method. 2. When redeclaring a function with an implicit or mismatched convention. Fixes PR13457, and allows clang to compile CommandLine.cpp for the Microsoft C++ ABI. Excellent test cases provided by Alexander Zinenko! Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1231 llvm-svn: 189412
* Cleanup of OpaquePtr. No functionality changes.Serge Pavlov2013-08-271-1/+1
| | | | | | | | - Some documenation were added. - Usages of OpaquePtr<A>.getAsVal<A>() were replaced by OpaquePtr<A>.get(). - Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively. llvm-svn: 189346
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-42/+3
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* Refactor for clarity and simplicity.Larisse Voufo2013-08-221-48/+42
| | | | llvm-svn: 188974
* Improve support for static data member templates. This revision still has at ↵Larisse Voufo2013-08-221-6/+1
| | | | | | least one bug, as it does not respect the variable template specialization hierarchy well. llvm-svn: 188969
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-136/+79
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Don't reject attribute used in an "extern const" variable definition.Rafael Espindola2013-08-161-0/+7
| | | | | | | Before this patch we would warn and drop the attribute in extern const char test3[] __attribute__((used)) = ""; llvm-svn: 188588
* PR16875: The return type of a dependent function type is visible when it'sRichard Smith2013-08-141-3/+22
| | | | | | | | | | | referenced as a member of the current instantiation. In that case, deduce the type of the function to a dependent type rather than exposing an undeduced auto type to the rest of the current instantiation. The standard doesn't really say that the type is dependent in this case; I'll bring this up with CWG. llvm-svn: 188410
* Bug fix: disallow a variable template to be redeclared as a non-templated ↵Larisse Voufo2013-08-141-10/+21
| | | | | | variable llvm-svn: 188350
* Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:Richard Smith2013-08-131-36/+97
| | | | | | | | | | | | | When a local extern declaration redeclares some other entity, the type of that entity is merged with the prior type if the prior declaration is visible (in C) or is declared in the same scope (in C++). - Make LookupRedeclarationWithLinkage actually work in C++, use it in the right set of cases, and make it track whether it found a shadowed declaration. - Track whether we found a declaration in the same scope (for C++) including across serialization and template instantiation. llvm-svn: 188307
* Fix crash w/BlockDecl and invalid qualified decl.Eli Friedman2013-08-121-1/+4
| | | | | | | | | I'm not really satisfied with the ad-hoc nature of Sema::diagnoseQualifiedDeclaration, but I'm not sure how to fix it. Fixes <rdar://problem/14639501>. llvm-svn: 188208
* Omit llvm:: before ArrayRef, as we have using llvm::ArrayRef in ↵Robert Wilhelm2013-08-091-8/+8
| | | | | | include/clang/Basic/LLVM.h. llvm-svn: 188089
* Implement [class.friend]p11's special name lookup rules for friend declarationsRichard Smith2013-08-091-29/+37
| | | | | | | | of local classes. We were previously handling this by performing qualified lookup within a function declaration(!!); replace it with the proper scope lookup. llvm-svn: 188050
* Moved diagnosis of forward declarations of variable templates from Parser to ↵Larisse Voufo2013-08-061-2/+18
| | | | | | Sema. llvm-svn: 187768
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-37/+208
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
* Error on more illegal kernel argument types for OpenCLMatt Arsenault2013-07-231-18/+170
| | | | | | | | bool, half, pointers and structs / unions containing any of these are not allowed. Does not yet reject size_t and related integer types that are also disallowed. llvm-svn: 186908
* Fixed implementation of C89 6.5.7 p3.Enea Zaffanella2013-07-221-0/+1
| | | | | | Warning should be emitted only for InitListExpr nodes. llvm-svn: 186859
* Implement the part of C89 6.5.7 p3 requiring a constant initializer listEnea Zaffanella2013-07-221-3/+13
| | | | | | when initializing aggregate/union types, no matter if static or not. llvm-svn: 186817
* Convert Sema::MatchTemplateParametersToScopeSpecifier to ArrayRef.Robert Wilhelm2013-07-211-27/+14
| | | | llvm-svn: 186794
* add type attribute warn_unused, for -Wunused-variable warnings (pr#14253)Lubos Lunak2013-07-201-2/+2
| | | | | | | | | The functionality is equivalent to the GCC attribute. Variables of tagged types will be warned about as unused if they are not used in any way except for possible (even non-trivial) ctors/dtors called. Useful for tagging classes like std::string (which is not part of this commit). llvm-svn: 186765
* Reinstate r186040, with additional fixes and more test coverage (reverted inRichard Smith2013-07-171-8/+4
| | | | | | | | | | | | | r186331). Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186546
* MS wide bitfield error check in SemaReid Kleckner2013-07-171-5/+7
| | | | | | | | | | | | | cl.exe treats wide bitfields as an error. This patch causes them to be an error if IsMsStruct is true, as it is in straight C. Patch by Warren Hunt! Reviewers: eli.friedman Differential Revision: http://llvm-reviews.chandlerc.com/D1125 llvm-svn: 186536
OpenPOWER on IntegriCloud