clang 17.0.0git
ByteCodeExprGen.h
Go to the documentation of this file.
1//===--- ByteCodeExprGen.h - Code generator for expressions -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines the constexpr bytecode compiler.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H
14#define LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H
15
16#include "ByteCodeEmitter.h"
17#include "EvalEmitter.h"
18#include "Pointer.h"
19#include "PrimType.h"
20#include "Record.h"
21#include "clang/AST/Decl.h"
22#include "clang/AST/Expr.h"
25
26namespace clang {
27class QualType;
28
29namespace interp {
30
31template <class Emitter> class LocalScope;
32template <class Emitter> class DestructorScope;
33template <class Emitter> class RecordScope;
34template <class Emitter> class VariableScope;
35template <class Emitter> class DeclScope;
36template <class Emitter> class OptionScope;
37template <class Emitter> class ArrayIndexScope;
38
39/// Compilation context for expressions.
40template <class Emitter>
41class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
42 public Emitter {
43protected:
44 // Aliases for types defined in the emitter.
45 using LabelTy = typename Emitter::LabelTy;
46 using AddrTy = typename Emitter::AddrTy;
47
48 /// Current compilation context.
50 /// Program to link to.
52
53public:
54 /// Initializes the compiler and the backend emitter.
55 template <typename... Tys>
56 ByteCodeExprGen(Context &Ctx, Program &P, Tys &&... Args)
57 : Emitter(Ctx, P, Args...), Ctx(Ctx), P(P) {}
58
59 // Expression visitors - result returned on interp stack.
60 bool VisitCastExpr(const CastExpr *E);
63 bool VisitParenExpr(const ParenExpr *E);
65 bool VisitLogicalBinOp(const BinaryOperator *E);
68 bool VisitCallExpr(const CallExpr *E);
69 bool VisitBuiltinCallExpr(const CallExpr *E);
74 bool VisitCXXThisExpr(const CXXThisExpr *E);
75 bool VisitUnaryOperator(const UnaryOperator *E);
76 bool VisitDeclRefExpr(const DeclRefExpr *E);
80 bool VisitInitListExpr(const InitListExpr *E);
81 bool VisitConstantExpr(const ConstantExpr *E);
83 bool VisitMemberExpr(const MemberExpr *E);
87 bool VisitStringLiteral(const StringLiteral *E);
95 bool VisitTypeTraitExpr(const TypeTraitExpr *E);
96
97protected:
98 bool visitExpr(const Expr *E) override;
99 bool visitDecl(const VarDecl *VD) override;
100
101protected:
102 /// Emits scope cleanup instructions.
103 void emitCleanup();
104
105 /// Returns a record type from a record or pointer type.
107
108 /// Returns a record from a record or pointer type.
110 Record *getRecord(const RecordDecl *RD);
111
112 // Returns a function for the given FunctionDecl.
113 // If the function does not exist yet, it is compiled.
114 const Function *getFunction(const FunctionDecl *FD);
115
116 /// Classifies a type.
117 std::optional<PrimType> classify(const Expr *E) const {
118 return E->isGLValue() ? PT_Ptr : classify(E->getType());
119 }
120 std::optional<PrimType> classify(QualType Ty) const {
121 return Ctx.classify(Ty);
122 }
123
124 /// Classifies a known primitive type
126 if (auto T = classify(Ty)) {
127 return *T;
128 }
129 llvm_unreachable("not a primitive type");
130 }
131
132 /// Evaluates an expression for side effects and discards the result.
133 bool discard(const Expr *E);
134 /// Evaluates an expression and places result on stack.
135 bool visit(const Expr *E);
136 /// Compiles an initializer.
137 bool visitInitializer(const Expr *E);
138 /// Compiles an array initializer.
140 /// Compiles a record initializer.
142 /// Creates and initializes a variable from the given decl.
143 bool visitVarDecl(const VarDecl *VD);
144
145 /// Visits an expression and converts it to a boolean.
146 bool visitBool(const Expr *E);
147
148 /// Visits an initializer for a local.
149 bool visitLocalInitializer(const Expr *Init, unsigned I) {
150 if (!this->emitGetPtrLocal(I, Init))
151 return false;
152
153 if (!visitInitializer(Init))
154 return false;
155
156 return this->emitPopPtr(Init);
157 }
158
159 /// Visits an initializer for a global.
160 bool visitGlobalInitializer(const Expr *Init, unsigned I) {
161 if (!this->emitGetPtrGlobal(I, Init))
162 return false;
163
164 if (!visitInitializer(Init))
165 return false;
166
167 if (Init->getType()->isRecordType() && !this->emitCheckGlobalCtor(Init))
168 return false;
169
170 return this->emitPopPtr(Init);
171 }
172
173 /// Visits a delegated initializer.
174 bool visitThisInitializer(const Expr *I) {
175 if (!this->emitThis(I))
176 return false;
177
178 if (!visitInitializer(I))
179 return false;
180
181 return this->emitPopPtr(I);
182 }
183
185 llvm::function_ref<bool(const Expr *)> V);
186
187 /// Creates a local primitive value.
188 unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,
189 bool IsExtended = false);
190
191 /// Allocates a space storing a local given its type.
192 std::optional<unsigned> allocateLocal(DeclTy &&Decl, bool IsExtended = false);
193
194private:
195 friend class VariableScope<Emitter>;
196 friend class LocalScope<Emitter>;
197 friend class DestructorScope<Emitter>;
198 friend class RecordScope<Emitter>;
199 friend class DeclScope<Emitter>;
200 friend class OptionScope<Emitter>;
201 friend class ArrayIndexScope<Emitter>;
202
203 /// Emits a zero initializer.
204 bool visitZeroInitializer(QualType QT, const Expr *E);
205
206 enum class DerefKind {
207 /// Value is read and pushed to stack.
208 Read,
209 /// Direct method generates a value which is written. Returns pointer.
210 Write,
211 /// Direct method receives the value, pushes mutated value. Returns pointer.
212 ReadWrite,
213 };
214
215 /// Method to directly load a value. If the value can be fetched directly,
216 /// the direct handler is called. Otherwise, a pointer is left on the stack
217 /// and the indirect handler is expected to operate on that.
218 bool dereference(const Expr *LV, DerefKind AK,
219 llvm::function_ref<bool(PrimType)> Direct,
220 llvm::function_ref<bool(PrimType)> Indirect);
221 bool dereferenceParam(const Expr *LV, PrimType T, const ParmVarDecl *PD,
222 DerefKind AK,
223 llvm::function_ref<bool(PrimType)> Direct,
224 llvm::function_ref<bool(PrimType)> Indirect);
225 bool dereferenceVar(const Expr *LV, PrimType T, const VarDecl *PD,
226 DerefKind AK, llvm::function_ref<bool(PrimType)> Direct,
227 llvm::function_ref<bool(PrimType)> Indirect);
228
229 /// Emits an APSInt constant.
230 bool emitConst(const llvm::APSInt &Value, const Expr *E);
231 bool emitConst(const llvm::APInt &Value, const Expr *E) {
232 return emitConst(static_cast<llvm::APSInt>(Value), E);
233 }
234
235 /// Emits an integer constant.
236 template <typename T> bool emitConst(T Value, const Expr *E);
237
238 /// Returns the CXXRecordDecl for the type of the given expression,
239 /// or nullptr if no such decl exists.
240 const CXXRecordDecl *getRecordDecl(const Expr *E) const {
241 QualType T = E->getType();
242 if (const auto *RD = T->getPointeeCXXRecordDecl())
243 return RD;
244 return T->getAsCXXRecordDecl();
245 }
246
247 /// Returns whether we should create a global variable for the
248 /// given ValueDecl.
249 bool shouldBeGloballyIndexed(const ValueDecl *VD) const {
250 if (const auto *V = dyn_cast<VarDecl>(VD))
251 return V->hasGlobalStorage() || V->isConstexpr();
252
253 return false;
254 }
255
256 llvm::RoundingMode getRoundingMode(const Expr *E) const {
257 FPOptions FPO = E->getFPFeaturesInEffect(Ctx.getLangOpts());
258
259 if (FPO.getRoundingMode() == llvm::RoundingMode::Dynamic)
260 return llvm::RoundingMode::NearestTiesToEven;
261
262 return FPO.getRoundingMode();
263 }
264
265 bool emitRecordDestruction(const Descriptor *Desc);
266 bool emitDerivedToBaseCasts(const RecordType *DerivedType,
267 const RecordType *BaseType, const Expr *E);
268
269protected:
270 /// Variable to storage mapping.
271 llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;
272
273 /// OpaqueValueExpr to location mapping.
274 llvm::DenseMap<const OpaqueValueExpr *, unsigned> OpaqueExprs;
275
276 /// Current scope.
278
279 /// Current argument index. Needed to emit ArrayInitIndexExpr.
280 std::optional<uint64_t> ArrayIndex;
281
282 /// Flag indicating if return value is to be discarded.
283 bool DiscardResult = false;
284};
285
286extern template class ByteCodeExprGen<ByteCodeEmitter>;
287extern template class ByteCodeExprGen<EvalEmitter>;
288
289/// Scope chain managing the variable lifetimes.
290template <class Emitter> class VariableScope {
291public:
293 : Ctx(Ctx), Parent(Ctx->VarScope) {
294 Ctx->VarScope = this;
295 }
296
297 virtual ~VariableScope() { Ctx->VarScope = this->Parent; }
298
299 void add(const Scope::Local &Local, bool IsExtended) {
300 if (IsExtended)
301 this->addExtended(Local);
302 else
303 this->addLocal(Local);
304 }
305
306 virtual void addLocal(const Scope::Local &Local) {
307 if (this->Parent)
308 this->Parent->addLocal(Local);
309 }
310
311 virtual void addExtended(const Scope::Local &Local) {
312 if (this->Parent)
313 this->Parent->addExtended(Local);
314 }
315
316 virtual void emitDestruction() {}
317 virtual void emitDestructors() {}
318 VariableScope *getParent() const { return Parent; }
319
320protected:
321 /// ByteCodeExprGen instance.
323 /// Link to the parent scope.
325};
326
327/// Generic scope for local variables.
328template <class Emitter> class LocalScope : public VariableScope<Emitter> {
329public:
331
332 /// Emit a Destroy op for this scope.
333 ~LocalScope() override {
334 if (!Idx)
335 return;
336 this->Ctx->emitDestroy(*Idx, SourceInfo{});
337 }
338
339 /// Overriden to support explicit destruction.
340 void emitDestruction() override {
341 if (!Idx)
342 return;
343 this->emitDestructors();
344 this->Ctx->emitDestroy(*Idx, SourceInfo{});
345 this->Idx = std::nullopt;
346 }
347
348 void addLocal(const Scope::Local &Local) override {
349 if (!Idx) {
350 Idx = this->Ctx->Descriptors.size();
351 this->Ctx->Descriptors.emplace_back();
352 }
353
354 this->Ctx->Descriptors[*Idx].emplace_back(Local);
355 }
356
357 void emitDestructors() override {
358 if (!Idx)
359 return;
360 // Emit destructor calls for local variables of record
361 // type with a destructor.
362 for (Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
363 if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
364 this->Ctx->emitGetPtrLocal(Local.Offset, SourceInfo{});
365 this->Ctx->emitRecordDestruction(Local.Desc);
366 }
367 }
368 }
369
370 /// Index of the scope in the chain.
371 std::optional<unsigned> Idx;
372};
373
374/// Emits the destructors of the variables of \param OtherScope
375/// when this scope is destroyed. Does not create a Scope in the bytecode at
376/// all, this is just a RAII object to emit destructors.
377template <class Emitter> class DestructorScope final {
378public:
379 DestructorScope(LocalScope<Emitter> &OtherScope) : OtherScope(OtherScope) {}
380
381 ~DestructorScope() { OtherScope.emitDestructors(); }
382
383private:
384 LocalScope<Emitter> &OtherScope;
385};
386
387/// Like a regular LocalScope, except that the destructors of all local
388/// variables are automatically emitted when the AutoScope is destroyed.
389template <class Emitter> class AutoScope : public LocalScope<Emitter> {
390public:
392 : LocalScope<Emitter>(Ctx), DS(*this) {}
393
394private:
396};
397
398/// Scope for storage declared in a compound statement.
399template <class Emitter> class BlockScope final : public AutoScope<Emitter> {
400public:
402
403 void addExtended(const Scope::Local &Local) override {
404 // If we to this point, just add the variable as a normal local
405 // variable. It will be destroyed at the end of the block just
406 // like all others.
407 this->addLocal(Local);
408 }
409};
410
411/// Expression scope which tracks potentially lifetime extended
412/// temporaries which are hoisted to the parent scope on exit.
413template <class Emitter> class ExprScope final : public AutoScope<Emitter> {
414public:
416
417 void addExtended(const Scope::Local &Local) override {
418 if (this->Parent)
419 this->Parent->addLocal(Local);
420 }
421};
422
423template <class Emitter> class ArrayIndexScope final {
424public:
425 ArrayIndexScope(ByteCodeExprGen<Emitter> *Ctx, uint64_t Index) : Ctx(Ctx) {
426 OldArrayIndex = Ctx->ArrayIndex;
427 Ctx->ArrayIndex = Index;
428 }
429
430 ~ArrayIndexScope() { Ctx->ArrayIndex = OldArrayIndex; }
431
432private:
434 std::optional<uint64_t> OldArrayIndex;
435};
436
437} // namespace interp
438} // namespace clang
439
440#endif
#define V(N, I)
Definition: ASTContext.h:3230
NodeId Parent
Definition: ASTDiff.cpp:191
@ Write
Definition: CGBuiltin.cpp:7715
static std::optional< DereferenceInfo > dereference(ProgramStateRef State, const FieldRegion *FR)
Dereferences FR and returns with the pointee's region, and whether it needs to be casted back to it's...
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition: Expr.h:4120
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5531
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2661
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3819
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:720
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1249
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1356
Represents a call to a member function that may be written either with member call syntax (e....
Definition: ExprCXX.h:176
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:765
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
Represents the this expression in C++.
Definition: ExprCXX.h:1148
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2817
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3487
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4067
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3417
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:194
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1044
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1237
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3420
This represents one expression.
Definition: Expr.h:110
bool isGLValue() const
Definition: Expr.h:274
QualType getType() const
Definition: Expr.h:142
Represents a function declaration or definition.
Definition: Decl.h:1917
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5567
Describes an C or C++ initializer list.
Definition: Expr.h:4815
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4564
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3180
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1145
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:2128
Represents a parameter to a function.
Definition: Decl.h:1722
A (possibly-)qualified type.
Definition: Type.h:736
Represents a struct/union/class.
Definition: Decl.h:4012
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4850
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1780
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4320
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2742
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.cpp:1799
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
Definition: Type.cpp:1784
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2565
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2181
Represents a variable declaration or definition.
Definition: Decl.h:913
ArrayIndexScope(ByteCodeExprGen< Emitter > *Ctx, uint64_t Index)
Like a regular LocalScope, except that the destructors of all local variables are automatically emitt...
AutoScope(ByteCodeExprGen< Emitter > *Ctx)
Scope for storage declared in a compound statement.
BlockScope(ByteCodeExprGen< Emitter > *Ctx)
void addExtended(const Scope::Local &Local) override
Compilation context for expressions.
bool visitExpr(const Expr *E) override
std::optional< unsigned > allocateLocal(DeclTy &&Decl, bool IsExtended=false)
Allocates a space storing a local given its type.
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst, bool IsExtended=false)
Creates a local primitive value.
bool VisitIntegerLiteral(const IntegerLiteral *E)
bool VisitCharacterLiteral(const CharacterLiteral *E)
bool VisitDeclRefExpr(const DeclRefExpr *E)
bool VisitExprWithCleanups(const ExprWithCleanups *E)
bool VisitMemberExpr(const MemberExpr *E)
bool discard(const Expr *E)
Evaluates an expression for side effects and discards the result.
bool visitThisInitializer(const Expr *I)
Visits a delegated initializer.
bool visitDecl(const VarDecl *VD) override
Toplevel visitDecl().
bool visitInitializer(const Expr *E)
Compiles an initializer.
bool visitRecordInitializer(const Expr *Initializer)
Compiles a record initializer.
bool VisitParenExpr(const ParenExpr *E)
bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E)
bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E)
bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Program & P
Program to link to.
bool VisitBuiltinCallExpr(const CallExpr *E)
PrimType classifyPrim(QualType Ty) const
Classifies a known primitive type.
bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *E)
llvm::DenseMap< const ValueDecl *, Scope::Local > Locals
Variable to storage mapping.
void emitCleanup()
Emits scope cleanup instructions.
bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E)
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E)
Context & Ctx
Current compilation context.
bool visitGlobalInitializer(const Expr *Init, unsigned I)
Visits an initializer for a global.
bool visitBool(const Expr *E)
Visits an expression and converts it to a boolean.
VariableScope< Emitter > * VarScope
Current scope.
std::optional< PrimType > classify(QualType Ty) const
bool VisitBinaryOperator(const BinaryOperator *E)
bool VisitTypeTraitExpr(const TypeTraitExpr *E)
bool visit(const Expr *E)
Evaluates an expression and places result on stack.
bool VisitInitListExpr(const InitListExpr *E)
bool VisitFloatingLiteral(const FloatingLiteral *E)
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E)
bool VisitUnaryOperator(const UnaryOperator *E)
bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E)
std::optional< uint64_t > ArrayIndex
Current argument index. Needed to emit ArrayInitIndexExpr.
bool VisitPointerCompoundAssignOperator(const CompoundAssignOperator *E)
bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E)
std::optional< PrimType > classify(const Expr *E) const
Classifies a type.
bool DiscardResult
Flag indicating if return value is to be discarded.
bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E)
bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E)
const Function * getFunction(const FunctionDecl *FD)
bool visitLocalInitializer(const Expr *Init, unsigned I)
Visits an initializer for a local.
bool VisitLogicalBinOp(const BinaryOperator *E)
bool visitVarDecl(const VarDecl *VD)
Creates and initializes a variable from the given decl.
bool VisitStringLiteral(const StringLiteral *E)
ByteCodeExprGen(Context &Ctx, Program &P, Tys &&... Args)
Initializes the compiler and the backend emitter.
Record * getRecord(QualType Ty)
Returns a record from a record or pointer type.
llvm::DenseMap< const OpaqueValueExpr *, unsigned > OpaqueExprs
OpaqueValueExpr to location mapping.
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E)
bool VisitCXXThisExpr(const CXXThisExpr *E)
typename Emitter::LabelTy LabelTy
bool VisitPointerArithBinOp(const BinaryOperator *E)
Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
bool visitConditional(const AbstractConditionalOperator *E, llvm::function_ref< bool(const Expr *)> V)
Visit a conditional operator, i.e.
bool VisitCompoundAssignOperator(const CompoundAssignOperator *E)
bool VisitCallExpr(const CallExpr *E)
const RecordType * getRecordTy(QualType Ty)
Returns a record type from a record or pointer type.
bool VisitConstantExpr(const ConstantExpr *E)
bool VisitCastExpr(const CastExpr *E)
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E)
bool visitArrayInitializer(const Expr *Initializer)
Compiles an array initializer.
typename Emitter::AddrTy AddrTy
Holds all information required to evaluate constexpr code in a module.
Definition: Context.h:35
const LangOptions & getLangOpts() const
Returns the language options.
Definition: Context.cpp:78
std::optional< PrimType > classify(QualType T) const
Classifies an expression.
Definition: Context.cpp:80
Scope used to handle temporaries in toplevel variable declarations.
Emits the destructors of the variables of.
DestructorScope(LocalScope< Emitter > &OtherScope)
Expression scope which tracks potentially lifetime extended temporaries which are hoisted to the pare...
void addExtended(const Scope::Local &Local) override
ExprScope(ByteCodeExprGen< Emitter > *Ctx)
Bytecode function.
Definition: Function.h:74
Generic scope for local variables.
~LocalScope() override
Emit a Destroy op for this scope.
void emitDestruction() override
Overriden to support explicit destruction.
void emitDestructors() override
void addLocal(const Scope::Local &Local) override
std::optional< unsigned > Idx
Index of the scope in the chain.
LocalScope(ByteCodeExprGen< Emitter > *Ctx)
Scope used to handle initialization methods.
The program contains and links the bytecode for all functions.
Definition: Program.h:40
Structure/Class descriptor.
Definition: Record.h:25
Describes the statement/declaration an opcode was generated from.
Definition: Source.h:70
Scope chain managing the variable lifetimes.
virtual void addExtended(const Scope::Local &Local)
void add(const Scope::Local &Local, bool IsExtended)
VariableScope * Parent
Link to the parent scope.
virtual void addLocal(const Scope::Local &Local)
VariableScope(ByteCodeExprGen< Emitter > *Ctx)
VariableScope * getParent() const
ByteCodeExprGen< Emitter > * Ctx
ByteCodeExprGen instance.
Defines the clang::TargetInfo interface.
PrimType
Enumeration of the primitive types of the VM.
Definition: PrimType.h:30
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition: Descriptor.h:26
Information about a local's storage.
Definition: Function.h:35