Skip to content

Commit f6712d2

Browse files
committed
[clang][Interp][NFC] Get rid of AutoScope
1 parent 369d3a7 commit f6712d2

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

clang/lib/AST/Interp/Compiler.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,8 @@ bool Compiler<Emitter>::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
17941794

17951795
if (!this->visitArrayElemInit(I, SubExpr))
17961796
return false;
1797+
if (!BS.destroyLocals())
1798+
return false;
17971799
}
17981800
return true;
17991801
}
@@ -3080,7 +3082,7 @@ bool Compiler<Emitter>::VisitStmtExpr(const StmtExpr *E) {
30803082
return false;
30813083
}
30823084

3083-
return true;
3085+
return BS.destroyLocals();
30843086
}
30853087

30863088
template <class Emitter> bool Compiler<Emitter>::discard(const Expr *E) {
@@ -4190,7 +4192,7 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
41904192
this->emitLabel(LabelEnd);
41914193
}
41924194

4193-
return true;
4195+
return IfScope.destroyLocals();
41944196
}
41954197

41964198
template <class Emitter>
@@ -4656,6 +4658,9 @@ bool Compiler<Emitter>::visitFunc(const FunctionDecl *F) {
46564658
if (!this->emitPopPtr(InitExpr))
46574659
return false;
46584660
}
4661+
4662+
if (!Scope.destroyLocals())
4663+
return false;
46594664
}
46604665
}
46614666

clang/lib/AST/Interp/Compiler.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -589,20 +589,10 @@ template <class Emitter> class DestructorScope final {
589589
LocalScope<Emitter> &OtherScope;
590590
};
591591

592-
/// Like a regular LocalScope, except that the destructors of all local
593-
/// variables are automatically emitted when the AutoScope is destroyed.
594-
template <class Emitter> class AutoScope : public LocalScope<Emitter> {
595-
public:
596-
AutoScope(Compiler<Emitter> *Ctx) : LocalScope<Emitter>(Ctx), DS(*this) {}
597-
598-
private:
599-
DestructorScope<Emitter> DS;
600-
};
601-
602592
/// Scope for storage declared in a compound statement.
603-
template <class Emitter> class BlockScope final : public AutoScope<Emitter> {
593+
template <class Emitter> class BlockScope final : public LocalScope<Emitter> {
604594
public:
605-
BlockScope(Compiler<Emitter> *Ctx) : AutoScope<Emitter>(Ctx) {}
595+
BlockScope(Compiler<Emitter> *Ctx) : LocalScope<Emitter>(Ctx) {}
606596

607597
void addExtended(const Scope::Local &Local) override {
608598
// If we to this point, just add the variable as a normal local

0 commit comments

Comments
 (0)