-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang][bytecode][NFC] Remove VariableScope::emitDestruction #169148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
destroyLocals() does the same thing.
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesdestroyLocals() does the same thing. Full diff: https://github.com/llvm/llvm-project/pull/169148.diff 2 Files Affected:
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 8f8f3d6a05820..725db1f77f29c 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 0c6cab9276531..359bf28a51c6e 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -258,7 +258,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
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 @@ template <class Emitter> class VariableScope {
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 @@ template <class Emitter> class LocalScope : public VariableScope<Emitter> {
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)
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/42435 Here is the relevant piece of the build log for the reference |
…9148) destroyLocals() does the same thing.
…9148) destroyLocals() does the same thing.
destroyLocals() does the same thing.