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

This commit is contained in:
David Blaikie 2021-04-03 14:00:30 -07:00
parent 2554f99b55
commit 499571ea83
1 changed files with 8 additions and 3 deletions

View File

@ -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);