summaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.h
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-06-30 16:59:57 +0200
committerGitHub <noreply@github.com>2025-06-30 16:59:57 +0200
commit00cdaa5c395c122f8ede2a4b0587bf9a0dfecc2a (patch)
tree53681e3d133c3951d31888f03ebed4a8e53fb041 /clang/lib/AST/ByteCode/Compiler.h
parent53102a395f3bd07762c183c9ecd213a4759559dd (diff)
[clang][bytecode] Add `Descriptor::hasTrivialDtor()` (#146286)
We sometimes used to have a long list of ``` GetLocalPtr PopPtr [...] ``` ops at the end of scopes, because we first got a pointer to a local variable and only then did we figure out that we didn't actually want to call the destructor for it. Add a new function that allows us to just ask the `Descriptor` whether we need to call its destructor.
Diffstat (limited to 'clang/lib/AST/ByteCode/Compiler.h')
-rw-r--r--clang/lib/AST/ByteCode/Compiler.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h
index a1d068cc7e0a..1a5fd8678587 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -574,17 +574,17 @@ public:
// Emit destructor calls for local variables of record
// type with a destructor.
for (Scope::Local &Local : llvm::reverse(this->Ctx->Descriptors[*Idx])) {
- if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
- if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
- return false;
+ if (Local.Desc->hasTrivialDtor())
+ continue;
+ if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
+ return false;
- if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
- return false;
+ if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
+ return false;
- if (!this->Ctx->emitPopPtr(E))
- return false;
- removeIfStoredOpaqueValue(Local);
- }
+ if (!this->Ctx->emitPopPtr(E))
+ return false;
+ removeIfStoredOpaqueValue(Local);
}
return true;
}