-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][Interp] Convert blocks to DeadBlocks when destroying frames #101794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesThis doesn't fix the attached test case, but at least we're not crashing anymore. Full diff: https://github.com/llvm/llvm-project/pull/101794.diff 2 Files Affected:
diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp
index 1c37450ae1c6e..9e7bf9972a578 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -75,9 +75,7 @@ InterpFrame::~InterpFrame() {
if (Func) {
for (auto &Scope : Func->scopes()) {
for (auto &Local : Scope.locals()) {
- Block *B = localBlock(Local.Offset);
- if (B->isInitialized())
- B->invokeDtor();
+ S.deallocate(localBlock(Local.Offset));
}
}
}
diff --git a/clang/test/AST/Interp/new-delete.cpp b/clang/test/AST/Interp/new-delete.cpp
index ae76950f13731..ddf91005c61d9 100644
--- a/clang/test/AST/Interp/new-delete.cpp
+++ b/clang/test/AST/Interp/new-delete.cpp
@@ -564,6 +564,27 @@ namespace DeleteThis {
// both-note {{in call to 'super_secret_double_delete()'}}
}
+/// FIXME: This is currently diagnosed, but should work.
+/// If the destructor for S is _not_ virtual however, it should fail.
+namespace CastedDelete {
+ struct S {
+ constexpr S(int *p) : p(p) {}
+ constexpr virtual ~S() { *p = 1; }
+ int *p;
+ };
+ struct T: S {
+ // implicit destructor defined eagerly because it is constexpr and virtual
+ using S::S;
+ };
+
+ constexpr int vdtor_1() {
+ int a;
+ delete (S*)new T(&a); // expected-note {{delete of pointer to subobject}}
+ return a;
+ }
+ static_assert(vdtor_1() == 1); // expected-error {{not an integral constant expression}} \
+ // expected-note {{in call to}}
+}
#else
/// Make sure we reject this prior to C++20
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/3135 Here is the relevant piece of the build log for the reference:
|
This doesn't fix the attached test case, but at least we're not crashing anymore.