================
@@ -516,19 +516,35 @@ class TrivialFunctionAnalysisVisitor
     return Result;
   }
 
+  bool CanTriviallyDestruct(const Type *T) {
+    if (T->isIntegralOrEnumerationType())
+      return true;
+    if (isa<PointerType>(T) || T->isNullPtrType())
+      return true;
+    auto *R = T->getAsCXXRecordDecl();
+    if (!R)
+      return false;
+    auto *Dtor = R->getDestructor();
+    return !Dtor || Dtor->isTrivial() || IsFunctionTrivial(Dtor);
+  }
+
 public:
   using CacheTy = TrivialFunctionAnalysis::CacheTy;
 
   TrivialFunctionAnalysisVisitor(CacheTy &Cache) : Cache(Cache) {}
 
   bool IsFunctionTrivial(const Decl *D) {
-    if (auto *FnDecl = dyn_cast<FunctionDecl>(D)) {
-      if (isNoDeleteFunction(FnDecl))
-        return true;
-      if (FnDecl->isVirtualAsWritten())
-        return false;
-    }
     return WithCachedResult(D, [&]() {
+      if (auto *FnDecl = dyn_cast<FunctionDecl>(D)) {
+        if (isNoDeleteFunction(FnDecl))
+          return true;
+        if (FnDecl->isVirtualAsWritten())
----------------
steakhal wrote:

This is wrong. It will only match if the given specific function had the 
`virtual` keyword.
A method that overrides a virtual wouldn't match this, which is I think not 
what you intended.

https://github.com/llvm/llvm-project/pull/181576
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to