[all-commits] [llvm/llvm-project] 7fcd97: [CIR][CodeGen] Fix wrong destructor placement for ...
Chibuoyim (Wilson) Ogbonna via All-commits
all-commits at lists.llvm.org
Wed Sep 30 13:30:06 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7fcd9732be7d03f2ae338a73953b3423afefc57c
https://github.com/llvm/llvm-project/commit/7fcd9732be7d03f2ae338a73953b3423afefc57c
Author: Chibuoyim (Wilson) Ogbonna <chibuoyim.faith.ogbonna at huawei.com>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
M clang/lib/CIR/CodeGen/CIRGenStmt.cpp
A clang/test/CIR/CodeGen/cleanup-scope-label-attr-block.cpp
Log Message:
-----------
[CIR][CodeGen] Fix wrong destructor placement for label and attributed statements (#226194)
Currently, using this as a sample:
```cpp
#include <cstdio>
struct S {
~S() { puts("~S"); }
};
int main() {
my_label: {
S s;
}
puts("after block");
}
```
with `bin/clang++ test.cpp -fclangir -emit-llvm -S -o -`, in the IR, we
can see that `puts` is called first and the destructor is called
**_later_**. So, when this is built through ClangIR, the output is:
```
after block
~S
```
but it should be (through the OGCG):
```
~S
after block
```
This PR fixes the placement of the destructor, so the object is
destroyed at the end of the labeled block and not in the outer scope.
The bug also occurred for attributed statements (e.g. `[[likely]]`).
Added a lit test.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list