diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index d0ddb2eb8d4be..96c4694b02c3d 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -106,25 +106,14 @@ bool InitLink::emit(Compiler *Ctx, const Expr *E) const { return true; } -/// Scope managing label targets. -template class LabelScope { -public: - virtual ~LabelScope() {} - -protected: - LabelScope(Compiler *Ctx) : Ctx(Ctx) {} - /// Compiler instance. - Compiler *Ctx; -}; - /// Sets the context for break/continue statements. -template class LoopScope final : public LabelScope { +template class LoopScope final { public: using LabelTy = typename Compiler::LabelTy; using OptLabelTy = typename Compiler::OptLabelTy; LoopScope(Compiler *Ctx, LabelTy BreakLabel, LabelTy ContinueLabel) - : LabelScope(Ctx), OldBreakLabel(Ctx->BreakLabel), + : Ctx(Ctx), OldBreakLabel(Ctx->BreakLabel), OldContinueLabel(Ctx->ContinueLabel), OldBreakVarScope(Ctx->BreakVarScope), OldContinueVarScope(Ctx->ContinueVarScope) { @@ -142,6 +131,7 @@ template class LoopScope final : public LabelScope { } private: + Compiler *Ctx; OptLabelTy OldBreakLabel; OptLabelTy OldContinueLabel; VariableScope *OldBreakVarScope; @@ -149,7 +139,7 @@ template class LoopScope final : public LabelScope { }; // Sets the context for a switch scope, mapping labels. -template class SwitchScope final : public LabelScope { +template class SwitchScope final { public: using LabelTy = typename Compiler::LabelTy; using OptLabelTy = typename Compiler::OptLabelTy; @@ -157,7 +147,7 @@ template class SwitchScope final : public LabelScope { SwitchScope(Compiler *Ctx, CaseMap &&CaseLabels, LabelTy BreakLabel, OptLabelTy DefaultLabel) - : LabelScope(Ctx), OldBreakLabel(Ctx->BreakLabel), + : Ctx(Ctx), OldBreakLabel(Ctx->BreakLabel), OldDefaultLabel(this->Ctx->DefaultLabel), OldCaseLabels(std::move(this->Ctx->CaseLabels)), OldLabelVarScope(Ctx->BreakVarScope) { @@ -175,6 +165,7 @@ template class SwitchScope final : public LabelScope { } private: + Compiler *Ctx; OptLabelTy OldBreakLabel; OptLabelTy OldDefaultLabel; CaseMap OldCaseLabels;