summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement DR482: namespace members can be redeclared with a qualified nameRichard Smith2013-12-051-8/+10
| | | | | | | | | | within their namespace, and such a redeclaration isn't required to be a definition any more. Update DR status page to say Clang 3.4 instead of SVN and add new Clang 3.5 category (but keep Clang 3.4 yellow for now). llvm-svn: 196481
* Unify lookup from within not-yet-defined defaulted special members: use commonRichard Smith2013-11-271-47/+64
| | | | | | | code for handling triviality, deletedness and constexpr. Fix a few bugs in these, particularly related to mutable members, and remove some dead code. llvm-svn: 195809
* Take cv-qualifiers on fields of class type into account when determiningRichard Smith2013-11-251-0/+4
| | | | | | whether a defaulted special member function should be deleted. llvm-svn: 195620
* Add class-specific operator new to Decl hierarchy. This guarantees that DeclsRichard Smith2013-11-221-4/+2
| | | | | | | | | | | | | can't accidentally be allocated the wrong way (missing prefix data for decls from AST files, for instance) and simplifies the CreateDeserialized functions a little. An extra DeclContext* parameter to the not-from-AST-file operator new allows us to ensure that we don't accidentally call the wrong one when deserializing (when we don't have a DeclContext), allows some extra checks, and prepares for some planned modules-related changes to Decl allocation. No functionality change intended. llvm-svn: 195426
* Don't reject dependent range-based for loops in constexpr functions. The loopRichard Smith2013-11-151-1/+1
| | | | | | variable isn't really uninitialized, it's just not initialized yet. llvm-svn: 194767
* Issue a diagnostic if we see a templated friend declaration that we do notRichard Smith2013-11-081-0/+2
| | | | | | support. llvm-svn: 194273
* Issue a diagnostic if an implicitly-defined move assignment operator would moveRichard Smith2013-11-041-10/+99
| | | | | | | the same virtual base class multiple times (and the move assignment is used, and the move assignment for the virtual base is not trivial). llvm-svn: 193977
* Update a comment to match current core issues list.Richard Smith2013-11-041-8/+3
| | | | llvm-svn: 193970
* Implement final resolution of DR1402: implicitly-declared move operators thatRichard Smith2013-11-041-154/+15
| | | | | | | | | | | would be deleted are still declared, but are ignored by overload resolution. Also, don't delete such members if a subobject has no corresponding move operation and a non-trivial copy. This causes us to implicitly declare move operations in more cases, but risks move-assigning virtual bases multiple times in some circumstances (a warning for that is to follow). llvm-svn: 193969
* Sema: Disallow inheriting from classes with flexible array membersDavid Majnemer2013-11-021-0/+12
| | | | | | | | | | | Flexible array members inherently index off of the end of their parent type. We shouldn't allow this type to be used as a base, virtual or otherwise, because indexing off the end may find us inside of another base or the derived types members. llvm-svn: 193923
* Sema: Remove stray whitespace around Sema::CheckBaseSpecifierDavid Majnemer2013-11-021-3/+3
| | | | llvm-svn: 193922
* Simplify and refactor the uninitialized field warning.Richard Trieu2013-10-251-190/+90
| | | | | | | | | | | Change the uninitialized field warnings so that field initializers are checked inside the constructor. Previously, in class initializers were checked separately. Running one set of checks also simplifies the logic for preventing duplicate warnings. Added new checks to warn when an uninitialized field is used in base class initialization. Also fixed misspelling of uninitialized and moved all code for this warning together. llvm-svn: 193386
* Make UsingShadowDecls redeclarable. This fixes some visibility problems withRichard Smith2013-10-231-19/+25
| | | | | | | | | | modules. With this fixed, I no longer see any test regressions in the libc++ test suite when enabling a single-module module.map for libc++ (other than issues with my system headers). llvm-svn: 193219
* Allow CorrectTypo to replace CXXScopeSpecifiers that refer to classes.Kaelyn Uhrain2013-10-191-3/+10
| | | | | | | | | | | Now that CorrectTypo knows how to correctly search classes for typo correction candidates, there is no good reason to only replace an existing CXXScopeSpecifier if it refers to a namespace. While the actual enablement was a matter of changing a single comparison, the fallout from enabling the functionality required a lot more code changes (including my two previous commits). llvm-svn: 193020
* Fix missed exception spec checks and crashesAlp Toker2013-10-181-23/+24
| | | | | | | | | | | | | | | | | | | Delayed exception specification checking for defaulted members and virtual destructors are both susceptible to mutation during iteration so we need to swap and process the worklists. This resolves both accepts-invalid and rejects-valid issues and moreover fixes potential invalid memory access as the contents of the vectors change during iteration and recursive template instantiation. Checking can be further delayed where parent classes aren't yet fully defined. This patch adds two assertions at end of TU to ensure no specs are left unchecked as was happenning before the fix, plus a test case from Marshall Clow for the defaulted member crash extracted from the libcxx headers. Reviewed by Richard Smith. llvm-svn: 192947
* [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for ↵David Majnemer2013-10-181-10/+19
| | | | | | | | | | | | | | 'final' Summary: Some MS headers use these features. Reviewers: rnk, rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1948 llvm-svn: 192936
* Revert "Fix missed exception spec checks and crashes"Alp Toker2013-10-171-23/+23
| | | | | | | | | | | The changes caused the sanitizer bot to hang: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/2311 Needs investigation. This reverts commit r192914. llvm-svn: 192921
* Fix missed exception spec checks and crashesAlp Toker2013-10-171-23/+23
| | | | | | | | | | | | | | | | | | Delayed exception specification checking for defaulted members and virtual destructors are both susceptible to mutation during iteration so we need to process the worklists fully. This resolves both accepts-invalid and rejects-valid issues and moreover fixes potential invalid memory access as the contents of the vectors change during iteration and recursive template instantiation. This patch also adds two assertions at end of TU to ensure no specs are left unchecked as was happenning before the fix, plus a test case from Marshall Clow for the defaulted member crash extracted from the libcxx headers. Reviewed by Richard Smith. llvm-svn: 192914
* Rename some functions for consistency.Rafael Espindola2013-10-171-1/+1
| | | | | | Every other function in Redeclarable.h was using Decl instead of Declaration. llvm-svn: 192900
* PR17567: Improve diagnostic for a mistyped constructor name. If we see somethingRichard Smith2013-10-151-0/+26
| | | | | | | | | | | that looks like a function declaration, except that it's missing a return type, try typo-correcting it to the relevant constructor name. In passing, fix a bug where the missing-type-specifier recovery codepath would drop a preceding scope specifier on the floor, leading to follow-on diagnostics and incorrect recovery for the auto-in-c++98 hack. llvm-svn: 192644
* Adds Microsoft compatiable C++ record layout code to clang.Warren Hunt2013-10-111-0/+7
| | | | llvm-svn: 192494
* Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a ↵Ted Kremenek2013-10-081-1/+1
| | | | | | holdover from the long-dead Action interface. llvm-svn: 192203
* Add support for WG21 N3599 (literal operator template for strings) as a GNURichard Smith2013-10-071-3/+25
| | | | | | | | | extension. The GCC folks have decided to support this even though the standard committee have not yet approved this feature. Patch by Hristo Venev! llvm-svn: 192128
* Fix windows newlines :(Faisal Vali2013-09-291-1/+1
| | | | llvm-svn: 191641
* Implement conversion to function pointer for generic lambdas without captures.Faisal Vali2013-09-291-38/+73
| | | | | | | | | | | | | | | | The general strategy is to create template versions of the conversion function and static invoker and then during template argument deduction of the conversion function, create the corresponding call-operator and static invoker specializations, and when the conversion function is marked referenced generate the body of the conversion function using the corresponding static-invoker specialization. Similarly, Codegen does something similar - when asked to emit the IR for a specialized static invoker of a generic lambda, it forwards emission to the corresponding call operator. This patch has been reviewed in person both by Doug and Richard. Richard gave me the LGTM. A few minor changes: - per Richard's request i added a simple check to gracefully inform that captures (init, explicit or default) have not been added to generic lambdas just yet (instead of the assertion violation). - I removed a few lines of code that added the call operators instantiated parameters to the currentinstantiationscope. Not only did it not handle parameter packs, but it is more relevant in the patch for nested lambdas which will follow this one, and fix that problem more comprehensively. - Doug had commented that the original implementation strategy of using the TypeSourceInfo of the call operator to create the static-invoker was flawed and allowed const as a member qualifier to creep into the type of the static-invoker. I currently kludge around it - but after my initial discussion with Doug, with a follow up session with Richard, I have added a FIXME so that a more elegant solution that involves the use of TrivialTypeSourceInfo call followed by the correct wiring of the template parameters to the functionprototypeloc is forthcoming. Thanks! llvm-svn: 191634
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-09-261-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Simplify code to equivalent code. No need to test for null after cast<>, useNick Lewycky2013-09-221-9/+5
| | | | | | | takeAs<> instead of cast<>(.take()). Fix 80-column violation in whitespace after comment. llvm-svn: 191170
* Modify the uninitialized field visitor to detect uninitialized use across theRichard Trieu2013-09-201-32/+180
| | | | | | | | | | | | | | | | | | fields in the class. This allows a better checking of member intiailizers and in class initializers in regards to initialization ordering. For instance, this code will now produce warnings: class A { int x; int y; A() : x(y) {} // y is initialized after x, warn here A(int): y(x) {} // default initialization of leaves x uninitialized, warn here }; Several test cases were updated with -Wno-uninitialized to silence this warning. llvm-svn: 191068
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-5/+15
| | | | | | | | | | | | | | 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
* Move the uninitialized field check to after all the field initializers are addedRichard Trieu2013-09-161-17/+39
| | | | | | to the CXXConstructorDecl so that information from the constructor can be used. llvm-svn: 190810
* Pass additional information around the uninitialized field visitor.Richard Trieu2013-09-161-7/+12
| | | | llvm-svn: 190805
* Refactor the uninitialized field visitor. Also moved the calls to the visitorRichard Trieu2013-09-131-54/+69
| | | | | | | later in the code so that the expressions will have addition processing first. This catches a few additional cases of uninitialized uses of class fields. llvm-svn: 190657
* Fix constructor-related typos.Benjamin Kramer2013-09-091-1/+1
| | | | | | Noticed by Roman Divacky. llvm-svn: 190311
* Improve error for "override" + non-virtual func.Eli Friedman2013-09-051-34/+77
| | | | | | | | | | | | | | | | | | | Consider something like the following: struct X { virtual void foo(float x); }; struct Y : X { void foo(double x) override; }; The error is almost certainly that Y::foo() has the wrong signature, rather than incorrect usage of the override keyword. This patch adds an appropriate diagnostic for that case. Fixes <rdar://problem/14785106>. llvm-svn: 190109
* Note when a decl is used in AST files.Eli Friedman2013-09-051-11/+11
| | | | | | | | | | | | | | | 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
* Sema: avoid reuse of Exprs when synthesizing operator=Pavel Labath2013-08-301-94/+197
| | | | | | | | | | | | | | | | | | Summary: Previously, Sema was reusing parts of the AST when synthesizing an assignment operator, turning it into a AS-dag. This caused problems for the static analyzer, which assumed an expression appears in the tree only once. Here I make sure to always create a fresh Expr, when inserting something into the AST, fixing PR16745 in the process. Reviewers: doug.gregor CC: cfe-commits, jordan_rose Differential Revision: http://llvm-reviews.chandlerc.com/D1425 llvm-svn: 189659
* Delete CC_Default and use the target default CC everywhereReid Kleckner2013-08-271-40/+33
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Simplify a bit.Rafael Espindola2013-08-261-13/+8
| | | | | | | | | | | | | This follows from computeKeyFunction having: // Template instantiations don't have key functions,see Itanium C++ ABI 5.2.6. // Same behavior as GCC. TemplateSpecializationKind TSK = RD->getTemplateSpecializationKind(); if (TSK == TSK_ImplicitInstantiation || TSK == TSK_ExplicitInstantiationDefinition) return 0; llvm-svn: 189287
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-231-2/+1
| | | | | | No functionality change intended. llvm-svn: 189112
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-7/+8
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Split isFromMainFile into two functions.Eli Friedman2013-08-221-1/+1
| | | | | | | | | Basically, isInMainFile considers line markers, and isWrittenInMainFile doesn't. Distinguishing between the two is useful when dealing with files which are preprocessed files or rewritten with -frewrite-includes (so we don't, for example, print useless warnings). llvm-svn: 188968
* const'ify Sema::ActOnCompoundStmt byRobert Wilhelm2013-08-191-11/+7
| | | | | | | | changing Parameter of Sema::ActOnCompoundStmt from MutableArrayRef to ArrayRef. No functionality change intended. llvm-svn: 188705
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-38/+23
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Omit llvm:: before SmallVector and SmallVectorImpl. We have using directive ↵Robert Wilhelm2013-08-101-3/+3
| | | | | | in include/clang/Basic/LLVM.h. llvm-svn: 188138
* Implement [class.friend]p11's special name lookup rules for friend declarationsRichard Smith2013-08-091-28/+51
| | | | | | | | 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
* Eliminate CXXConstructorDecl::IsImplicitlyDefined.Jordan Rose2013-08-071-3/+0
| | | | | | | | | | | | This field is just IsDefaulted && !IsDeleted; in all places it's used, a simple check for isDefaulted() is superior anyway, and we were forgetting to set it in a few cases. Also eliminate CXXDestructorDecl::IsImplicitlyDefined, for the same reasons. No intended functionality change. llvm-svn: 187891
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-2/+4
| | | | | | 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
* Sema: Minor const fixups and control flow tidying.Benjamin Kramer2013-07-241-93/+67
| | | | | | No functionality change. llvm-svn: 187047
* C++1y literal suffix support:Richard Smith2013-07-231-1/+3
| | | | | | | * Allow ns, us, ms, s, min, h as numeric ud-suffixes * Allow s as string ud-suffix llvm-svn: 186933
OpenPOWER on IntegriCloud