summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-unsequenced.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Sema] SequenceChecker: C++17 sequencing rules for built-in operators <<, ↵Bruno Ricci2019-12-221-20/+69
| | | | | | | | | | | >>, .*, ->*, =, op= Implement the C++17 sequencing rules for the built-in operators <<, >>, .*, ->*, = and op=. Differential Revision: https://reviews.llvm.org/D58297 Reviewed By: rsmith
* [Sema] SequenceChecker: Fix handling of operator ||, && and ?:Bruno Ricci2019-12-221-8/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | The current handling of the operators ||, && and ?: has a number of false positive and false negative. The issues for operator || and && are: 1. We need to add sequencing regions for the LHS and RHS as is done for the comma operator. Not doing so causes false positives in expressions like `((a++, false) || (a++, false))` (from PR39779, see PR22197 for another example). 2. In the current implementation when the evaluation of the LHS fails, the RHS is added to a worklist to be processed later. This results in false negatives in expressions like `(a && a++) + a`. Fix these issues by introducing sequencing regions for the LHS and RHS, and by not deferring the visitation of the RHS. The issues with the ternary operator ?: are similar, with the added twist that we should not warn on expressions like `(x ? y += 1 : y += 2)` since exactly one of the 2nd and 3rd expression is going to be evaluated, but we should still warn on expressions like `(x ? y += 1 : y += 2) = y`. Differential Revision: https://reviews.llvm.org/D57747 Reviewed By: rsmith
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-061-2/+2
| | | | | | | | | where either the modification or the other access is unreachable. This reverts r359984 (which reverted r359962). The bug in clang-tidy's test suite exposed by the original commit was fixed in r360009. llvm-svn: 360010
* Revert rL359962 : Use DiagRuntimeBehavior for -Wunsequenced to weed out ↵Simon Pilgrim2019-05-051-2/+2
| | | | | | | | | | false positives where either the modification or the other access is unreachable. ........ Try to fix buildbots llvm-svn: 359984
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-041-2/+2
| | | | | | where either the modification or the other access is unreachable. llvm-svn: 359962
* [Sema][NFC] SequenceChecker: More tests in preparation for D57660Bruno Ricci2019-02-231-5/+148
| | | | llvm-svn: 354727
* [Sema][NFC] SequenceChecker: Add tests for references/members, and prepare ↵Bruno Ricci2019-02-151-37/+246
| | | | | | | | | | | | | for the C++17 tests Add some tests for unsequenced operations with members and references. For now most of it is unhandled but it shows what work needs to be done. Also merge the tests for the C++17 sequencing rules in warn-unsequenced.cpp since we want to make sure that the appropriate warnings are still present in C++17 without duplicating the whole content of warn-unsequenced.cpp. llvm-svn: 354151
* Fix false positive unsequenced access and modification warning in array ↵Nicolas Lesser2019-01-101-0/+1
| | | | | | | | | | | | | | | | | | | | subscript expression. Summary: In the [expr.sub] p1, we can read that for a given E1[E2], E1 is sequenced before E2. Patch by Mateusz Janek. Reviewers: rsmith, Rakete1111 Reviewed By: rsmith, Rakete1111 Subscribers: riccibruno, lebedev.ri, Rakete1111, hiraditya, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D50766 llvm-svn: 350874
* Fix false positive in -Wunsequenced and templates.Richard Trieu2016-08-051-0/+55
| | | | | | | | | | | | | | For builtin logical operators, there is a well-defined ordering of argument evaluation. For overloaded operator of the same type, there is no argument evaluation order, similar to other function calls. When both are present, uninstantiated templates with an operator&& is treated as an unresolved function call. Unresolved function calls are treated as normal function calls, and may result in false positives when the builtin logical operator is used. Have the unsequenced checker ignore dependent expressions to avoid this false positive. The check also happens in template instantiations to catch when the overloaded operator is used. llvm-svn: 277866
* Teach -Wunsequenced that the side-effects of a function evaluation are sequencedRichard Smith2013-06-301-1/+11
| | | | | | | | | before the value computation of the result. In C, this is implied by there being a sequence point after their evaluation, and in C++, it's implied by the side-effects being sequenced before the expressions and statements in the function body. llvm-svn: 185282
* PR16467: Teach -Wunsequenced that in C11 (unlike C++11), an assignment'sRichard Smith2013-06-261-0/+2
| | | | | | | | side-effect is not sequenced before its value computation. Also fix a mishandling of ?: expressions where the condition is constant that was exposed by the tests for this. llvm-svn: 185035
* Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor notRichard Smith2013-01-171-0/+5
| | | | | | to visit them. llvm-svn: 172769
* -Wunsequenced: if the LHS of an &&, || or ?: is not constant, check forRichard Smith2013-01-171-0/+7
| | | | | | | | | unsequenced operations in the RHS. We don't compare the RHS with the rest of the expression yet; such checks will need care to avoid diagnosing unsequenced operations which are both in conditionally-evaluated subexpressions which actually can't occur together, such as in '(b && ++x) + (!b && ++x)'. llvm-svn: 172760
* Add -Wunsequenced (with compatibility alias -Wsequence-point) to warn onRichard Smith2013-01-171-0/+91
expressions which have undefined behavior due to multiple unsequenced modifications or an unsequenced modification and use of a variable. llvm-svn: 172690
OpenPOWER on IntegriCloud