Skip to content

Commit

Permalink
Add workaround for false positive in -Wfree-nonheap-object
Browse files Browse the repository at this point in the history
  • Loading branch information
dwblaikie committed Apr 3, 2021
1 parent 2554f99 commit 499571e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mlir/lib/IR/OperationSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 499571e

Please sign in to comment.