Skip to content
Commit c3dd2f35 authored by tomasz-kaminski-sonarsource's avatar tomasz-kaminski-sonarsource Committed by Tomasz Kamiński
Browse files

[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
parent faf77f8d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment