[all-commits] [llvm/llvm-project] af2bb8: [Clang] Correctly handle allocations in the condit...
Corentin Jabot via All-commits
all-commits at lists.llvm.org
Fri Jul 4 06:40:50 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: af2bb8f826050402fa9c6a6be8475808dcb63df0
https://github.com/llvm/llvm-project/commit/af2bb8f826050402fa9c6a6be8475808dcb63df0
Author: Corentin Jabot <corentinjabot at gmail.com>
Date: 2025-07-04 (Fri, 04 Jul 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Sema/Sema.h
M clang/lib/Parse/ParseExprCXX.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/lib/Sema/SemaExprCXX.cpp
M clang/lib/Sema/TreeTransform.h
M clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
Log Message:
-----------
[Clang] Correctly handle allocations in the condition of a `if constexpr` (#146890)
Deal with the following scenario
```cpp
struct S {
char* c = new char;
constexpr ~S() {
delete c;
}
};
if constexpr((S{}, true)){};
```
There were two issues
- We need to produce a full expression _before_ evaluating the condition
(otherwise, automatic variables are never destroyed)
- We need to preserve the evaluation context of the condition while
doing the semantics analysis for it (lest it is evaluated in a
non-constant-evaluated context)
Fixes #120197
Fixes #134820
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