19 using namespace clang;
39 using LabelTy =
typename ByteCodeStmtGen<Emitter>::LabelTy;
45 OldContinueLabel(Ctx->ContinueLabel) {
46 this->Ctx->BreakLabel = BreakLabel;
47 this->Ctx->ContinueLabel = ContinueLabel;
51 this->Ctx->BreakLabel = OldBreakLabel;
52 this->Ctx->ContinueLabel = OldContinueLabel;
63 using LabelTy =
typename ByteCodeStmtGen<Emitter>::LabelTy;
65 using CaseMap =
typename ByteCodeStmtGen<Emitter>::CaseMap;
70 OldDefaultLabel(this->Ctx->DefaultLabel),
71 OldCaseLabels(
std::move(this->Ctx->CaseLabels)) {
72 this->Ctx->BreakLabel = BreakLabel;
73 this->Ctx->DefaultLabel = DefaultLabel;
74 this->Ctx->CaseLabels = std::move(CaseLabels);
78 this->Ctx->BreakLabel = OldBreakLabel;
79 this->Ctx->DefaultLabel = OldDefaultLabel;
80 this->Ctx->CaseLabels = std::move(OldCaseLabels);
92 template <
class Emitter>
98 if (
auto *MD = dyn_cast<CXXMethodDecl>(F))
99 return this->bail(MD);
102 if (!visitStmt(Body))
112 template <
class Emitter>
115 case Stmt::CompoundStmtClass:
116 return visitCompoundStmt(cast<CompoundStmt>(S));
117 case Stmt::DeclStmtClass:
118 return visitDeclStmt(cast<DeclStmt>(S));
119 case Stmt::ReturnStmtClass:
120 return visitReturnStmt(cast<ReturnStmt>(S));
121 case Stmt::IfStmtClass:
122 return visitIfStmt(cast<IfStmt>(S));
123 case Stmt::NullStmtClass:
126 if (
auto *Exp = dyn_cast<Expr>(S))
127 return this->discard(Exp);
128 return this->bail(S);
133 template <
class Emitter>
137 for (
auto *InnerStmt : CompoundStmt->
body())
138 if (!visitStmt(InnerStmt))
143 template <
class Emitter>
145 for (
auto *D : DS->
decls()) {
147 if (
auto *VD = dyn_cast<VarDecl>(D)) {
148 if (!visitVarDecl(VD))
154 if (
auto *DD = dyn_cast<DecompositionDecl>(D)) {
155 return this->bail(DD);
162 template <
class Emitter>
168 if (!this->visit(RE))
171 return this->emitRet(*ReturnType, RS);
174 auto ReturnLocation = [
this, RE] {
return this->emitGetParamPtr(0, RE); };
175 if (!this->visitInitializer(RE, ReturnLocation))
178 return this->emitRetVoid(RS);
182 if (!this->emitRetVoid(RS))
188 template <
class Emitter>
191 if (
auto *CondInit = IS->
getInit())
196 if (!visitDeclStmt(CondDecl))
199 if (!this->visitBool(IS->
getCond()))
203 LabelTy LabelElse = this->getLabel();
204 LabelTy LabelEnd = this->getLabel();
205 if (!this->jumpFalse(LabelElse))
209 if (!this->jump(LabelEnd))
211 this->emitLabel(LabelElse);
212 if (!visitStmt(Else))
214 this->emitLabel(LabelEnd);
216 LabelTy LabelEnd = this->getLabel();
217 if (!this->jumpFalse(LabelEnd))
221 this->emitLabel(LabelEnd);
227 template <
class Emitter>
238 auto Off = this->allocateLocalPrimitive(VD, *T, DT.isConstQualified());
242 if (!this->visit(VD->
getInit()))
246 return this->emitSetLocal(*T, Off, VD);
249 if (
auto Off = this->allocateLocal(VD)) {
250 return this->visitLocalInitializer(VD->
getInit(), *Off);
252 return this->bail(VD);
Represents a function declaration or definition.
Sets the context for break/continue statements.
Stmt - This represents one statement.
typename ByteCodeStmtGen< Emitter >::OptLabelTy OptLabelTy
IfStmt - This represents an if/then/else.
Scope managing label targets.
Represents a variable declaration or definition.
QualType getReturnType() const
LoopScope(ByteCodeStmtGen< Emitter > *Ctx, LabelTy BreakLabel, LabelTy ContinueLabel)
Describes the statement/declaration an opcode was generated from.
Compilation context for statements.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
typename ByteCodeStmtGen< Emitter >::OptLabelTy OptLabelTy
Expression scope which tracks potentially lifetime extended temporaries which are hoisted to the pare...
Scope for storage declared in a compound statement.
CompoundStmt - This represents a group of statements like { stmt stmt }.
This represents one expression.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
typename ByteCodeStmtGen< Emitter >::LabelTy LabelTy
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
ByteCodeStmtGen< Emitter > * Ctx
ByteCodeStmtGen instance.
bool visitFunc(const FunctionDecl *F) override
typename ByteCodeStmtGen< Emitter >::CaseMap CaseMap
Dataflow Directional Tag Classes.
const Expr * getInit() const
StmtClass getStmtClass() const
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
LabelScope(ByteCodeStmtGen< Emitter > *Ctx)
typename Emitter::LabelTy LabelTy
typename ByteCodeStmtGen< Emitter >::LabelTy LabelTy
SwitchScope(ByteCodeStmtGen< Emitter > *Ctx, CaseMap &&CaseLabels, LabelTy BreakLabel, OptLabelTy DefaultLabel)