clang: lib/AST/ByteCode/Compiler.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H
14#define LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H
15
25
27class QualType;
28
29namespace interp {
30
31template class LocalScope;
34template class DeclScope;
37template class OptionScope;
40template class LoopScope;
41template class LabelScope;
42template class SwitchScope;
44
45template class Compiler;
47public:
48 enum {
57
64 return IL;
65 }
69 return IL;
70 }
73 IL.D = D;
74 return IL;
75 }
78 IL.Offset = Index;
79 return IL;
80 }
81
83 template
85
87 union {
90 };
91};
92
93
94
96 std::optional S = std::nullopt;
100
101 operator bool() const { return S && *S; }
103};
104
105
106template
109protected:
110
111 using LabelTy = typename Emitter::LabelTy;
112 using AddrTy = typename Emitter::AddrTy;
114 using CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>;
115
116
118
120
121public:
122
123 template <typename... Tys>
126
127
213
214
230
231protected:
233 bool visitExpr(const Expr *E, bool DestroyToplevelScope) override;
235
237
238protected:
239
241
242
244
245
248
249
250
252
255 }
258 }
259
260
263 return *T;
264 }
265 llvm_unreachable("not a primitive type");
266 }
267
270 return *T;
271 llvm_unreachable("not a primitive type");
272 }
273
274
275
276
278
279
280
281
283
285
286
288
291
294
296
297
299
303
304
306 bool IsExtended = false);
307
308
309 std::optional
311 const ValueDecl *ExtendingDecl = nullptr);
313
314private:
329
330
332 bool visitZeroRecordInitializer(const Record *R, const Expr *E);
333 bool visitZeroArrayInitializer(QualType T, const Expr *E);
334
335
336 bool emitConst(const llvm::APSInt &Value, PrimType Ty, const Expr *E);
337 bool emitConst(const llvm::APSInt &Value, const Expr *E);
338 bool emitConst(const llvm::APInt &Value, const Expr *E) {
339 return emitConst(static_castllvm::APSInt\(Value), E);
340 }
341
342
343 template bool emitConst(T Value, PrimType Ty, const Expr *E);
344 template bool emitConst(T Value, const Expr *E);
345
346 llvm::RoundingMode getRoundingMode(const Expr *E) const {
348
349 if (FPO.getRoundingMode() == llvm::RoundingMode::Dynamic)
350 return llvm::RoundingMode::NearestTiesToEven;
351
353 }
354
355 uint32_t getFPOptions(const Expr *E) const {
356 return E->getFPFeaturesInEffect(Ctx.getLangOpts()).getAsOpaqueInt();
357 }
358
359 bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr *E);
360 PrimType classifyComplexElementType(QualType T) const {
362
363 QualType ElemType = T->getAs()->getElementType();
364
365 return *this->classify(ElemType);
366 }
367
368 PrimType classifyVectorElementType(QualType T) const {
370 return *this->classify(T->getAs()->getElementType());
371 }
372
373 bool emitComplexReal(const Expr *SubExpr);
374 bool emitComplexBoolCast(const Expr *E);
375 bool emitComplexComparison(const Expr *LHS, const Expr *RHS,
376 const BinaryOperator *E);
377 bool emitRecordDestruction(const Record *R, SourceInfo Loc);
378 bool emitDestruction(const Descriptor *Desc, SourceInfo Loc);
379 bool emitDummyPtr(const DeclTy &D, const Expr *E);
380 unsigned collectBaseOffset(const QualType BaseType,
381 const QualType DerivedType);
382 bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
383 bool emitBuiltinBitCast(const CastExpr *E);
384 bool compileConstructor(const CXXConstructorDecl *Ctor);
385 bool compileDestructor(const CXXDestructorDecl *Dtor);
386
387 bool checkLiteralType(const Expr *E);
388
389protected:
390
391 llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;
392
393
394 llvm::DenseMap<const OpaqueValueExpr *, unsigned> OpaqueExprs;
395
396
398
399
401
402
404
405
407
409
410
411
414
417
418
420
421
423
424
426
428
430
432
434};
435
438
439
441public:
443 : Ctx(Ctx), Parent(Ctx->VarScope), ValDecl(VD) {
444 Ctx->VarScope = this;
445 }
446
448
450 if (IsExtended)
451 this->addExtended(Local);
452 else
453 this->addLocal(Local);
454 }
455
458 this->Parent->addLocal(Local);
459 }
460
463 this->Parent->addExtended(Local);
464 }
465
467
468
470 while (P) {
471 if (P->ValDecl == ExtendingDecl) {
472 P->addLocal(Local);
473 return;
474 }
476 if ()
477 break;
478 }
479
480
482 this->Parent->addLocal(Local);
483 else
484 this->addLocal(Local);
485 }
486
491
492protected:
493
495
498};
499
500
502public:
506
507
509 if (!Idx)
510 return;
511 this->Ctx->emitDestroy(*Idx, SourceInfo{});
512 removeStoredOpaqueValues();
513 }
514
515
517 if (!Idx)
518 return;
519
520 this->emitDestructors();
521 this->Ctx->emitDestroy(*Idx, SourceInfo{});
522 }
523
524
526 if (!Idx)
527 return true;
528
529 bool Success = this->emitDestructors(E);
530 this->Ctx->emitDestroy(*Idx, E);
531 this->Idx = std::nullopt;
533 }
534
536 if (!Idx) {
537 Idx = this->Ctx->Descriptors.size();
538 this->Ctx->Descriptors.emplace_back();
539 this->Ctx->emitInitScope(*Idx, {});
540 }
541
542 this->Ctx->Descriptors[*Idx].emplace_back(Local);
543 }
544
546 if (!Idx)
547 return true;
548
549
550 for (Scope::Local &Local : llvm::reverse(this->Ctx->Descriptors[*Idx])) {
551 if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
552 if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
553 return false;
554
555 if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
556 return false;
557
558 if (!this->Ctx->emitPopPtr(E))
559 return false;
560 removeIfStoredOpaqueValue(Local);
561 }
562 }
563 return true;
564 }
565
567 if (!Idx)
568 return;
569
570 for (const Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
571 removeIfStoredOpaqueValue(Local);
572 }
573 }
574
576 if (const auto *OVE =
577 llvm::dyn_cast_if_present(Local.Desc->asExpr())) {
578 if (auto It = this->Ctx->OpaqueExprs.find(OVE);
579 It != this->Ctx->OpaqueExprs.end())
580 this->Ctx->OpaqueExprs.erase(It);
581 };
582 }
583
584
586};
587
588
590public:
592
594
595
596
597 this->addLocal(Local);
598 }
599};
600
602public:
604 OldArrayIndex = Ctx->ArrayIndex;
605 Ctx->ArrayIndex = Index;
606 }
607
609
610private:
612 std::optional<uint64_t> OldArrayIndex;
613};
614
616public:
618 assert(DefaultExpr);
619
620 if (!Ctx->SourceLocDefaultExpr) {
621 Enabled = true;
622 Ctx->SourceLocDefaultExpr = DefaultExpr;
623 }
624 }
625
627 if (Enabled)
628 Ctx->SourceLocDefaultExpr = nullptr;
629 }
630
631private:
633 bool Enabled = false;
634};
635
637public:
639 Ctx->InitStack.push_back(std::move(Link));
640 }
641
643
644private:
646};
647
649public:
651 : Ctx(Ctx), OldValue(Ctx->InitStackActive) {
652 Ctx->InitStackActive = Active;
653 }
654
656
657private:
659 bool OldValue;
660};
661
662}
663}
664
665#endif
llvm::MachO::Record Record
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
AddrLabelExpr - The GNU address of label extension, representing &&label.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Represents an attribute applied to a statement.
A builtin binary operation expression such as "x + y" or "x <= y".
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
BreakStmt - This represents a break.
Represents binding an expression to a temporary.
A boolean literal, per ([C++ lex.bool] Boolean literals).
Represents a call to a C++ constructor.
A default argument (C++ [dcl.fct.default]).
A use of a default initializer in a constructor or in aggregate initialization.
Represents a delete expression for memory deallocation and destructor calls, e.g.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
The null pointer literal (C++11 [lex.nullptr])
Represents a list-initialization with parenthesis.
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
A rewritten comparison expression that was originally written using operator syntax.
An expression "T()" which creates an rvalue of a non-class type T.
Implicit construction of a std::initializer_list object from an array temporary within list-initia...
Represents the this expression in C++.
A C++ throw-expression (C++ [except.throw]).
CXXTryStmt - A C++ try block, including all handlers.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CaseStmt - Represent a case statement.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
CompoundAssignOperator - For compound assignments (e.g.
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
Represents the specialization of a concept - evaluates to a prvalue of type bool.
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
ContinueStmt - This represents a continue.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
A reference to a declared variable, function, enum, etc.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
DoStmt - This represents a 'do/while' stmt.
Represents a reference to #emded data.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
This represents one expression.
An expression trait intrinsic.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
RoundingMode getRoundingMode() const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Represents a function declaration or definition.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Represents a C11 generic selection.
IfStmt - This represents an if/then/else.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Represents an implicitly-generated value initialization of an object of a given type.
Describes an C or C++ initializer list.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
ObjCBoxedExpr - used for generalized expression boxing.
ObjCEncodeExpr, used for @encode in Objective-C.
ObjCStringLiteral, used for Objective-C string literals i.e.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
ParenExpr - This represents a parenthesized expression, e.g.
[C99 6.4.2.2] - A predefined identifier such as func.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
Represents a struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Represents an expression that computes the length of a parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Stmt - This represents one statement.
StringLiteral - This represents a string literal expression, e.g.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
SwitchStmt - This represents a 'switch' stmt.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
bool isAnyComplexType() const
bool isVectorType() const
const T * getAs() const
Member-template getAs'.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
WhileStmt - This represents a 'while' stmt.
ArrayIndexScope(Compiler< Emitter > *Ctx, uint64_t Index)
Scope for storage declared in a compound statement.
BlockScope(Compiler< Emitter > *Ctx)
void addExtended(const Scope::Local &Local) override
Compilation context for expressions.
std::optional< PrimType > classify(const Expr *E) const
llvm::SmallVector< InitLink > InitStack
OptLabelTy BreakLabel
Point to break to.
bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E)
bool VisitCXXDeleteExpr(const CXXDeleteExpr *E)
bool VisitOffsetOfExpr(const OffsetOfExpr *E)
bool visitContinueStmt(const ContinueStmt *S)
bool VisitCharacterLiteral(const CharacterLiteral *E)
PrimType classifyPrim(const Expr *E) const
Classifies a known primitive expression.
bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E)
bool VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E)
bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E)
bool visitBool(const Expr *E)
Visits an expression and converts it to a boolean.
bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E)
bool visitDeclAndReturn(const VarDecl *VD, bool ConstantContext) override
Toplevel visitDeclAndReturn().
PrimType classifyPrim(QualType Ty) const
Classifies a known primitive type.
bool VisitTypeTraitExpr(const TypeTraitExpr *E)
bool VisitLambdaExpr(const LambdaExpr *E)
bool VisitMemberExpr(const MemberExpr *E)
llvm::DenseMap< const OpaqueValueExpr *, unsigned > OpaqueExprs
OpaqueValueExpr to location mapping.
bool VisitBinaryOperator(const BinaryOperator *E)
bool visitAttributedStmt(const AttributedStmt *S)
bool VisitPackIndexingExpr(const PackIndexingExpr *E)
bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E)
bool VisitCallExpr(const CallExpr *E)
std::optional< uint64_t > ArrayIndex
Current argument index. Needed to emit ArrayInitIndexExpr.
bool VisitPseudoObjectExpr(const PseudoObjectExpr *E)
bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E)
const Function * getFunction(const FunctionDecl *FD)
Returns a function for the given FunctionDecl.
void emitCleanup()
Emits scope cleanup instructions.
bool VisitFixedPointBinOp(const BinaryOperator *E)
bool VisitCastExpr(const CastExpr *E)
bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E)
bool VisitFixedPointUnaryOperator(const UnaryOperator *E)
bool VisitComplexUnaryOperator(const UnaryOperator *E)
std::optional< PrimType > classify(QualType Ty) const
llvm::DenseMap< const SwitchCase *, LabelTy > CaseMap
bool visitDeclStmt(const DeclStmt *DS)
bool VisitBlockExpr(const BlockExpr *E)
bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E)
Visit an APValue.
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E)
bool VisitLogicalBinOp(const BinaryOperator *E)
bool visitCompoundStmt(const CompoundStmt *S)
std::optional< PrimType > ReturnType
Type of the expression returned by the function.
Context & Ctx
Current compilation context.
bool visitDeclRef(const ValueDecl *D, const Expr *E)
Visit the given decl as if we have a reference to it.
bool visitBreakStmt(const BreakStmt *S)
bool visitExpr(const Expr *E, bool DestroyToplevelScope) override
bool visitForStmt(const ForStmt *S)
bool VisitDeclRefExpr(const DeclRefExpr *E)
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E)
bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E)
OptLabelTy DefaultLabel
Default case label.
bool VisitStmtExpr(const StmtExpr *E)
std::optional< unsigned > allocateLocal(DeclTy &&Decl, QualType Ty=QualType(), const ValueDecl *ExtendingDecl=nullptr)
Allocates a space storing a local given its type.
bool VisitFixedPointLiteral(const FixedPointLiteral *E)
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E)
VariableScope< Emitter > * VarScope
Current scope.
VariableScope< Emitter > * ContinueVarScope
Scope to cleanup until when we see a continue statement.
bool VisitCXXNewExpr(const CXXNewExpr *E)
const ValueDecl * InitializingDecl
bool VisitCompoundAssignOperator(const CompoundAssignOperator *E)
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init)
Pointer to the array(not the element!) must be on the stack when calling this.
bool delegate(const Expr *E)
Just pass evaluation on to E.
bool discard(const Expr *E)
Evaluates an expression for side effects and discards the result.
bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
CaseMap CaseLabels
Switch case mapping.
Record * getRecord(QualType Ty)
Returns a record from a record or pointer type.
bool visit(const Expr *E)
Evaluates an expression and places the result on the stack.
const RecordType * getRecordTy(QualType Ty)
Returns a record type from a record or pointer type.
bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E)
bool visitInitList(ArrayRef< const Expr * > Inits, const Expr *ArrayFiller, const Expr *E)
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E)
bool VisitPredefinedExpr(const PredefinedExpr *E)
bool VisitSourceLocExpr(const SourceLocExpr *E)
Compiler(Context &Ctx, Program &P, Tys &&...Args)
Initializes the compiler and the backend emitter.
bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E)
bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
bool VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E)
bool visitInitializer(const Expr *E)
Compiles an initializer.
const Expr * SourceLocDefaultExpr
DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E)
bool VisitPointerArithBinOp(const BinaryOperator *E)
Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E)
bool visitDefaultStmt(const DefaultStmt *S)
typename Emitter::LabelTy LabelTy
VarCreationState visitDecl(const VarDecl *VD)
bool visitStmt(const Stmt *S)
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E)
bool visitAPValueInitializer(const APValue &Val, const Expr *E)
bool VisitVectorUnaryOperator(const UnaryOperator *E)
bool VisitCXXConstructExpr(const CXXConstructExpr *E)
bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E)
bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E)
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E)
bool VisitRecoveryExpr(const RecoveryExpr *E)
bool VisitRequiresExpr(const RequiresExpr *E)
bool Initializing
Flag inidicating if we're initializing an already created variable.
bool visitReturnStmt(const ReturnStmt *RS)
bool VisitCXXThrowExpr(const CXXThrowExpr *E)
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
bool VisitChooseExpr(const ChooseExpr *E)
bool visitFunc(const FunctionDecl *F) override
bool visitCXXForRangeStmt(const CXXForRangeStmt *S)
bool visitCaseStmt(const CaseStmt *S)
bool VisitComplexBinOp(const BinaryOperator *E)
llvm::DenseMap< const ValueDecl *, Scope::Local > Locals
Variable to storage mapping.
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E)
bool VisitCXXTypeidExpr(const CXXTypeidExpr *E)
bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID)
OptLabelTy ContinueLabel
Point to continue to.
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E)
typename Emitter::AddrTy AddrTy
bool VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *E)
bool VisitUnaryOperator(const UnaryOperator *E)
bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E)
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E)
bool visitDoStmt(const DoStmt *S)
bool VisitIntegerLiteral(const IntegerLiteral *E)
bool VisitInitListExpr(const InitListExpr *E)
bool VisitVectorBinOp(const BinaryOperator *E)
bool VisitStringLiteral(const StringLiteral *E)
bool VisitParenExpr(const ParenExpr *E)
bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E)
bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E)
bool VisitPointerCompoundAssignOperator(const CompoundAssignOperator *E)
VariableScope< Emitter > * BreakVarScope
Scope to cleanup until when we see a break statement.
std::optional< LabelTy > OptLabelTy
bool DiscardResult
Flag indicating if return value is to be discarded.
bool VisitEmbedExpr(const EmbedExpr *E)
bool VisitConvertVectorExpr(const ConvertVectorExpr *E)
bool VisitCXXThisExpr(const CXXThisExpr *E)
bool VisitConstantExpr(const ConstantExpr *E)
unsigned allocateTemporary(const Expr *E)
bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E)
bool visitSwitchStmt(const SwitchStmt *S)
bool VisitCXXUuidofExpr(const CXXUuidofExpr *E)
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst, bool IsExtended=false)
Creates a local primitive value.
bool VisitExprWithCleanups(const ExprWithCleanups *E)
bool visitWhileStmt(const WhileStmt *S)
bool visitIfStmt(const IfStmt *IS)
bool VisitAddrLabelExpr(const AddrLabelExpr *E)
bool VisitFloatingLiteral(const FloatingLiteral *E)
Program & P
Program to link to.
bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
bool VisitGNUNullExpr(const GNUNullExpr *E)
bool VisitImaginaryLiteral(const ImaginaryLiteral *E)
bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E)
VarCreationState visitVarDecl(const VarDecl *VD, bool Toplevel=false)
Creates and initializes a variable from the given decl.
bool visitCXXTryStmt(const CXXTryStmt *S)
Holds all information required to evaluate constexpr code in a module.
const LangOptions & getLangOpts() const
Returns the language options.
std::optional< PrimType > classify(QualType T) const
Classifies a type.
Scope used to handle temporaries in toplevel variable declarations.
InitLinkScope(Compiler< Emitter > *Ctx, InitLink &&Link)
InitStackScope(Compiler< Emitter > *Ctx, bool Active)
Scope managing label targets.
Generic scope for local variables.
LocalScope(Compiler< Emitter > *Ctx)
~LocalScope() override
Emit a Destroy op for this scope.
bool destroyLocals(const Expr *E=nullptr) override
Explicit destruction of local variables.
LocalScope(Compiler< Emitter > *Ctx, const ValueDecl *VD)
bool emitDestructors(const Expr *E=nullptr) override
void emitDestruction() override
Overriden to support explicit destruction.
void removeIfStoredOpaqueValue(const Scope::Local &Local)
void addLocal(const Scope::Local &Local) override
void removeStoredOpaqueValues()
std::optional< unsigned > Idx
Index of the scope in the chain.
Sets the context for break/continue statements.
Scope used to handle initialization methods.
The program contains and links the bytecode for all functions.
Structure/Class descriptor.
Describes the statement/declaration an opcode was generated from.
SourceLocScope(Compiler< Emitter > *Ctx, const Expr *DefaultExpr)
Scope chain managing the variable lifetimes.
virtual void addExtended(const Scope::Local &Local)
void addExtended(const Scope::Local &Local, const ValueDecl *ExtendingDecl)
void add(const Scope::Local &Local, bool IsExtended)
Compiler< Emitter > * Ctx
Compiler instance.
virtual bool emitDestructors(const Expr *E=nullptr)
virtual bool destroyLocals(const Expr *E=nullptr)
VariableScope * Parent
Link to the parent scope.
virtual void addLocal(const Scope::Local &Local)
VariableScope * getParent() const
VariableScope(Compiler< Emitter > *Ctx, const ValueDecl *VD)
virtual void emitDestruction()
Defines the clang::TargetInfo interface.
PrimType
Enumeration of the primitive types of the VM.
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
The JSON file list parser is used to communicate input to InstallAPI.
@ Link
'link' clause, allowed on 'declare' construct.
const FunctionProtoType * T
@ Success
Template argument deduction was successful.
static InitLink InitList()
static InitLink Elem(unsigned Index)
bool emit(Compiler< Emitter > *Ctx, const Expr *E) const
static InitLink Field(unsigned Offset)
static InitLink Decl(const ValueDecl *D)
static InitLink Temp(unsigned Offset)
Information about a local's storage.
State encapsulating if a the variable creation has been successful, unsuccessful, or no variable has ...
static VarCreationState NotCreated()
VarCreationState()=default