================
@@ -1951,7 +1957,11 @@ TypeTraitExpr *TypeTraitExpr::Create(const ASTContext 
&C, QualType T,
                                      SourceLocation RParenLoc, APValue Value) {
   void *Mem =
       C.Allocate(totalSizeToAlloc<APValue, TypeSourceInfo *>(1, Args.size()));
-  return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value);
+  auto *E =
+      new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, std::move(Value));
+  if (E->getTrailingObjects<APValue>()->needsCleanup())
+    C.addDestruction(E->getTrailingObjects<APValue>());
----------------
Tsche wrote:

I believe we do need cleanup for the array case (string trait result is stored 
as array in APValue to avoid adding another trailing obj)

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

Reply via email to