[clang] [clang] Fix crash when destructor definition is preceded with '=' (PR #90220)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 27 12:09:05 PDT 2024


================
@@ -3893,9 +3893,12 @@ namespace {
     }
 
     void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) {
-      if (E->getTemporary()->getDestructor()->isTrivial()) {
-        Inherited::VisitStmt(E);
-        return;
+      if (const CXXDestructorDecl *DtorDecl =
+              E->getTemporary()->getDestructor()) {
+        if (DtorDecl->isTrivial()) {
+          Inherited::VisitStmt(E);
+          return;
+        }
----------------
Endilll wrote:

It looks like it's normal for `nullptr` to slip into `CXXTemporary` as destructor:
https://github.com/llvm/llvm-project/blob/9145514fde484916971e6bb147c18f9235a9f2b5/clang/lib/Sema/SemaExprCXX.cpp#L7611-L7630
So the check I added might be a check in the right place.

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


More information about the cfe-commits mailing list