forked from OSchip/llvm-project
[mlir] Add workaround for false positive in -Wfree-nonheap-object
Restore499571ea83
reverted by0082764605
. A compiler slightly older than "[clang][Sema] removes -Wfree-nonheap-object reference param false positive" may report the false positive. We need to retain the workaround a bit longer so that such compilers can be used to compile MLIR in a warning-free way.
This commit is contained in:
parent
db7efcab7d
commit
bcf6f641ac
|
@ -237,7 +237,9 @@ detail::OperandStorage::~OperandStorage() {
|
|||
if (isDynamicStorage()) {
|
||||
TrailingOperandStorage &storage = getDynamicStorage();
|
||||
storage.~TrailingOperandStorage();
|
||||
free(&storage);
|
||||
// Work around -Wfree-nonheap-object false positive fixed by D102728.
|
||||
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()) {
|
||||
// Work around -Wfree-nonheap-object false positive fixed by D102728.
|
||||
auto *mem = &storage;
|
||||
free(mem);
|
||||
}
|
||||
|
||||
// Update the storage representation to use the new dynamic storage.
|
||||
dynamicStorage.setPointerAndInt(newStorage, true);
|
||||
|
|
Loading…
Reference in New Issue