[Mlir-commits] [mlir] 499571e - Add workaround for false positive in -Wfree-nonheap-object

David Blaikie llvmlistbot at llvm.org
Sat Apr 3 14:21:23 PDT 2021


Author: David Blaikie
Date: 2021-04-03T14:03:43-07:00
New Revision: 499571ea835daf786626a0db1e12f890b6cd8f8d

URL: https://github.com/llvm/llvm-project/commit/499571ea835daf786626a0db1e12f890b6cd8f8d
DIFF: https://github.com/llvm/llvm-project/commit/499571ea835daf786626a0db1e12f890b6cd8f8d.diff

LOG: Add workaround for false positive in -Wfree-nonheap-object

Added: 
    

Modified: 
    mlir/lib/IR/OperationSupport.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index c60e05665142..fc7cf9310a83 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -237,7 +237,9 @@ detail::OperandStorage::~OperandStorage() {
   if (isDynamicStorage()) {
     TrailingOperandStorage &storage = getDynamicStorage();
     storage.~TrailingOperandStorage();
-    free(&storage);
+    // Workaround false positive in -Wfree-nonheap-object
+    auto *mem = &storage;
+    free(mem);
   } else {
     getInlineStorage().~TrailingOperandStorage();
   }
@@ -371,8 +373,11 @@ MutableArrayRef<OpOperand> detail::OperandStorage::resize(Operation *owner,
     new (&newOperands[numOperands]) OpOperand(owner);
 
   // If the current storage is also dynamic, free it.
-  if (isDynamicStorage())
-    free(&storage);
+  if (isDynamicStorage()) {
+    // Workaround false positive in -Wfree-nonheap-object
+    auto *mem = &storage;
+    free(mem);
+  }
 
   // Update the storage representation to use the new dynamic storage.
   representation = reinterpret_cast<intptr_t>(newStorage);


        


More information about the Mlir-commits mailing list