[clang] [clang-repl] Test explicit emission of dtors in runtime interface builder (NFC) (PR #89734)

Stefan Gränitz via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 03:34:45 PDT 2024


================
@@ -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
----------------
weliveindetail wrote:

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
```

https://github.com/llvm/llvm-project/pull/89734


More information about the cfe-commits mailing list