summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
...
* PR24164, PR39336: init-captures are not distinct full-expressions.Richard Smith2018-10-191-4/+4
| | | | | | | | | Rather, they are subexpressions of the enclosing lambda-expression, and any temporaries in them are destroyed at the end of that full-expression, or when the corresponding lambda-expression is destroyed if they are lifetime-extended. llvm-svn: 344801
* [Test] Fix test file for C++98 modeDavid Bolvansky2018-10-181-1/+3
| | | | llvm-svn: 344762
* [Diagnostics] Add missing expected warning to test fileDavid Bolvansky2018-10-181-1/+1
| | | | llvm-svn: 344761
* Improve -Wshadow warnings with enumerators.Aaron Ballman2018-10-111-0/+3
| | | | | | | | | | | Addresses PR24718 by checking for enumerators that shadow other enumerators. Catches issues like: enum E1{e1}; void f(void) { enum E2{e1}; } llvm-svn: 344259
* [clang] Fix failing attribute test on WindowsLouis Dionne2018-10-101-1/+1
| | | | | | | | The test added in r344146 was failing because the ABI on Windows is different, and that test includes ABI-specific details. The test now harcodes which ABI to use so we can rely on those details. llvm-svn: 344159
* [Sema] Fix a multiple definition bug with friends and templatesErik Pilkington2018-10-101-0/+20
| | | | | | | | | | | | | | The problem was that MergeFunctionDecl sometimes needs the injected template arguments of a FunctionTemplateDecl, but is called before adding the new template to the redecl chain. This leads to multiple common pointers in the same redecl chain, each with their own identical instantiation. Fix this by merging the the common state before inserting the new template into the redecl chain. rdar://44810129 Differential revision: https://reviews.llvm.org/D53046 llvm-svn: 344157
* [clang] Properly apply attributes on explicit instantiations of static data ↵Louis Dionne2018-10-101-0/+25
| | | | | | | | | | | | | | members Summary: https://llvm.org/PR39118 Reviewers: aaron.ballman, rnk Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D52675 llvm-svn: 344146
* [coro]Pass rvalue reference for named local variable to return_valueBrian Gesiak2018-10-081-0/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Addressing https://bugs.llvm.org/show_bug.cgi?id=37265. Implements [class.copy]/33 of coroutines TS. When the criteria for elision of a copy/move operation are met, but not for an exception-declaration, and the object to be copied is designated by an lvalue, or when the expression in a return or co_return statement is a (possibly parenthesized) id-expression that names an object with automatic storage duration declared in the body or parameter-declaration-clause of the innermost enclosing function or lambda-expression, overload resolution to select the constructor for the copy or the return_value overload to call is first performed as if the object were designated by an rvalue. Patch by Tanoy Sinha! Reviewers: modocache, GorNishanov Reviewed By: modocache, GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51741 llvm-svn: 343949
* Thread safety analysis: Handle conditional expression in getTrylockCallExprAaron Puchert2018-10-061-0/+17
| | | | | | | | | | | | | | | | | | | | | Summary: We unwrap conditional expressions containing try-lock functions. Additionally we don't acquire on conditional expression branches, since that is usually not helpful. When joining the branches we would almost certainly get a warning then. Hopefully fixes an issue that was raised in D52398. Reviewers: aaron.ballman, delesley, hokein Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52888 llvm-svn: 343902
* Emit diagnostic note when calling an invalid function declaration.James Y Knight2018-10-051-1/+2
| | | | | | | | | | | | | | The comment said it was intentionally not emitting any diagnostic because the declaration itself was already diagnosed. However, everywhere else that wants to not emit a diagnostic without an extra note emits note_invalid_subexpr_in_const_expr instead, which gets suppressed later. This was the only place which did not emit a diagnostic note. Differential Revision: https://reviews.llvm.org/D52919 llvm-svn: 343867
* Thread safety analysis: Examine constructor argumentsAaron Puchert2018-10-041-0/+26
| | | | | | | | | | | | | | | | | | | | Summary: Instead of only examining call arguments, we also examine constructor arguments applying the same rules. That was an opportunity for refactoring the examination procedure to work with iterators instead of integer indices. For the case of CallExprs no functional change is intended. Reviewers: aaron.ballman, delesley Reviewed By: delesley Subscribers: JonasToth, cfe-commits Differential Revision: https://reviews.llvm.org/D52443 llvm-svn: 343831
* [clang] Add the exclude_from_explicit_instantiation attributeLouis Dionne2018-10-044-0/+193
| | | | | | | | | | | | | | | | | | | | | | Summary: This attribute allows excluding a member of a class template from being part of an explicit template instantiation of that class template. This also makes sure that code using such a member will not take for granted that an external instantiation exists in another translation unit. The attribute was discussed on cfe-dev at [1] and is primarily motivated by the removal of always_inline in libc++ to control what's part of the ABI (see links in [1]). [1]: http://lists.llvm.org/pipermail/cfe-dev/2018-August/059024.html rdar://problem/43428125 Reviewers: rsmith Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D51789 llvm-svn: 343790
* [constexpr] Fix ICE when memcpy() is given a pointer to an incomplete arrayPetr Pavlu2018-10-041-0/+37
| | | | | | | | | | Fix code for constant evaluation of __builtin_memcpy() and __builtin_memmove() that would attempt to divide by zero when given two pointers to an incomplete array. Differential Revision: https://reviews.llvm.org/D51855 llvm-svn: 343761
* Thread safety analysis: Unwrap __builtin_expect in getTrylockCallExprAaron Puchert2018-10-031-0/+15
| | | | | | | | | | | | | | | | | | Summary: When people are really sure they'll get the lock they sometimes use __builtin_expect. It's also used by some assertion implementations. Asserting that try-lock succeeded is basically the same as asserting that the lock is not held by anyone else (and acquiring it). Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D52398 llvm-svn: 343681
* [cxx2a] P0614R1: Support init-statements in range-based for loops.Richard Smith2018-09-282-0/+16
| | | | | | | We don't yet support this for the case where a range-based for loop is implicitly rewritten to an ObjC for..in statement. llvm-svn: 343350
* Handle dependent class template names in class template argumentRichard Smith2018-09-281-0/+7
| | | | | | deduction for new-expressions. llvm-svn: 343293
* [cxx2a] P0641R2: (Some) type mismatches on defaulted functions onlyRichard Smith2018-09-284-9/+21
| | | | | | | | | | | | | | | | render the function deleted instead of rendering the program ill-formed. This change also adds an enabled-by-default warning for the case where an explicitly-defaulted special member function of a non-template class is implicitly deleted by the type checking rules. (This fires either due to this language change or due to pre-C++20 reasons for the member being implicitly deleted). I've tested this on a large codebase and found only bugs (where the program means something that's clearly different from what the programmer intended), so this is enabled by default, but we should revisit this if there are problems with this being enabled by default. llvm-svn: 343285
* [cxx2a] P0624R2: Lambdas with no capture-default areRichard Smith2018-09-272-0/+52
| | | | | | default-constructible and assignable. llvm-svn: 343279
* [Sema] Handle __va_start for Windows/ARM64 in the same way as for ARMMartin Storsjo2018-09-271-0/+1
| | | | | | | | This fixes PR39090. Differential Revision: https://reviews.llvm.org/D52571 llvm-svn: 343184
* P1008R1 Classes with user-declared constructors are never aggregates inRichard Smith2018-09-262-0/+46
| | | | | | C++20. llvm-svn: 343131
* P0962R1: only use the member form of 'begin' and 'end' in a range-basedRichard Smith2018-09-241-3/+3
| | | | | | | | | | for loop if both members exist. This resolves a DR whereby an errant 'begin' or 'end' member in a base class could result in a derived class not being usable as a range with non-member 'begin' and 'end'. llvm-svn: 342925
* Update smart pointer detection for thread safety analysis.Richard Trieu2018-09-221-0/+95
| | | | | | | | | Objects are determined to be smart pointers if they have both a star and arrow operator. Some implementations of smart pointers have these overloaded operators in a base class, while the check only searched the derived class. This fix will also look for the operators in the base class. llvm-svn: 342794
* [Sema] Retain __restrict qualifiers when substituting a reference type.Erik Pilkington2018-09-201-0/+18
| | | | | | | | Fixes rdar://43760099 Differential revision: https://reviews.llvm.org/D52271 llvm-svn: 342672
* Thread Safety Analysis: warnings for attributes without argumentsAaron Puchert2018-09-201-19/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When thread safety annotations are used without capability arguments, they are assumed to apply to `this` instead. So we warn when either `this` doesn't exist, or the class is not a capability type. This is based on earlier work by Josh Gao that was committed in r310403, but reverted in r310698 because it didn't properly work in template classes. See also D36237. The solution is not to go via the QualType of `this`, which is then a template type, hence the attributes are not known because it could be specialized. Instead we look directly at the class in which we are contained. Additionally I grouped two of the warnings together. There are two issues here: the existence of `this`, which requires us to be a non-static member function, and the appropriate annotation on the class we are contained in. So we don't distinguish between not being in a class and being static, because in both cases we don't have `this`. Fixes PR38399. Reviewers: aaron.ballman, delesley, jmgao, rtrieu Reviewed By: delesley Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51901 llvm-svn: 342605
* Thread safety analysis: Fix crash for function pointersAaron Puchert2018-09-191-0/+5
| | | | | | | | For function pointers, the FunctionDecl of the callee is unknown, so getDirectCallee will return nullptr. We have to catch that case to avoid crashing. We assume there is no attribute then. llvm-svn: 342519
* Thread safety analysis: Run more tests with capability attributes [NFC]Aaron Puchert2018-09-174-99/+62
| | | | | | | | | | | | | | | | | | | | | | Summary: We run the tests for -Wthread-safety-{negative,verbose} with the new attributes as well as the old ones. Also put the macros in a header so that we don't have to copy them all around. The warn-thread-safety-parsing.cpp test checks for warnings depending on the actual attribute name, so it can't undergo the same treatment. Together with D49275 this should fix PR33754. Reviewers: aaron.ballman, delesley, grooverdan Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52141 llvm-svn: 342418
* [clang] Make sure attributes on member classes are applied properlyLouis Dionne2018-09-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | Summary: Attributes on member classes of class templates and member class templates of class templates are not currently instantiated. This was discovered by Richard Smith here: http://lists.llvm.org/pipermail/cfe-dev/2018-September/059291.html This commit makes sure that attributes are instantiated properly. This commit does not fix the broken behavior for member partial and explicit specializations of class templates. PR38913 Reviewers: rsmith Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D51997 llvm-svn: 342238
* [Sema] Remove location from implicit capture init exprVedant Kumar2018-09-131-2/+4
| | | | | | | | | | | | | | | | | | A lambda's closure is initialized when the lambda is declared. For implicit captures, the initialization code emitted from EmitLambdaExpr references source locations *within the lambda body* in the function containing the lambda. This results in a poor debugging experience: we step to the line containing the lambda, then into lambda, out again, over and over, until every capture's field is initialized. To improve stepping behavior, assign the starting location of the lambda to expressions which initialize an implicit capture within it. rdar://39807527 Differential Revision: https://reviews.llvm.org/D50927 llvm-svn: 342194
* Fix crash on call to __builtin_memcpy with a null pointer to anRichard Smith2018-09-132-1/+18
| | | | | | | | incomplete type. Also improve the diagnostics for similar situations. llvm-svn: 342192
* [AST] Fix a crash on invalid.Erik Pilkington2018-09-101-0/+7
| | | | | | | | | Problem was that we were appending to the source location info buffer in the copy assignment operator (instead of overwriting). rdar://42746401 llvm-svn: 341869
* Enhance -Wc++14-compat for class template argument deduction to list theRichard Smith2018-09-101-1/+1
| | | | | | deduced type (if known). llvm-svn: 341858
* Prevent cpu-specific/cpu-dispatch from giong on a lambda.Erich Keane2018-09-101-0/+3
| | | | | | | It is non-sensical to use cpu-specific/cpu-dispatch multiversioning on a lambda, so prevent it when trying to add the attribute. llvm-svn: 341833
* PR33222: Require the declared return type not the actual return type toRichard Smith2018-09-101-0/+70
| | | | | | | | | match when checking for redeclaration of a function template. This properly handles differences in deduced return types, particularly when performing redeclaration checks for a friend function template. llvm-svn: 341778
* Part of PR33222: defer enforcing return type mismatch for dependentRichard Smith2018-09-101-0/+23
| | | | | | friend function declarations of class templates. llvm-svn: 341775
* [Sema] Check that the destructor for each element of class type isAkira Hatanaka2018-09-071-0/+48
| | | | | | | | | | accessible from the context where aggregate initialization occurs. rdar://problem/38168772 Differential Revision: https://reviews.llvm.org/D45898 llvm-svn: 341629
* PR38627: Fix handling of exception specification adjustment forRichard Smith2018-09-055-29/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. llvm-svn: 341499
* Add test file missed from r341097.Richard Smith2018-08-301-0/+34
| | | | llvm-svn: 341099
* Add missing -Wc++11-compat / -Wc++14-compat warnings for:Richard Smith2018-08-302-5/+24
| | | | | | | | * generic lambdas * return type deduction * class template argument deduction llvm-svn: 341098
* Thread safety analysis no longer hands when analyzing a self-referencing ↵Aaron Ballman2018-08-241-0/+8
| | | | | | | | initializer. This fixes PR38640. llvm-svn: 340636
* Thread safety analysis: Allow relockable scopesAaron Puchert2018-08-221-0/+164
| | | | | | | | | | | | | | | | | | | Summary: It's already allowed to prematurely release a scoped lock, now we also allow relocking it again, possibly even in another mode. This is the second attempt, the first had been merged as r339456 and reverted in r339558 because it caused a crash. Reviewers: delesley, aaron.ballman Reviewed By: delesley, aaron.ballman Subscribers: hokein, cfe-commits Differential Revision: https://reviews.llvm.org/D49885 llvm-svn: 340459
* Address Aaron Ballman's post-commit review comments from r340306, NFCErik Pilkington2018-08-211-0/+6
| | | | llvm-svn: 340311
* Add a new flag and attributes to control static destructor registrationErik Pilkington2018-08-212-0/+45
| | | | | | | | | | | | | | | | | | | | This commit adds the flag -fno-c++-static-destructors and the attributes [[clang::no_destroy]] and [[clang::always_destroy]]. no_destroy specifies that a specific static or thread duration variable shouldn't have it's destructor registered, and is the default in -fno-c++-static-destructors mode. always_destroy is the opposite, and is the default in -fc++-static-destructors mode. A variable whose destructor is disabled (either because of -fno-c++-static-destructors or [[clang::no_destroy]]) doesn't count as a use of the destructor, so we don't do any access checking or mark it referenced. We also don't emit -Wexit-time-destructors for these variables. rdar://21734598 Differential revision: https://reviews.llvm.org/D50994 llvm-svn: 340306
* Model type attributes as regular Attrs.Richard Smith2018-08-201-7/+36
| | | | | | | | | | | | | | Specifically, AttributedType now tracks a regular attr::Kind rather than having its own parallel Kind enumeration, and AttributedTypeLoc now holds an Attr* instead of holding an ad-hoc collection of Attr fields. Differential Revision: https://reviews.llvm.org/D50526 This reinstates r339623, reverted in r339638, with a fix to not fail template instantiation if we instantiate a QualType with no associated type source information and we encounter an AttributedType. llvm-svn: 340215
* [SEMA] add more -Wfloat-conversion to compound assigment analysisNick Desaulniers2018-08-131-0/+26
| | | | | | | | | | | | | | Summary: Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061 Reviewers: aaron.ballman, acoomans Reviewed By: aaron.ballman, acoomans Subscribers: acoomans, cfe-commits, srhines, pirama Differential Revision: https://reviews.llvm.org/D50467 llvm-svn: 339581
* Summary:Add clang::reinitializes attributeMartin Bohme2018-08-131-0/+15
| | | | | | | | | | | | | | | | Summary: This is for use by clang-tidy's bugprone-use-after-move check -- see corresponding clang-tidy patch at https://reviews.llvm.org/D49910. Reviewers: aaron.ballman, rsmith Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49911 llvm-svn: 339569
* Revert "Allow relockable scopes with thread safety attributes."Haojian Wu2018-08-131-148/+0
| | | | | | | | | | | | | | | | | | | | | | This reverts commit r339456. The change introduces a new crash, see class SCOPED_LOCKABLE FileLock { public: explicit FileLock() EXCLUSIVE_LOCK_FUNCTION(file_); ~FileLock() UNLOCK_FUNCTION(file_); void Lock() EXCLUSIVE_LOCK_FUNCTION(file_); Mutex file_; }; void relockShared2() { FileLock file_lock; file_lock.Lock(); } llvm-svn: 339558
* Allow relockable scopes with thread safety attributes.Aaron Ballman2018-08-101-0/+148
| | | | | | Patch by Aaron Puchert llvm-svn: 339456
* PR38286: Don't crash when attempting to define a constructor for anRichard Smith2018-08-081-0/+11
| | | | | | incomplete class template. llvm-svn: 339210
* [constexpr] Support for constant evaluation of __builtin_memcpy andRichard Smith2018-08-041-6/+142
| | | | | | | | | | | | | | | | | | __builtin_memmove (in non-type-punning cases). This is intended to permit libc++ to make std::copy etc constexpr without sacrificing the optimization that uses memcpy on trivially-copyable types. __builtin_strcpy and __builtin_wcscpy are not handled by this change. They'd be straightforward to add, but we haven't encountered a need for them just yet. This reinstates r338455, reverted in r338602, with a fix to avoid trying to constant-evaluate a memcpy call if either pointer operand has an invalid designator. llvm-svn: 338941
* Properly add shared locks to the initial list of locks being tracked, ↵Aaron Ballman2018-08-031-0/+8
| | | | | | | | instead of assuming unlock functions always use exclusive locks. Patch by Aaron Puchert. llvm-svn: 338912
OpenPOWER on IntegriCloud