================
@@ -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;
+        }
----------------
Sirraide wrote:

As you already pointed out, this does seem like a weird fix for this. I’m not 
sure this is right. The documentation for `CXXBindTemporaryExpr` states:
```
/// This ensures the destructor is called for the temporary. It should only be
/// needed for non-POD, non-trivially destructable class types.
```
To me at least, this sounds like we should never get here with the destructor 
being null. Perhaps another approach would be to simply ignore the `=` if the 
next token is `{` and parse a function body. 

If the next token is not `{`, then we could ignore everything following it up 
to the next semicolon (unless it’s `= delete`, `= default`, or `= 0`, of 
course), i.e. essentially treat it as though it were `~Foo();`—if that’s not 
too complicated. And if we’re going with that, `assert`ing that the destructor 
is never null here is probably a good idea.

https://github.com/llvm/llvm-project/pull/90220
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to