[PATCH] D155547: CPP-4580 Model lifetime of a variable declared in for condition in CFG correctly
Tomasz Kamiński via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 17 23:21:17 PDT 2023
tomasz-kaminski-sonarsource created this revision.
Herald added a reviewer: NoQ.
Herald added a project: All.
tomasz-kaminski-sonarsource requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Per [stmt.for] p1 (https://eel.is/c++draft/stmt.for#1) the following
'for' and `while` statement are equivalent
for (; A c = b; b.c) {
A d;
}
while (A c = b) {
A d;
b.c;
}
As a consequence, the variable declared in for condition expression
should be destroyed after the increment expression.
Co-authored-by: Tomasz Kamiński <tomasz.kamiński at sonarsource.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155547
Files:
clang/lib/Analysis/CFG.cpp
clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
clang/test/Analysis/lifetime-cfg-output.cpp
clang/test/Analysis/scopes-cfg-output.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155547.541327.patch
Type: text/x-patch
Size: 8910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230718/ccd6603a/attachment-0001.bin>
More information about the cfe-commits
mailing list