diff options
author | tomasz-kaminski-sonarsource <79814193+tomasz-kaminski-sonarsource@users.noreply.github.com> | 2023-07-18 16:55:50 +0200 |
---|---|---|
committer | Tomasz Kamiński <tomasz.kamiński@sonarsource.com> | 2023-07-19 09:01:41 +0200 |
commit | c3dd2f35b876f9af39c01de49941a3920fd59a33 (patch) | |
tree | 40541e91483008ea2edd31ab9c32760220d31bad /clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | |
parent | faf77f8dec2f83ada139a0d6fe7acb9b3902ae8b (diff) | |
download | llvm-c3dd2f35b876f9af39c01de49941a3920fd59a33.zip llvm-c3dd2f35b876f9af39c01de49941a3920fd59a33.tar.gz llvm-c3dd2f35b876f9af39c01de49941a3920fd59a33.tar.bz2 |
[analyzer] Model lifetime of a variable declared in for condition in CFG correctly
Per [stmt.for] p1 (https://eel.is/c++draft/stmt.for#1) the following
`for` and `while` statements are equivalent
```
for (; A c = b; b.c) {
A d;
}
while (A c = b) {
A d;
b.c;
}
```
As a consequence, the variable declared for the condition expression
should be destroyed after the increment expression.
This fixed the handling of the object lifetime `continue`, and now
destructors, scope and lifetime elements are present for continue
path in following code:
```
for (; A c = b; b.c) {
if (cond)
continue;
A d;
}
```
Reviewed By: xazax.hun
Differential Revision: https://reviews.llvm.org/D155547
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp')
0 files changed, 0 insertions, 0 deletions