[PATCH] D120426: [Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr`

Argyrios Kyrtzidis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 24 12:56:32 PST 2022


akyrtzi updated this revision to Diff 411219.
akyrtzi added a comment.

Add a target triple to the test, so it can pass on windows.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120426/new/

https://reviews.llvm.org/D120426

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp


Index: clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: define linkonce_odr {{.*}} @_ZN3StrD1Ev
+
+class A {
+public:
+  ~A();
+};
+class Str {
+  A d;
+
+public:
+  ~Str() = default;
+};
+class E {
+  Str s;
+  template <typename>
+  void h() {
+    s = {};
+  }
+  void f();
+};
+void E::f() {
+  h<int>();
+}
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12748,6 +12748,9 @@
 template<typename Derived>
 ExprResult
 TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
+  if (auto *Dtor = E->getTemporary()->getDestructor())
+    SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
+                                   const_cast<CXXDestructorDecl *>(Dtor));
   return getDerived().TransformExpr(E->getSubExpr());
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120426.411219.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220224/1abce7a7/attachment.bin>


More information about the cfe-commits mailing list