[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 10:54:34 PST 2022
akyrtzi updated this revision to Diff 411186.
akyrtzi added a comment.
Move the `const_cast` to the call site.
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 %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.411186.patch
Type: text/x-patch
Size: 1136 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220224/60346234/attachment.bin>
More information about the cfe-commits
mailing list