summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-11-22 16:41:00 +0100
committerGitHub <noreply@github.com>2025-11-22 16:41:00 +0100
commitcc4dd015ad4a1b33d43fbac00d62f6b309a96ff4 (patch)
tree9facf4ca92d0d3678ef305037bec097c33436b4d
parent2e424deeb6180d112323f4df955c8034eb56780c (diff)
[clang][bytecode][NFC] Remove VariableScope::emitDestruction (#169148)
destroyLocals() does the same thing.
-rw-r--r--clang/lib/AST/ByteCode/Compiler.cpp21
-rw-r--r--clang/lib/AST/ByteCode/Compiler.h12
2 files changed, 15 insertions, 18 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 8f8f3d6a0582..725db1f77f29 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5939,8 +5939,10 @@ bool Compiler<Emitter>::visitBreakStmt(const BreakStmt *S) {
assert(TargetLabel);
for (VariableScope<Emitter> *C = this->VarScope; C != BreakScope;
- C = C->getParent())
- C->emitDestruction();
+ C = C->getParent()) {
+ if (!C->destroyLocals())
+ return false;
+ }
return this->jump(*TargetLabel);
}
@@ -5974,8 +5976,10 @@ bool Compiler<Emitter>::visitContinueStmt(const ContinueStmt *S) {
assert(TargetLabel);
for (VariableScope<Emitter> *C = VarScope; C != ContinueScope;
- C = C->getParent())
- C->emitDestruction();
+ C = C->getParent()) {
+ if (!C->destroyLocals())
+ return false;
+ }
return this->jump(*TargetLabel);
}
@@ -7159,9 +7163,12 @@ bool Compiler<Emitter>::VisitDeclRefExpr(const DeclRefExpr *E) {
return this->visitDeclRef(D, E);
}
-template <class Emitter> void Compiler<Emitter>::emitCleanup() {
- for (VariableScope<Emitter> *C = VarScope; C; C = C->getParent())
- C->emitDestruction();
+template <class Emitter> bool Compiler<Emitter>::emitCleanup() {
+ for (VariableScope<Emitter> *C = VarScope; C; C = C->getParent()) {
+ if (!C->destroyLocals())
+ return false;
+ }
+ return true;
}
template <class Emitter>
diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h
index 0c6cab927653..359bf28a51c6 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -258,7 +258,7 @@ protected:
protected:
/// Emits scope cleanup instructions.
- void emitCleanup();
+ bool emitCleanup();
/// Returns a record type from a record or pointer type.
const RecordType *getRecordTy(QualType Ty);
@@ -524,7 +524,6 @@ public:
this->addLocal(Local);
}
- virtual void emitDestruction() {}
virtual bool emitDestructors(const Expr *E = nullptr) { return true; }
virtual bool destroyLocals(const Expr *E = nullptr) { return true; }
VariableScope *getParent() const { return Parent; }
@@ -555,15 +554,6 @@ public:
removeStoredOpaqueValues();
}
- /// Overriden to support explicit destruction.
- void emitDestruction() override {
- if (!Idx)
- return;
-
- this->emitDestructors();
- this->Ctx->emitDestroy(*Idx, SourceInfo{});
- }
-
/// Explicit destruction of local variables.
bool destroyLocals(const Expr *E = nullptr) override {
if (!Idx)