clang 22.0.0git
clang::interp::Compiler< Emitter > Class Template Reference

Compilation context for expressions. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/Compiler.h"

Inheritance diagram for clang::interp::Compiler< Emitter >:
[legend]

Classes

struct  LabelInfo

Public Member Functions

template<typename... Tys>
 Compiler (Context &Ctx, Program &P, Tys &&...Args)
 Initializes the compiler and the backend emitter.
bool VisitCastExpr (const CastExpr *E)
bool VisitBuiltinBitCastExpr (const BuiltinBitCastExpr *E)
bool VisitIntegerLiteral (const IntegerLiteral *E)
bool VisitFloatingLiteral (const FloatingLiteral *E)
bool VisitImaginaryLiteral (const ImaginaryLiteral *E)
bool VisitFixedPointLiteral (const FixedPointLiteral *E)
bool VisitParenExpr (const ParenExpr *E)
bool VisitBinaryOperator (const BinaryOperator *E)
bool VisitLogicalBinOp (const BinaryOperator *E)
bool VisitPointerArithBinOp (const BinaryOperator *E)
 Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
bool VisitComplexBinOp (const BinaryOperator *E)
bool VisitVectorBinOp (const BinaryOperator *E)
bool VisitFixedPointBinOp (const BinaryOperator *E)
bool VisitFixedPointUnaryOperator (const UnaryOperator *E)
bool VisitCXXDefaultArgExpr (const CXXDefaultArgExpr *E)
bool VisitCallExpr (const CallExpr *E)
bool VisitBuiltinCallExpr (const CallExpr *E, unsigned BuiltinID)
bool VisitCXXDefaultInitExpr (const CXXDefaultInitExpr *E)
bool VisitCXXBoolLiteralExpr (const CXXBoolLiteralExpr *E)
bool VisitCXXNullPtrLiteralExpr (const CXXNullPtrLiteralExpr *E)
bool VisitGNUNullExpr (const GNUNullExpr *E)
bool VisitCXXThisExpr (const CXXThisExpr *E)
bool VisitUnaryOperator (const UnaryOperator *E)
bool VisitVectorUnaryOperator (const UnaryOperator *E)
bool VisitComplexUnaryOperator (const UnaryOperator *E)
bool VisitDeclRefExpr (const DeclRefExpr *E)
bool VisitImplicitValueInitExpr (const ImplicitValueInitExpr *E)
bool VisitSubstNonTypeTemplateParmExpr (const SubstNonTypeTemplateParmExpr *E)
bool VisitArraySubscriptExpr (const ArraySubscriptExpr *E)
bool VisitInitListExpr (const InitListExpr *E)
bool VisitCXXParenListInitExpr (const CXXParenListInitExpr *E)
bool VisitConstantExpr (const ConstantExpr *E)
bool VisitUnaryExprOrTypeTraitExpr (const UnaryExprOrTypeTraitExpr *E)
bool VisitMemberExpr (const MemberExpr *E)
bool VisitArrayInitIndexExpr (const ArrayInitIndexExpr *E)
bool VisitArrayInitLoopExpr (const ArrayInitLoopExpr *E)
bool VisitOpaqueValueExpr (const OpaqueValueExpr *E)
bool VisitAbstractConditionalOperator (const AbstractConditionalOperator *E)
bool VisitStringLiteral (const StringLiteral *E)
bool VisitObjCStringLiteral (const ObjCStringLiteral *E)
bool VisitObjCEncodeExpr (const ObjCEncodeExpr *E)
bool VisitSYCLUniqueStableNameExpr (const SYCLUniqueStableNameExpr *E)
bool VisitCharacterLiteral (const CharacterLiteral *E)
bool VisitCompoundAssignOperator (const CompoundAssignOperator *E)
bool VisitFloatCompoundAssignOperator (const CompoundAssignOperator *E)
bool VisitPointerCompoundAssignOperator (const CompoundAssignOperator *E)
bool VisitExprWithCleanups (const ExprWithCleanups *E)
bool VisitMaterializeTemporaryExpr (const MaterializeTemporaryExpr *E)
bool VisitCXXBindTemporaryExpr (const CXXBindTemporaryExpr *E)
bool VisitCompoundLiteralExpr (const CompoundLiteralExpr *E)
bool VisitTypeTraitExpr (const TypeTraitExpr *E)
bool VisitArrayTypeTraitExpr (const ArrayTypeTraitExpr *E)
bool VisitLambdaExpr (const LambdaExpr *E)
bool VisitPredefinedExpr (const PredefinedExpr *E)
bool VisitCXXThrowExpr (const CXXThrowExpr *E)
bool VisitCXXReinterpretCastExpr (const CXXReinterpretCastExpr *E)
bool VisitCXXDynamicCastExpr (const CXXDynamicCastExpr *E)
bool VisitCXXNoexceptExpr (const CXXNoexceptExpr *E)
bool VisitCXXConstructExpr (const CXXConstructExpr *E)
bool VisitSourceLocExpr (const SourceLocExpr *E)
bool VisitOffsetOfExpr (const OffsetOfExpr *E)
bool VisitCXXScalarValueInitExpr (const CXXScalarValueInitExpr *E)
bool VisitSizeOfPackExpr (const SizeOfPackExpr *E)
bool VisitGenericSelectionExpr (const GenericSelectionExpr *E)
bool VisitChooseExpr (const ChooseExpr *E)
bool VisitEmbedExpr (const EmbedExpr *E)
bool VisitObjCBoolLiteralExpr (const ObjCBoolLiteralExpr *E)
bool VisitCXXInheritedCtorInitExpr (const CXXInheritedCtorInitExpr *E)
bool VisitExpressionTraitExpr (const ExpressionTraitExpr *E)
bool VisitCXXUuidofExpr (const CXXUuidofExpr *E)
bool VisitRequiresExpr (const RequiresExpr *E)
bool VisitConceptSpecializationExpr (const ConceptSpecializationExpr *E)
bool VisitCXXRewrittenBinaryOperator (const CXXRewrittenBinaryOperator *E)
bool VisitPseudoObjectExpr (const PseudoObjectExpr *E)
bool VisitPackIndexingExpr (const PackIndexingExpr *E)
bool VisitRecoveryExpr (const RecoveryExpr *E)
bool VisitAddrLabelExpr (const AddrLabelExpr *E)
bool VisitConvertVectorExpr (const ConvertVectorExpr *E)
bool VisitShuffleVectorExpr (const ShuffleVectorExpr *E)
bool VisitExtVectorElementExpr (const ExtVectorElementExpr *E)
bool VisitObjCBoxedExpr (const ObjCBoxedExpr *E)
bool VisitCXXStdInitializerListExpr (const CXXStdInitializerListExpr *E)
bool VisitStmtExpr (const StmtExpr *E)
bool VisitCXXNewExpr (const CXXNewExpr *E)
bool VisitCXXDeleteExpr (const CXXDeleteExpr *E)
bool VisitBlockExpr (const BlockExpr *E)
bool VisitCXXTypeidExpr (const CXXTypeidExpr *E)
bool visitCompoundStmt (const CompoundStmt *S)
bool visitDeclStmt (const DeclStmt *DS, bool EvaluateConditionDecl=false)
bool visitReturnStmt (const ReturnStmt *RS)
bool visitIfStmt (const IfStmt *IS)
bool visitWhileStmt (const WhileStmt *S)
bool visitDoStmt (const DoStmt *S)
bool visitForStmt (const ForStmt *S)
bool visitCXXForRangeStmt (const CXXForRangeStmt *S)
bool visitBreakStmt (const BreakStmt *S)
bool visitContinueStmt (const ContinueStmt *S)
bool visitSwitchStmt (const SwitchStmt *S)
bool visitCaseStmt (const CaseStmt *S)
bool visitDefaultStmt (const DefaultStmt *S)
bool visitAttributedStmt (const AttributedStmt *S)
bool visitCXXTryStmt (const CXXTryStmt *S)
Public Member Functions inherited from clang::StmtVisitorBase< llvm::make_const_ptr, Compiler< Emitter >, bool, ParamTys... >
bool Visit (PTR(Stmt) S, ParamTys... P)
 BINOP_FALLBACK (PtrMemD) BINOP_FALLBACK(PtrMemI) BINOP_FALLBACK(Mul) BINOP_FALLBACK(Div) BINOP_FALLBACK(Rem) BINOP_FALLBACK(Add) BINOP_FALLBACK(Sub) BINOP_FALLBACK(Shl) BINOP_FALLBACK(LT) BINOP_FALLBACK(GT) BINOP_FALLBACK(LE) BINOP_FALLBACK(GE) BINOP_FALLBACK(EQ) BINOP_FALLBACK(NE) BINOP_FALLBACK(And) BINOP_FALLBACK(Xor) BINOP_FALLBACK(Or) BINOP_FALLBACK(LAnd) BINOP_FALLBACK(LOr) CAO_FALLBACK(MulAssign) CAO_FALLBACK(DivAssign) CAO_FALLBACK(RemAssign) CAO_FALLBACK(AddAssign) CAO_FALLBACK(SubAssign) CAO_FALLBACK(ShlAssign) CAO_FALLBACK(ShrAssign) CAO_FALLBACK(AndAssign) CAO_FALLBACK(OrAssign) UNARYOP_FALLBACK(PostInc) UNARYOP_FALLBACK(PostDec) UNARYOP_FALLBACK(PreInc) UNARYOP_FALLBACK(PreDec) UNARYOP_FALLBACK(AddrOf) UNARYOP_FALLBACK(Deref) UNARYOP_FALLBACK(Plus) UNARYOP_FALLBACK(Minus) UNARYOP_FALLBACK(Not) UNARYOP_FALLBACK(LNot) UNARYOP_FALLBACK(Real) UNARYOP_FALLBACK(Imag) UNARYOP_FALLBACK(Extension) UNARYOP_FALLBACK(Coawait) bool VisitStmt(PTR(Stmt) Node

Protected Types

using LabelTy = typename Emitter::LabelTy
using AddrTy = typename Emitter::AddrTy
using OptLabelTy = UnsignedOrNone
using CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>

Protected Member Functions

bool visitStmt (const Stmt *S)
bool visitExpr (const Expr *E, bool DestroyToplevelScope) override
bool visitFunc (const FunctionDecl *F) override
bool visitDeclAndReturn (const VarDecl *VD, const Expr *Init, bool ConstantContext) override
 Toplevel visitDeclAndReturn().
void emitCleanup ()
 Emits scope cleanup instructions.
const RecordType * getRecordTy (QualType Ty)
 Returns a record type from a record or pointer type.
RecordgetRecord (QualType Ty)
 Returns a record from a record or pointer type.
RecordgetRecord (const RecordDecl *RD)
const FunctiongetFunction (const FunctionDecl *FD)
 Returns a function for the given FunctionDecl.
OptPrimType classify (const Expr *E) const
OptPrimType classify (QualType Ty) const
bool canClassify (const Expr *E) const
bool canClassify (QualType T) const
PrimType classifyPrim (QualType Ty) const
 Classifies a known primitive type.
PrimType classifyPrim (const Expr *E) const
 Classifies a known primitive expression.
bool visit (const Expr *E) override
 Evaluates an expression and places the result on the stack.
bool visitInitializer (const Expr *E)
 Compiles an initializer.
bool visitAsLValue (const Expr *E)
bool discard (const Expr *E)
 Evaluates an expression for side effects and discards the result.
bool delegate (const Expr *E)
 Just pass evaluation on to E.
VarCreationState visitVarDecl (const VarDecl *VD, const Expr *Init, bool Toplevel=false, bool IsConstexprUnknown=false)
 Creates and initializes a variable from the given decl.
VarCreationState visitDecl (const VarDecl *VD, bool IsConstexprUnknown=false)
bool visitAPValue (const APValue &Val, PrimType ValType, const Expr *E)
 Visit an APValue.
bool visitAPValueInitializer (const APValue &Val, const Expr *E, QualType T)
bool visitDeclRef (const ValueDecl *D, const Expr *E)
 Visit the given decl as if we have a reference to it.
bool visitBool (const Expr *E)
 Visits an expression and converts it to a boolean.
bool visitInitList (ArrayRef< const Expr * > Inits, const Expr *ArrayFiller, const Expr *E)
bool visitArrayElemInit (unsigned ElemIndex, const Expr *Init, OptPrimType InitT)
 Pointer to the array(not the element!) must be on the stack when calling this.
bool visitCallArgs (ArrayRef< const Expr * > Args, const FunctionDecl *FuncDecl, bool Activate, bool IsOperatorCall)
unsigned allocateLocalPrimitive (DeclTy &&Decl, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl=nullptr, ScopeKind SC=ScopeKind::Block, bool IsConstexprUnknown=false)
 Creates a local primitive value.
UnsignedOrNone allocateLocal (DeclTy &&Decl, QualType Ty=QualType(), const ValueDecl *ExtendingDecl=nullptr, ScopeKind=ScopeKind::Block, bool IsConstexprUnknown=false)
 Allocates a space storing a local given its type.
UnsignedOrNone allocateTemporary (const Expr *E)

Protected Attributes

ContextCtx
 Current compilation context.
ProgramP
 Program to link to.
llvm::DenseMap< const ValueDecl *, Scope::LocalLocals
 Variable to storage mapping.
llvm::DenseMap< const OpaqueValueExpr *, unsignedOpaqueExprs
 OpaqueValueExpr to location mapping.
VariableScope< Emitter > * VarScope = nullptr
 Current scope.
std::optional< uint64_t > ArrayIndex
 Current argument index. Needed to emit ArrayInitIndexExpr.
const ExprSourceLocDefaultExpr = nullptr
 DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
bool DiscardResult = false
 Flag indicating if return value is to be discarded.
bool InStmtExpr = false
bool ToLValue = false
bool Initializing = false
 Flag inidicating if we're initializing an already created variable.
const ValueDeclInitializingDecl = nullptr
llvm::SmallVector< InitLinkInitStack
bool InitStackActive = false
OptPrimType ReturnType
 Type of the expression returned by the function.
CaseMap CaseLabels
 Switch case mapping.
llvm::SmallVector< LabelInfoLabelInfoStack
 Stack of label information for loops and switch statements.
const FunctionDeclCompilingFunction = nullptr

Friends

class VariableScope< Emitter >
class LocalScope< Emitter >
class DestructorScope< Emitter >
class DeclScope< Emitter >
class InitLinkScope< Emitter >
class InitStackScope< Emitter >
class OptionScope< Emitter >
class ArrayIndexScope< Emitter >
class SourceLocScope< Emitter >
struct InitLink
class LoopScope< Emitter >
class LabelScope< Emitter >
class SwitchScope< Emitter >
class StmtExprScope< Emitter >
class LocOverrideScope< Emitter >

Additional Inherited Members

Public Attributes inherited from clang::StmtVisitorBase< llvm::make_const_ptr, Compiler< Emitter >, bool, ParamTys... >
ParamTys P

Detailed Description

template<class Emitter>
class clang::interp::Compiler< Emitter >

Compilation context for expressions.

Definition at line 109 of file Compiler.h.

Member Typedef Documentation

◆ AddrTy

template<class Emitter>
using clang::interp::Compiler< Emitter >::AddrTy = typename Emitter::AddrTy
protected

Definition at line 114 of file Compiler.h.

◆ CaseMap

template<class Emitter>
using clang::interp::Compiler< Emitter >::CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>
protected

Definition at line 116 of file Compiler.h.

◆ LabelTy

template<class Emitter>
using clang::interp::Compiler< Emitter >::LabelTy = typename Emitter::LabelTy
protected

Definition at line 113 of file Compiler.h.

◆ OptLabelTy

template<class Emitter>
using clang::interp::Compiler< Emitter >::OptLabelTy = UnsignedOrNone
protected

Definition at line 115 of file Compiler.h.

Constructor & Destructor Documentation

◆ Compiler()

template<class Emitter>
template<typename... Tys>
clang::interp::Compiler< Emitter >::Compiler ( Context & Ctx,
Program & P,
Tys &&... Args )
inline

Initializes the compiler and the backend emitter.

Definition at line 140 of file Compiler.h.

References Ctx, and P.

Member Function Documentation

◆ allocateLocal()

◆ allocateLocalPrimitive()

◆ allocateTemporary()

◆ canClassify() [1/2]

template<class Emitter>
bool clang::interp::Compiler< Emitter >::canClassify ( const Expr * E) const
inlineprotected

◆ canClassify() [2/2]

template<class Emitter>
bool clang::interp::Compiler< Emitter >::canClassify ( QualType T) const
inlineprotected

Definition at line 275 of file Compiler.h.

References Ctx, and clang::T.

◆ classify() [1/2]

◆ classify() [2/2]

template<class Emitter>
OptPrimType clang::interp::Compiler< Emitter >::classify ( QualType Ty) const
inlineprotected

Definition at line 273 of file Compiler.h.

References Ctx.

◆ classifyPrim() [1/2]

template<class Emitter>
PrimType clang::interp::Compiler< Emitter >::classifyPrim ( const Expr * E) const
inlineprotected

Classifies a known primitive expression.

Definition at line 285 of file Compiler.h.

References classify(), and clang::T.

◆ classifyPrim() [2/2]

◆ delegate()

◆ discard()

template<class Emitter>
bool Compiler::discard ( const Expr * E)
protected

Evaluates an expression for side effects and discards the result.

Definition at line 4168 of file Compiler.cpp.

References clang::StmtVisitorBase< llvm::make_const_ptr, Compiler< Emitter >, bool, ParamTys... >::Visit().

◆ emitCleanup()

template<class Emitter>
void Compiler::emitCleanup ( )
protected

Emits scope cleanup instructions.

Definition at line 7022 of file Compiler.cpp.

References clang::C, and VarScope.

◆ getFunction()

template<class Emitter>
const Function * Compiler::getFunction ( const FunctionDecl * FD)
protected

Returns a function for the given FunctionDecl.

If the function does not exist yet, it is compiled.

Definition at line 4660 of file Compiler.cpp.

References Ctx.

Referenced by VisitCallExpr(), VisitCXXConstructExpr(), VisitCXXInheritedCtorInitExpr(), VisitCXXNewExpr(), and visitDeclRef().

◆ getRecord() [1/2]

template<class Emitter>
Record * Compiler::getRecord ( const RecordDecl * RD)
protected

Definition at line 4655 of file Compiler.cpp.

References P.

◆ getRecord() [2/2]

template<class Emitter>
Record * Compiler::getRecord ( QualType Ty)
protected

◆ getRecordTy()

template<class Emitter>
const RecordType * Compiler::getRecordTy ( QualType Ty)
protected

Returns a record type from a record or pointer type.

Definition at line 4642 of file Compiler.cpp.

References clang::Type::getAsCanonical().

Referenced by getRecord().

◆ visit()

template<class Emitter>
bool Compiler::visit ( const Expr * E)
overrideprotected

Evaluates an expression and places the result on the stack.

If the expression is of composite type, a local variable will be created and a pointer to said variable will be placed on the stack.

Definition at line 4206 of file Compiler.cpp.

References allocateLocal(), canClassify(), clang::interp::discard(), clang::Expr::getType(), clang::Expr::isGLValue(), clang::QualType::isNull(), clang::Type::isVoidType(), stripDerivedToBaseCasts(), clang::interp::InitLink::Temp(), ToLValue, clang::StmtVisitorBase< llvm::make_const_ptr, Compiler< Emitter >, bool, ParamTys... >::Visit(), and visitInitializer().

Referenced by visitAPValue(), visitArrayElemInit(), VisitArraySubscriptExpr(), VisitBinaryOperator(), visitBool(), VisitBuiltinCallExpr(), visitCallArgs(), VisitCallExpr(), VisitCastExpr(), VisitComplexBinOp(), VisitComplexUnaryOperator(), VisitCompoundAssignOperator(), VisitCompoundLiteralExpr(), VisitConvertVectorExpr(), VisitCXXBindTemporaryExpr(), VisitCXXConstructExpr(), VisitCXXDeleteExpr(), VisitCXXNewExpr(), VisitCXXStdInitializerListExpr(), VisitCXXTypeidExpr(), visitDeclAndReturn(), visitDeclRef(), VisitEmbedExpr(), visitExpr(), VisitExtVectorElementExpr(), VisitFixedPointBinOp(), VisitFixedPointUnaryOperator(), VisitFloatCompoundAssignOperator(), visitInitList(), VisitLambdaExpr(), VisitMaterializeTemporaryExpr(), VisitMemberExpr(), VisitOffsetOfExpr(), VisitOpaqueValueExpr(), VisitPointerArithBinOp(), VisitPointerCompoundAssignOperator(), visitReturnStmt(), VisitShuffleVectorExpr(), VisitSourceLocExpr(), visitSwitchStmt(), VisitUnaryOperator(), visitVarDecl(), VisitVectorBinOp(), and VisitVectorUnaryOperator().

◆ VisitAbstractConditionalOperator()

◆ VisitAddrLabelExpr()

template<class Emitter>
bool Compiler::VisitAddrLabelExpr ( const AddrLabelExpr * E)

Definition at line 3942 of file Compiler.cpp.

References clang::Expr::getType(), and clang::Type::isVoidPointerType().

◆ visitAPValue()

◆ visitAPValueInitializer()

◆ visitArrayElemInit()

template<class Emitter>
bool Compiler::visitArrayElemInit ( unsigned ElemIndex,
const Expr * Init,
OptPrimType InitT )
protected

Pointer to the array(not the element!) must be on the stack when calling this.

Definition at line 2061 of file Compiler.cpp.

References clang::interp::InitLink::Elem(), clang::interp::Init(), visit(), and visitInitializer().

Referenced by VisitArrayInitLoopExpr(), VisitCastExpr(), VisitImaginaryLiteral(), and visitInitList().

◆ VisitArrayInitIndexExpr()

template<class Emitter>
bool Compiler::VisitArrayInitIndexExpr ( const ArrayInitIndexExpr * E)

Definition at line 2403 of file Compiler.cpp.

References ArrayIndex.

◆ VisitArrayInitLoopExpr()

◆ VisitArraySubscriptExpr()

◆ VisitArrayTypeTraitExpr()

template<class Emitter>
bool Compiler::VisitArrayTypeTraitExpr ( const ArrayTypeTraitExpr * E)

Definition at line 3052 of file Compiler.cpp.

References DiscardResult, and clang::ArrayTypeTraitExpr::getValue().

◆ visitAsLValue()

template<class Emitter>
bool Compiler::visitAsLValue ( const Expr * E)
protected

◆ visitAttributedStmt()

◆ VisitBinaryOperator()

◆ VisitBlockExpr()

template<class Emitter>
bool Compiler::VisitBlockExpr ( const BlockExpr * E)

Definition at line 3790 of file Compiler.cpp.

References Ctx, DiscardResult, and clang::Func.

◆ visitBool()

◆ visitBreakStmt()

template<class Emitter>
bool Compiler::visitBreakStmt ( const BreakStmt * S)

Definition at line 5863 of file Compiler.cpp.

References clang::C, clang::LoopControlStmt::getNamedLoopOrSwitch(), LabelInfoStack, and VarScope.

Referenced by visitStmt().

◆ VisitBuiltinBitCastExpr()

template<class Emitter>
bool Compiler::VisitBuiltinBitCastExpr ( const BuiltinBitCastExpr * E)

Definition at line 776 of file Compiler.cpp.

◆ VisitBuiltinCallExpr()

◆ visitCallArgs()

◆ VisitCallExpr()

◆ visitCaseStmt()

template<class Emitter>
bool Compiler::visitCaseStmt ( const CaseStmt * S)

Definition at line 6014 of file Compiler.cpp.

References CaseLabels, clang::CaseStmt::getSubStmt(), and visitStmt().

Referenced by visitStmt().

◆ VisitCastExpr()

template<class Emitter>
bool Compiler::VisitCastExpr ( const CastExpr * E)

Definition at line 212 of file Compiler.cpp.

References allocateLocal(), allocateLocalPrimitive(), allocateTemporary(), canClassify(), clang::Type::castAs(), clang::Type::castAsEnumDecl(), classify(), classifyPrim(), Ctx, delegate(), clang::interp::discard(), DiscardResult, clang::Type::getAs(), clang::CastExpr::getCastKind(), clang::MemberPointerType::getMostRecentCXXRecordDecl(), clang::VectorType::getNumElements(), clang::Type::getPointeeType(), clang::interp::getRoundingMode(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::QualType::getTypePtr(), Initializing, clang::interp::Descriptor::InlineDescMD, clang::Type::isAnyComplexType(), clang::Type::isAtomicType(), clang::Type::isBooleanType(), clang::Type::isEnumeralType(), clang::Type::isFloatingType(), clang::Type::isFunctionPointerType(), clang::Type::isIntegralOrEnumerationType(), clang::QualType::isNull(), clang::Type::isPointerOrReferenceType(), clang::Type::isPointerType(), clang::interp::isPtrType(), clang::Type::isRealFloatingType(), clang::Type::isReferenceType(), clang::Type::isVectorType(), clang::Type::isVoidPointerType(), clang::Type::isVoidType(), clang::QualType::isVolatileQualified(), Locals, P, clang::CastExpr::path(), clang::interp::PT_IntAP, clang::interp::PT_IntAPS, clang::interp::PT_MemberPtr, clang::interp::PT_Ptr, clang::interp::Reinterpret, clang::interp::Context::shouldBeGloballyIndexed(), clang::T, ToLValue, visit(), visitArrayElemInit(), and clang::interp::Volatile.

Referenced by VisitCXXDynamicCastExpr(), and VisitCXXReinterpretCastExpr().

◆ VisitCharacterLiteral()

template<class Emitter>
bool Compiler::VisitCharacterLiteral ( const CharacterLiteral * E)

Definition at line 2642 of file Compiler.cpp.

References DiscardResult, and clang::CharacterLiteral::getValue().

◆ VisitChooseExpr()

template<class Emitter>
bool Compiler::VisitChooseExpr ( const ChooseExpr * E)

Definition at line 3470 of file Compiler.cpp.

References delegate(), and clang::ChooseExpr::getChosenSubExpr().

◆ VisitComplexBinOp()

◆ VisitComplexUnaryOperator()

◆ VisitCompoundAssignOperator()

◆ VisitCompoundLiteralExpr()

◆ visitCompoundStmt()

template<class Emitter>
bool Compiler::visitCompoundStmt ( const CompoundStmt * S)

Definition at line 5481 of file Compiler.cpp.

References clang::CompoundStmt::body(), and visitStmt().

Referenced by visitStmt().

◆ VisitConceptSpecializationExpr()

template<class Emitter>
bool Compiler::VisitConceptSpecializationExpr ( const ConceptSpecializationExpr * E)

◆ VisitConstantExpr()

◆ visitContinueStmt()

template<class Emitter>
bool Compiler::visitContinueStmt ( const ContinueStmt * S)

Definition at line 5899 of file Compiler.cpp.

References clang::C, clang::LoopControlStmt::getNamedLoopOrSwitch(), LabelInfoStack, and VarScope.

Referenced by visitStmt().

◆ VisitConvertVectorExpr()

◆ VisitCXXBindTemporaryExpr()

template<class Emitter>
bool Compiler::VisitCXXBindTemporaryExpr ( const CXXBindTemporaryExpr * E)

◆ VisitCXXBoolLiteralExpr()

template<class Emitter>
bool Compiler::VisitCXXBoolLiteralExpr ( const CXXBoolLiteralExpr * E)

Definition at line 5337 of file Compiler.cpp.

References DiscardResult, and clang::CXXBoolLiteralExpr::getValue().

◆ VisitCXXConstructExpr()

◆ VisitCXXDefaultArgExpr()

template<class Emitter>
bool Compiler::VisitCXXDefaultArgExpr ( const CXXDefaultArgExpr * E)

Definition at line 5330 of file Compiler.cpp.

References delegate(), and clang::CXXDefaultArgExpr::getExpr().

◆ VisitCXXDefaultInitExpr()

template<class Emitter>
bool Compiler::VisitCXXDefaultInitExpr ( const CXXDefaultInitExpr * E)

Definition at line 5323 of file Compiler.cpp.

References delegate(), and clang::CXXDefaultInitExpr::getExpr().

◆ VisitCXXDeleteExpr()

◆ VisitCXXDynamicCastExpr()

template<class Emitter>
bool Compiler::VisitCXXDynamicCastExpr ( const CXXDynamicCastExpr * E)

Definition at line 3169 of file Compiler.cpp.

References Ctx, clang::interp::Dynamic, and VisitCastExpr().

◆ visitCXXForRangeStmt()

◆ VisitCXXInheritedCtorInitExpr()

◆ VisitCXXNewExpr()

◆ VisitCXXNoexceptExpr()

template<class Emitter>
bool Compiler::VisitCXXNoexceptExpr ( const CXXNoexceptExpr * E)

◆ VisitCXXNullPtrLiteralExpr()

template<class Emitter>
bool Compiler::VisitCXXNullPtrLiteralExpr ( const CXXNullPtrLiteralExpr * E)

Definition at line 5345 of file Compiler.cpp.

References Ctx, DiscardResult, and clang::Expr::getType().

◆ VisitCXXParenListInitExpr()

template<class Emitter>
bool Compiler::VisitCXXParenListInitExpr ( const CXXParenListInitExpr * E)

◆ VisitCXXReinterpretCastExpr()

◆ VisitCXXRewrittenBinaryOperator()

template<class Emitter>
bool Compiler::VisitCXXRewrittenBinaryOperator ( const CXXRewrittenBinaryOperator * E)

◆ VisitCXXScalarValueInitExpr()

template<class Emitter>
bool Compiler::VisitCXXScalarValueInitExpr ( const CXXScalarValueInitExpr * E)

◆ VisitCXXStdInitializerListExpr()

◆ VisitCXXThisExpr()

◆ VisitCXXThrowExpr()

template<class Emitter>
bool Compiler::VisitCXXThrowExpr ( const CXXThrowExpr * E)

Definition at line 3112 of file Compiler.cpp.

References clang::CXXThrowExpr::getSubExpr().

◆ visitCXXTryStmt()

template<class Emitter>
bool Compiler::visitCXXTryStmt ( const CXXTryStmt * S)

Definition at line 6068 of file Compiler.cpp.

References clang::CXXTryStmt::getTryBlock(), and visitStmt().

Referenced by visitStmt().

◆ VisitCXXTypeidExpr()

◆ VisitCXXUuidofExpr()

◆ visitDecl()

◆ visitDeclAndReturn()

◆ visitDeclRef()

◆ VisitDeclRefExpr()

template<class Emitter>
bool Compiler::VisitDeclRefExpr ( const DeclRefExpr * E)

Definition at line 7017 of file Compiler.cpp.

References clang::DeclRefExpr::getDecl(), and visitDeclRef().

◆ visitDeclStmt()

template<class Emitter>
bool Compiler::visitDeclStmt ( const DeclStmt * DS,
bool EvaluateConditionDecl = false )

◆ visitDefaultStmt()

template<class Emitter>
bool Compiler::visitDefaultStmt ( const DefaultStmt * S)

Definition at line 6020 of file Compiler.cpp.

References clang::DefaultStmt::getSubStmt(), LabelInfoStack, and visitStmt().

Referenced by visitStmt().

◆ visitDoStmt()

template<class Emitter>
bool Compiler::visitDoStmt ( const DoStmt * S)

◆ VisitEmbedExpr()

template<class Emitter>
bool Compiler::VisitEmbedExpr ( const EmbedExpr * E)

Definition at line 2178 of file Compiler.cpp.

References clang::EmbedExpr::begin(), and visit().

◆ visitExpr()

template<class Emitter>
bool Compiler::visitExpr ( const Expr * E,
bool DestroyToplevelScope )
overrideprotected

◆ VisitExpressionTraitExpr()

template<class Emitter>
bool Compiler::VisitExpressionTraitExpr ( const ExpressionTraitExpr * E)

Definition at line 3843 of file Compiler.cpp.

References Ctx, and clang::ExpressionTraitExpr::getValue().

◆ VisitExprWithCleanups()

template<class Emitter>
bool Compiler::VisitExprWithCleanups ( const ExprWithCleanups * E)

◆ VisitExtVectorElementExpr()

◆ VisitFixedPointBinOp()

◆ VisitFixedPointLiteral()

◆ VisitFixedPointUnaryOperator()

template<class Emitter>
bool Compiler::VisitFixedPointUnaryOperator ( const UnaryOperator * E)

◆ VisitFloatCompoundAssignOperator()

◆ VisitFloatingLiteral()

template<class Emitter>
bool Compiler::VisitFloatingLiteral ( const FloatingLiteral * E)

Definition at line 789 of file Compiler.cpp.

References DiscardResult, and clang::FloatingLiteral::getValue().

◆ visitForStmt()

◆ visitFunc()

◆ VisitGenericSelectionExpr()

template<class Emitter>
bool Compiler::VisitGenericSelectionExpr ( const GenericSelectionExpr * E)

Definition at line 3464 of file Compiler.cpp.

References delegate(), and clang::GenericSelectionExpr::getResultExpr().

◆ VisitGNUNullExpr()

template<class Emitter>
bool Compiler::VisitGNUNullExpr ( const GNUNullExpr * E)

◆ visitIfStmt()

◆ VisitImaginaryLiteral()

◆ VisitImplicitValueInitExpr()

◆ visitInitializer()

template<class Emitter>
bool Compiler::visitInitializer ( const Expr * E)
protected

Compiles an initializer.

This is like visit() but it will never create a variable and instead rely on a variable already having been created. visitInitializer() then relies on a pointer to this variable being on top of the stack.

Definition at line 4233 of file Compiler.cpp.

References canClassify(), clang::Expr::getType(), and clang::StmtVisitorBase< llvm::make_const_ptr, Compiler< Emitter >, bool, ParamTys... >::Visit().

Referenced by visit(), visitArrayElemInit(), visitCallArgs(), VisitCompoundLiteralExpr(), VisitCXXConstructExpr(), VisitCXXNewExpr(), visitExpr(), visitInitList(), VisitLambdaExpr(), VisitMaterializeTemporaryExpr(), VisitOpaqueValueExpr(), visitReturnStmt(), and visitVarDecl().

◆ visitInitList()

◆ VisitInitListExpr()

template<class Emitter>
bool Compiler::VisitInitListExpr ( const InitListExpr * E)

◆ VisitIntegerLiteral()

template<class Emitter>
bool Compiler::VisitIntegerLiteral ( const IntegerLiteral * E)

Definition at line 781 of file Compiler.cpp.

References DiscardResult, and clang::interp::LE().

◆ VisitLambdaExpr()

◆ VisitLogicalBinOp()

◆ VisitMaterializeTemporaryExpr()

◆ VisitMemberExpr()

◆ VisitObjCBoolLiteralExpr()

template<class Emitter>
bool Compiler::VisitObjCBoolLiteralExpr ( const ObjCBoolLiteralExpr * E)

Definition at line 3475 of file Compiler.cpp.

References DiscardResult, and clang::ObjCBoolLiteralExpr::getValue().

◆ VisitObjCBoxedExpr()

◆ VisitObjCEncodeExpr()

◆ VisitObjCStringLiteral()

template<class Emitter>
bool Compiler::VisitObjCStringLiteral ( const ObjCStringLiteral * E)

Definition at line 2600 of file Compiler.cpp.

References DiscardResult.

◆ VisitOffsetOfExpr()

◆ VisitOpaqueValueExpr()

◆ VisitPackIndexingExpr()

template<class Emitter>
bool Compiler::VisitPackIndexingExpr ( const PackIndexingExpr * E)

Definition at line 3932 of file Compiler.cpp.

References delegate(), and clang::PackIndexingExpr::getSelectedExpr().

◆ VisitParenExpr()

template<class Emitter>
bool Compiler::VisitParenExpr ( const ParenExpr * E)

Definition at line 835 of file Compiler.cpp.

References delegate(), and clang::ParenExpr::getSubExpr().

◆ VisitPointerArithBinOp()

template<class Emitter>
bool Compiler::VisitPointerArithBinOp ( const BinaryOperator * E)

◆ VisitPointerCompoundAssignOperator()

◆ VisitPredefinedExpr()

template<class Emitter>
bool Compiler::VisitPredefinedExpr ( const PredefinedExpr * E)

◆ VisitPseudoObjectExpr()

template<class Emitter>
bool Compiler::VisitPseudoObjectExpr ( const PseudoObjectExpr * E)

◆ VisitRecoveryExpr()

template<class Emitter>
bool Compiler::VisitRecoveryExpr ( const RecoveryExpr * E)

Definition at line 3937 of file Compiler.cpp.

◆ VisitRequiresExpr()

template<class Emitter>
bool Compiler::VisitRequiresExpr ( const RequiresExpr * E)

◆ visitReturnStmt()

template<class Emitter>
bool Compiler::visitReturnStmt ( const ReturnStmt * RS)

◆ VisitShuffleVectorExpr()

◆ VisitSizeOfPackExpr()

template<class Emitter>
bool Compiler::VisitSizeOfPackExpr ( const SizeOfPackExpr * E)

Definition at line 3459 of file Compiler.cpp.

References clang::SizeOfPackExpr::getPackLength().

◆ VisitSourceLocExpr()

◆ visitStmt()

◆ VisitStmtExpr()

◆ VisitStringLiteral()

◆ VisitSubstNonTypeTemplateParmExpr()

template<class Emitter>
bool Compiler::VisitSubstNonTypeTemplateParmExpr ( const SubstNonTypeTemplateParmExpr * E)

◆ visitSwitchStmt()

◆ VisitSYCLUniqueStableNameExpr()

◆ VisitTypeTraitExpr()

◆ VisitUnaryExprOrTypeTraitExpr()

◆ VisitUnaryOperator()

◆ visitVarDecl()

◆ VisitVectorBinOp()

◆ VisitVectorUnaryOperator()

◆ visitWhileStmt()

◆ ArrayIndexScope< Emitter >

template<class Emitter>
friend class ArrayIndexScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ DeclScope< Emitter >

template<class Emitter>
friend class DeclScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ DestructorScope< Emitter >

template<class Emitter>
friend class DestructorScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ InitLink

template<class Emitter>
friend struct InitLink
friend

Definition at line 351 of file Compiler.h.

References InitLink, and clang::T.

Referenced by InitLink.

◆ InitLinkScope< Emitter >

template<class Emitter>
friend class InitLinkScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ InitStackScope< Emitter >

template<class Emitter>
friend class InitStackScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ LabelScope< Emitter >

template<class Emitter>
friend class LabelScope< Emitter >
friend

Definition at line 351 of file Compiler.h.

◆ LocalScope< Emitter >

template<class Emitter>
friend class LocalScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ LocOverrideScope< Emitter >

template<class Emitter>
friend class LocOverrideScope< Emitter >
friend

Definition at line 351 of file Compiler.h.

◆ LoopScope< Emitter >

template<class Emitter>
friend class LoopScope< Emitter >
friend

Definition at line 351 of file Compiler.h.

◆ OptionScope< Emitter >

template<class Emitter>
friend class OptionScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ SourceLocScope< Emitter >

template<class Emitter>
friend class SourceLocScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

◆ StmtExprScope< Emitter >

template<class Emitter>
friend class StmtExprScope< Emitter >
friend

Definition at line 351 of file Compiler.h.

◆ SwitchScope< Emitter >

template<class Emitter>
friend class SwitchScope< Emitter >
friend

Definition at line 351 of file Compiler.h.

◆ VariableScope< Emitter >

template<class Emitter>
friend class VariableScope< Emitter >
friend

Definition at line 339 of file Compiler.h.

Member Data Documentation

◆ ArrayIndex

template<class Emitter>
std::optional<uint64_t> clang::interp::Compiler< Emitter >::ArrayIndex
protected

Current argument index. Needed to emit ArrayInitIndexExpr.

Definition at line 438 of file Compiler.h.

Referenced by VisitArrayInitIndexExpr().

◆ CaseLabels

template<class Emitter>
CaseMap clang::interp::Compiler< Emitter >::CaseLabels
protected

Switch case mapping.

Definition at line 461 of file Compiler.h.

Referenced by visitCaseStmt(), and visitSwitchStmt().

◆ CompilingFunction

template<class Emitter>
const FunctionDecl* clang::interp::Compiler< Emitter >::CompilingFunction = nullptr
protected

Definition at line 465 of file Compiler.h.

Referenced by VisitCallExpr(), and visitFunc().

◆ Ctx

◆ DiscardResult

template<class Emitter>
bool clang::interp::Compiler< Emitter >::DiscardResult = false
protected

Flag indicating if return value is to be discarded.

Definition at line 444 of file Compiler.h.

Referenced by visitAPValue(), VisitArrayInitLoopExpr(), VisitArraySubscriptExpr(), VisitArrayTypeTraitExpr(), VisitBinaryOperator(), VisitBlockExpr(), VisitBuiltinCallExpr(), VisitCallExpr(), VisitCastExpr(), VisitCharacterLiteral(), VisitComplexBinOp(), VisitComplexUnaryOperator(), VisitCompoundAssignOperator(), VisitCompoundLiteralExpr(), VisitConceptSpecializationExpr(), VisitConstantExpr(), VisitCXXBindTemporaryExpr(), VisitCXXBoolLiteralExpr(), VisitCXXConstructExpr(), VisitCXXNewExpr(), VisitCXXNoexceptExpr(), VisitCXXNullPtrLiteralExpr(), VisitCXXScalarValueInitExpr(), VisitCXXThisExpr(), VisitCXXTypeidExpr(), VisitCXXUuidofExpr(), visitDeclRef(), VisitExtVectorElementExpr(), VisitFixedPointBinOp(), VisitFixedPointLiteral(), VisitFloatCompoundAssignOperator(), VisitFloatingLiteral(), VisitGNUNullExpr(), VisitImaginaryLiteral(), visitInitList(), VisitIntegerLiteral(), VisitLambdaExpr(), VisitLogicalBinOp(), VisitMaterializeTemporaryExpr(), VisitMemberExpr(), VisitObjCBoolLiteralExpr(), VisitObjCBoxedExpr(), VisitObjCStringLiteral(), VisitOffsetOfExpr(), VisitOpaqueValueExpr(), VisitPointerArithBinOp(), VisitPointerCompoundAssignOperator(), VisitPredefinedExpr(), VisitRequiresExpr(), VisitSourceLocExpr(), VisitStringLiteral(), VisitSYCLUniqueStableNameExpr(), VisitTypeTraitExpr(), VisitUnaryExprOrTypeTraitExpr(), VisitUnaryOperator(), VisitVectorBinOp(), and VisitVectorUnaryOperator().

◆ Initializing

◆ InitializingDecl

template<class Emitter>
const ValueDecl* clang::interp::Compiler< Emitter >::InitializingDecl = nullptr
protected

Definition at line 452 of file Compiler.h.

Referenced by visitDeclRef().

◆ InitStack

template<class Emitter>
llvm::SmallVector<InitLink> clang::interp::Compiler< Emitter >::InitStack
protected

Definition at line 454 of file Compiler.h.

Referenced by VisitCXXThisExpr().

◆ InitStackActive

template<class Emitter>
bool clang::interp::Compiler< Emitter >::InitStackActive = false
protected

Definition at line 455 of file Compiler.h.

Referenced by VisitCXXThisExpr().

◆ InStmtExpr

template<class Emitter>
bool clang::interp::Compiler< Emitter >::InStmtExpr = false
protected

Definition at line 446 of file Compiler.h.

Referenced by visitReturnStmt().

◆ LabelInfoStack

template<class Emitter>
llvm::SmallVector<LabelInfo> clang::interp::Compiler< Emitter >::LabelInfoStack
protected

Stack of label information for loops and switch statements.

Definition at line 463 of file Compiler.h.

Referenced by visitBreakStmt(), visitContinueStmt(), and visitDefaultStmt().

◆ Locals

template<class Emitter>
llvm::DenseMap<const ValueDecl *, Scope::Local> clang::interp::Compiler< Emitter >::Locals
protected

Variable to storage mapping.

Definition at line 429 of file Compiler.h.

Referenced by allocateLocal(), allocateLocalPrimitive(), VisitCastExpr(), visitDeclAndReturn(), and visitDeclRef().

◆ OpaqueExprs

template<class Emitter>
llvm::DenseMap<const OpaqueValueExpr *, unsigned> clang::interp::Compiler< Emitter >::OpaqueExprs
protected

OpaqueValueExpr to location mapping.

Definition at line 432 of file Compiler.h.

Referenced by VisitOpaqueValueExpr().

◆ P

◆ ReturnType

template<class Emitter>
OptPrimType clang::interp::Compiler< Emitter >::ReturnType
protected

Type of the expression returned by the function.

Definition at line 458 of file Compiler.h.

Referenced by VisitBuiltinCallExpr(), VisitCallExpr(), visitFunc(), and visitReturnStmt().

◆ SourceLocDefaultExpr

template<class Emitter>
const Expr* clang::interp::Compiler< Emitter >::SourceLocDefaultExpr = nullptr
protected

DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.

Definition at line 441 of file Compiler.h.

Referenced by VisitSourceLocExpr().

◆ ToLValue

template<class Emitter>
bool clang::interp::Compiler< Emitter >::ToLValue = false
protected

Definition at line 447 of file Compiler.h.

Referenced by visit(), and VisitCastExpr().

◆ VarScope


The documentation for this class was generated from the following files: