clang
10.0.0svn
|
Compilation context for expressions. More...
#include "/opt/doxygen-docs/src/llvm/tools/clang/lib/AST/Interp/ByteCodeExprGen.h"
Public Member Functions | |
template<typename... Tys> | |
ByteCodeExprGen (Context &Ctx, Program &P, Tys &&... Args) | |
Initializes the compiler and the backend emitter. More... | |
bool | VisitCastExpr (const CastExpr *E) |
bool | VisitIntegerLiteral (const IntegerLiteral *E) |
bool | VisitParenExpr (const ParenExpr *E) |
bool | VisitBinaryOperator (const BinaryOperator *E) |
![]() | |
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 | NullaryFn = bool(ByteCodeExprGen::*)(const SourceInfo &) |
using | UnaryFn = bool(ByteCodeExprGen::*)(PrimType, const SourceInfo &) |
using | BinaryFn = bool(ByteCodeExprGen::*)(PrimType, PrimType, const SourceInfo &) |
using | LabelTy = typename Emitter::LabelTy |
using | AddrTy = typename Emitter::AddrTy |
using | InitFnRef = std::function< bool()> |
Protected Member Functions | |
bool | visitExpr (const Expr *E) override |
bool | visitDecl (const VarDecl *VD) override |
void | emitCleanup () |
Emits scope cleanup instructions. More... | |
const RecordType * | getRecordTy (QualType Ty) |
Returns a record type from a record or pointer type. More... | |
Record * | getRecord (QualType Ty) |
Returns a record from a record or pointer type. More... | |
Record * | getRecord (const RecordDecl *RD) |
unsigned | getIntWidth (QualType Ty) |
Returns the size int bits of an integer. More... | |
unsigned | getCharBit () const |
Returns the value of CHAR_BIT. More... | |
llvm::Optional< PrimType > | classify (const Expr *E) const |
Classifies a type. More... | |
llvm::Optional< PrimType > | classify (QualType Ty) const |
bool | needsAdjust (QualType Ty) const |
Checks if a pointer needs adjustment. More... | |
PrimType | classifyPrim (QualType Ty) const |
Classifies a known primitive type. More... | |
bool | discard (const Expr *E) |
Evaluates an expression for side effects and discards the result. More... | |
bool | visit (const Expr *E) |
Evaluates an expression and places result on stack. More... | |
bool | visitInitializer (const Expr *E, InitFnRef GenPtr) |
Compiles an initializer for a local. More... | |
bool | visitBool (const Expr *E) |
Visits an expression and converts it to a boolean. More... | |
bool | visitLocalInitializer (const Expr *Init, unsigned I) |
Visits an initializer for a local. More... | |
bool | visitGlobalInitializer (const Expr *Init, unsigned I) |
Visits an initializer for a global. More... | |
bool | visitThisInitializer (const Expr *I) |
Visits a delegated initializer. More... | |
unsigned | allocateLocalPrimitive (DeclTy &&Decl, PrimType Ty, bool IsMutable, bool IsExtended=false) |
Creates a local primitive value. More... | |
llvm::Optional< unsigned > | allocateLocal (DeclTy &&Decl, bool IsExtended=false) |
Allocates a space storing a local given its type. More... | |
Protected Attributes | |
Context & | Ctx |
Current compilation context. More... | |
Program & | P |
Program to link to. More... | |
llvm::DenseMap< const ValueDecl *, Scope::Local > | Locals |
Variable to storage mapping. More... | |
llvm::DenseMap< const OpaqueValueExpr *, unsigned > | OpaqueExprs |
OpaqueValueExpr to location mapping. More... | |
VariableScope< Emitter > * | VarScope = nullptr |
Current scope. More... | |
llvm::Optional< uint64_t > | ArrayIndex |
Current argument index. More... | |
bool | DiscardResult = false |
Flag indicating if return value is to be discarded. More... | |
llvm::Optional< InitFnRef > | InitFn = {} |
Expression being initialized. More... | |
Friends | |
class | VariableScope< Emitter > |
class | LocalScope< Emitter > |
class | RecordScope< Emitter > |
class | DeclScope< Emitter > |
class | OptionScope< Emitter > |
Additional Inherited Members | |
![]() | |
ParamTys | P |
Compilation context for expressions.
Definition at line 41 of file ByteCodeExprGen.h.
|
protected |
Definition at line 52 of file ByteCodeExprGen.h.
|
protected |
Definition at line 48 of file ByteCodeExprGen.h.
|
protected |
Definition at line 55 of file ByteCodeExprGen.h.
|
protected |
Definition at line 51 of file ByteCodeExprGen.h.
|
protected |
Definition at line 45 of file ByteCodeExprGen.h.
|
protected |
Definition at line 46 of file ByteCodeExprGen.h.
|
inline |
Initializes the compiler and the backend emitter.
Definition at line 65 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::emitCleanup(), clang::interp::ByteCodeExprGen< Emitter >::getRecord(), clang::interp::ByteCodeExprGen< Emitter >::getRecordTy(), clang::interp::ByteCodeExprGen< Emitter >::VisitBinaryOperator(), clang::interp::ByteCodeExprGen< Emitter >::VisitCastExpr(), clang::interp::ByteCodeExprGen< Emitter >::visitDecl(), clang::interp::ByteCodeExprGen< Emitter >::visitExpr(), clang::interp::ByteCodeExprGen< Emitter >::VisitIntegerLiteral(), and clang::interp::ByteCodeExprGen< Emitter >::VisitParenExpr().
|
protected |
Allocates a space storing a local given its type.
Definition at line 437 of file ByteCodeExprGen.cpp.
References clang::Expr::getType(), clang::ValueDecl::getType(), clang::QualType::getTypePtr(), clang::QualType::isConstQualified(), clang::interp::Scope::Local::Offset, and P.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().
|
protected |
Creates a local primitive value.
Definition at line 423 of file ByteCodeExprGen.cpp.
References clang::interp::Scope::Local::Offset, and P.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().
|
inlineprotected |
Classifies a type.
Definition at line 102 of file ByteCodeExprGen.h.
References clang::Expr::getType(), clang::Expr::isGLValue(), and clang::interp::PT_Ptr.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().
|
inlineprotected |
Definition at line 105 of file ByteCodeExprGen.h.
References clang::interp::Context::classify().
|
inlineprotected |
Classifies a known primitive type.
Definition at line 115 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::classify(), clang::interp::ByteCodeExprGen< Emitter >::discard(), clang::interp::ByteCodeExprGen< Emitter >::visit(), clang::interp::ByteCodeExprGen< Emitter >::visitBool(), and clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
Evaluates an expression for side effects and discards the result.
Definition at line 209 of file ByteCodeExprGen.cpp.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().
|
protected |
Emits scope cleanup instructions.
Definition at line 568 of file ByteCodeExprGen.cpp.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
|
inlineprotected |
Returns the value of CHAR_BIT.
Definition at line 96 of file ByteCodeExprGen.h.
References clang::interp::Context::getASTContext(), clang::TargetInfo::getCharWidth(), and clang::ASTContext::getTargetInfo().
|
inlineprotected |
Returns the size int bits of an integer.
Definition at line 90 of file ByteCodeExprGen.h.
References clang::interp::Context::getASTContext(), and clang::ASTContext::getIntWidth().
Returns a record from a record or pointer type.
Definition at line 506 of file ByteCodeExprGen.cpp.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
|
protected |
Definition at line 514 of file ByteCodeExprGen.cpp.
References P.
|
protected |
Returns a record type from a record or pointer type.
Definition at line 498 of file ByteCodeExprGen.cpp.
References clang::Type::getAs(), and clang::Type::getPointeeType().
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
|
inlineprotected |
Checks if a pointer needs adjustment.
Definition at line 110 of file ByteCodeExprGen.h.
Evaluates an expression and places result on stack.
Definition at line 215 of file ByteCodeExprGen.cpp.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().
bool ByteCodeExprGen::VisitBinaryOperator | ( | const BinaryOperator * | E | ) |
Definition at line 146 of file ByteCodeExprGen.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), and clang::interp::LT().
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
Visits an expression and converts it to a boolean.
Definition at line 221 of file ByteCodeExprGen.cpp.
References clang::VarDecl::getInit(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::VarDecl::hasInit(), clang::VarDecl::hasLocalStorage(), clang::VarDecl::isConstexpr(), clang::QualType::isConstQualified(), clang::Type::isFundamentalType(), P, clang::interp::PT_Bool, clang::interp::PT_Ptr, clang::interp::PT_Sint16, clang::interp::PT_Sint32, clang::interp::PT_Sint64, clang::interp::PT_Sint8, clang::interp::PT_Uint16, clang::interp::PT_Uint32, clang::interp::PT_Uint64, clang::interp::PT_Uint8, clang::Expr::refersToBitField(), and true.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().
Definition at line 90 of file ByteCodeExprGen.cpp.
References dereference(), clang::CastExpr::getCastKind(), and clang::CastExpr::getSubExpr().
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
Definition at line 531 of file ByteCodeExprGen.cpp.
References clang::VarDecl::getInit(), clang::ValueDecl::getType(), and P.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
Definition at line 519 of file ByteCodeExprGen.cpp.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
|
inlineprotected |
Visits an initializer for a global.
Definition at line 140 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
|
protected |
Compiles an initializer for a local.
Definition at line 464 of file ByteCodeExprGen.cpp.
References clang::ValueDecl::getType(), clang::VarDecl::hasLocalStorage(), clang::VarDecl::isConstexpr(), clang::Type::isReferenceType(), and P.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim(), clang::interp::ByteCodeExprGen< Emitter >::visitGlobalInitializer(), clang::interp::ByteCodeExprGen< Emitter >::visitLocalInitializer(), and clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().
bool ByteCodeExprGen::VisitIntegerLiteral | ( | const IntegerLiteral * | E | ) |
Definition at line 129 of file ByteCodeExprGen.cpp.
References clang::Expr::getType(), clang::APIntStorage::getValue(), and clang::interp::LE().
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
|
inlineprotected |
Visits an initializer for a local.
Definition at line 133 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
Definition at line 141 of file ByteCodeExprGen.cpp.
References clang::ParenExpr::getSubExpr().
Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().
|
inlineprotected |
Visits a delegated initializer.
Definition at line 147 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::allocateLocal(), clang::interp::ByteCodeExprGen< Emitter >::allocateLocalPrimitive(), and clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
Definition at line 163 of file ByteCodeExprGen.h.
|
friend |
Definition at line 161 of file ByteCodeExprGen.h.
|
friend |
Definition at line 164 of file ByteCodeExprGen.h.
|
friend |
Definition at line 162 of file ByteCodeExprGen.h.
|
friend |
Definition at line 160 of file ByteCodeExprGen.h.
|
protected |
Current argument index.
Definition at line 227 of file ByteCodeExprGen.h.
|
protected |
Current compilation context.
Definition at line 58 of file ByteCodeExprGen.h.
|
protected |
Flag indicating if return value is to be discarded.
Definition at line 230 of file ByteCodeExprGen.h.
Referenced by clang::interp::OptionScope< Emitter >::OptionScope().
|
protected |
Expression being initialized.
Definition at line 233 of file ByteCodeExprGen.h.
Referenced by clang::interp::OptionScope< Emitter >::OptionScope().
|
protected |
Variable to storage mapping.
Definition at line 218 of file ByteCodeExprGen.h.
|
protected |
OpaqueValueExpr to location mapping.
Definition at line 221 of file ByteCodeExprGen.h.
|
protected |
Program to link to.
Definition at line 60 of file ByteCodeExprGen.h.
|
protected |
Current scope.
Definition at line 224 of file ByteCodeExprGen.h.
Referenced by clang::interp::VariableScope< Emitter >::VariableScope().