https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/112841
This is what the current interpreter does as well. >From 349cda342a9febd60419ea53ea34cdf8a7b2523f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Fri, 18 Oct 2024 06:25:29 +0200 Subject: [PATCH] [clang][bytecode] Ignore explicit calls to trivial dtors This is what the current interpreter does as well. --- clang/lib/AST/ByteCode/Compiler.cpp | 4 ++++ clang/test/AST/ByteCode/placement-new.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 8ca63bf64aa0ef..a71c0dcc9381e8 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -4535,6 +4535,10 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) { return VisitBuiltinCallExpr(E, Builtin::BI__builtin_operator_delete); } } + // Explicit calls to trivial destructors + if (const auto *DD = dyn_cast_if_present<CXXDestructorDecl>(FuncDecl); + DD && DD->isTrivial()) + return true; QualType ReturnType = E->getCallReturnType(Ctx.getASTContext()); std::optional<PrimType> T = classify(ReturnType); diff --git a/clang/test/AST/ByteCode/placement-new.cpp b/clang/test/AST/ByteCode/placement-new.cpp index 8e6d802e93295c..5673b5cba3f700 100644 --- a/clang/test/AST/ByteCode/placement-new.cpp +++ b/clang/test/AST/ByteCode/placement-new.cpp @@ -311,3 +311,16 @@ constexpr bool change_union_member() { return u.b == 2; } static_assert(change_union_member()); + +namespace PR48606 { + struct A { mutable int n = 0; }; + + constexpr bool f() { + A a; + A *p = &a; + p->~A(); + std::construct_at<A>(p); + return true; + } + static_assert(f()); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits