https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/89734
From 085a93919d8f65419cc856fe5584c83d3eceb142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graen...@gmail.com> Date: Tue, 23 Apr 2024 12:23:11 +0200 Subject: [PATCH 1/2] [clang-repl] Add test for explicit emission of dtors in the runtime interface builder --- clang/test/Interpreter/force-codegen-dtor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 clang/test/Interpreter/force-codegen-dtor.cpp diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp new file mode 100644 index 00000000000000..a299ea46d5eac0 --- /dev/null +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -0,0 +1,13 @@ +// UNSUPPORTED: system-aix + +// RUN: cat %s | clang-repl | FileCheck %s +int *x = new int(); +template <class T> struct GuardX { T *&x; GuardX(T *&x) : x(x) {}; ~GuardX(); }; +template <class T> GuardX<T>::~GuardX() { delete x; x = nullptr; } + +// clang would normally defer codegen for ~GuardX() +// Make sure that RuntimeInterfaceBuilder requests it explicitly +(GuardX(x)) + +// CHECK-NOT: Symbols not found +// CHECK-NOT: _ZN6GuardXIiED2Ev From 6fab67a6cf689c33a93748c66414050dfdf43d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graen...@gmail.com> Date: Tue, 23 Apr 2024 14:06:57 +0200 Subject: [PATCH 2/2] Add printf in dtor --- clang/test/Interpreter/force-codegen-dtor.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/test/Interpreter/force-codegen-dtor.cpp b/clang/test/Interpreter/force-codegen-dtor.cpp index a299ea46d5eac0..07758bb3fa0991 100644 --- a/clang/test/Interpreter/force-codegen-dtor.cpp +++ b/clang/test/Interpreter/force-codegen-dtor.cpp @@ -1,13 +1,17 @@ +// REQUIRES: host-supports-jit // UNSUPPORTED: system-aix // RUN: cat %s | clang-repl | FileCheck %s int *x = new int(); template <class T> struct GuardX { T *&x; GuardX(T *&x) : x(x) {}; ~GuardX(); }; -template <class T> GuardX<T>::~GuardX() { delete x; x = nullptr; } -// clang would normally defer codegen for ~GuardX() -// Make sure that RuntimeInterfaceBuilder requests it explicitly +// clang normally defers codegen for this out-of-line ~GuardX(), which would +// cause the JIT to report Symbols not found: [ _ZN6GuardXIiED2Ev ] +extern "C" int printf(const char *, ...); +template <class T> GuardX<T>::~GuardX() { delete x; printf("Running dtor\n"); } + +// Let's make sure that the RuntimeInterfaceBuilder requests it explicitly: (GuardX(x)) // CHECK-NOT: Symbols not found -// CHECK-NOT: _ZN6GuardXIiED2Ev +// CHECK: Running dtor _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits