-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
[clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) #89734
base: main
Are you sure you want to change the base?
[clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) #89734
Conversation
@llvm/pr-subscribers-clang Author: Stefan Gränitz (weliveindetail) ChangesThis patch adds test coverage for an edge case that is supported already. Full diff: https://github.com/llvm/llvm-project/pull/89734.diff 1 Files Affected:
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
|
(GuardX(x)) | ||
|
||
// CHECK-NOT: Symbols not found | ||
// CHECK-NOT: _ZN6GuardXIiED2Ev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a check like below that is more explicit, but we recognize expressions for value printing (the thing we parse as "semi-missing") only in trailing statements. If we added the code below, then (GuardX(x))
is not considered trailing anymore, because we pipe he whole file into clang-repl.
#include <cstdint>
auto x_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(x));
extern "C" int printf(const char *, ...);
printf("0x%016" PRIx64 "\n", x_addr);
// CHECK: 0x00000000000000000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a printf in the dtor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
3ae15ad
to
9e8dd76
Compare
Oh interesting, the Windows test actually fails at this assertion:
@vgvassilev Any ideas? |
We generally have to put a switch for the late parsed templates. We have it in some other tests. |
This patch adds test coverage for an edge case that is supported already.