clang 17.0.0git
|
Compilation context for expressions. More...
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/Interp/ByteCodeExprGen.h"
Protected Types | |
using | LabelTy = typename Emitter::LabelTy |
using | AddrTy = typename Emitter::AddrTy |
Protected Member Functions | |
bool | visitExpr (const Expr *E) override |
bool | visitDecl (const VarDecl *VD) override |
Toplevel visitDecl(). | |
void | emitCleanup () |
Emits scope cleanup instructions. | |
const RecordType * | getRecordTy (QualType Ty) |
Returns a record type from a record or pointer type. | |
Record * | getRecord (QualType Ty) |
Returns a record from a record or pointer type. | |
Record * | getRecord (const RecordDecl *RD) |
const Function * | getFunction (const FunctionDecl *FD) |
std::optional< PrimType > | classify (const Expr *E) const |
Classifies a type. | |
std::optional< PrimType > | classify (QualType Ty) const |
PrimType | classifyPrim (QualType Ty) const |
Classifies a known primitive type. | |
bool | discard (const Expr *E) |
Evaluates an expression for side effects and discards the result. | |
bool | visit (const Expr *E) |
Evaluates an expression and places result on stack. | |
bool | visitInitializer (const Expr *E) |
Compiles an initializer. | |
bool | visitArrayInitializer (const Expr *Initializer) |
Compiles an array initializer. | |
bool | visitRecordInitializer (const Expr *Initializer) |
Compiles a record initializer. | |
bool | visitVarDecl (const VarDecl *VD) |
Creates and initializes a variable from the given decl. | |
bool | visitBool (const Expr *E) |
Visits an expression and converts it to a boolean. | |
bool | visitLocalInitializer (const Expr *Init, unsigned I) |
Visits an initializer for a local. | |
bool | visitGlobalInitializer (const Expr *Init, unsigned I) |
Visits an initializer for a global. | |
bool | visitThisInitializer (const Expr *I) |
Visits a delegated initializer. | |
unsigned | allocateLocalPrimitive (DeclTy &&Decl, PrimType Ty, bool IsMutable, bool IsExtended=false) |
Creates a local primitive value. | |
std::optional< unsigned > | allocateLocal (DeclTy &&Decl, bool IsExtended=false) |
Allocates a space storing a local given its type. | |
Protected Attributes | |
Context & | Ctx |
Current compilation context. | |
Program & | P |
Program to link to. | |
llvm::DenseMap< const ValueDecl *, Scope::Local > | Locals |
Variable to storage mapping. | |
llvm::DenseMap< const OpaqueValueExpr *, unsigned > | OpaqueExprs |
OpaqueValueExpr to location mapping. | |
VariableScope< Emitter > * | VarScope = nullptr |
Current scope. | |
std::optional< uint64_t > | ArrayIndex |
Current argument index. Needed to emit ArrayInitIndexExpr. | |
bool | DiscardResult = false |
Flag indicating if return value is to be discarded. | |
Friends | |
class | VariableScope< Emitter > |
class | LocalScope< Emitter > |
class | RecordScope< Emitter > |
class | DeclScope< Emitter > |
class | OptionScope< Emitter > |
class | ArrayIndexScope< Emitter > |
Additional Inherited Members | |
![]() | |
ParamTys | P { return RetTy() |
Compilation context for expressions.
Definition at line 40 of file ByteCodeExprGen.h.
|
protected |
Definition at line 45 of file ByteCodeExprGen.h.
|
protected |
Definition at line 44 of file ByteCodeExprGen.h.
|
inline |
Initializes the compiler and the backend emitter.
Definition at line 55 of file ByteCodeExprGen.h.
|
protected |
Allocates a space storing a local given its type.
Definition at line 1159 of file ByteCodeExprGen.cpp.
References clang::ValueDecl::getType(), clang::Expr::getType(), clang::QualType::getTypePtr(), clang::interp::Descriptor::InlineDescMD, clang::QualType::isConstQualified(), and P.
|
protected |
Creates a local primitive value.
Definition at line 1134 of file ByteCodeExprGen.cpp.
References clang::interp::Descriptor::InlineDescMD, and P.
|
inlineprotected |
Classifies a type.
Definition at line 115 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::classify(), clang::Expr::getType(), clang::Expr::isGLValue(), and clang::interp::PT_Ptr.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classify(), and clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().
|
inlineprotected |
Definition at line 118 of file ByteCodeExprGen.h.
References clang::interp::Context::classify(), and clang::interp::ByteCodeExprGen< Emitter >::Ctx.
|
inlineprotected |
Classifies a known primitive type.
Definition at line 123 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::classify().
Evaluates an expression for side effects and discards the result.
Definition at line 904 of file ByteCodeExprGen.cpp.
References clang::Expr::containsErrors().
|
protected |
Emits scope cleanup instructions.
Definition at line 1855 of file ByteCodeExprGen.cpp.
References clang::C.
|
protected |
Definition at line 1460 of file ByteCodeExprGen.cpp.
References clang::interp::Function::hasBody(), clang::interp::Function::isFullyCompiled(), and P.
|
protected |
Definition at line 1455 of file ByteCodeExprGen.cpp.
References P.
Returns a record from a record or pointer type.
Definition at line 1447 of file ByteCodeExprGen.cpp.
|
protected |
Returns a record type from a record or pointer type.
Definition at line 1439 of file ByteCodeExprGen.cpp.
References clang::Type::getAs(), and clang::Type::getPointeeType().
Evaluates an expression and places result on stack.
Definition at line 913 of file ByteCodeExprGen.cpp.
References clang::Expr::containsErrors().
bool ByteCodeExprGen::VisitAbstractConditionalOperator | ( | const AbstractConditionalOperator * | E | ) |
Definition at line 572 of file ByteCodeExprGen.cpp.
References clang::Condition, clang::AbstractConditionalOperator::getCond(), clang::AbstractConditionalOperator::getFalseExpr(), and clang::AbstractConditionalOperator::getTrueExpr().
|
protected |
Compiles an array initializer.
Definition at line 1199 of file ByteCodeExprGen.cpp.
References clang::Type::getAsArrayTypeUnsafe(), clang::ConstantArrayType::getSize(), clang::Expr::getType(), clang::Initializer, and clang::interp::Function::isConstexpr().
bool ByteCodeExprGen::VisitArrayInitIndexExpr | ( | const ArrayInitIndexExpr * | E | ) |
Definition at line 557 of file ByteCodeExprGen.cpp.
bool ByteCodeExprGen::VisitArraySubscriptExpr | ( | const ArraySubscriptExpr * | E | ) |
Definition at line 410 of file ByteCodeExprGen.cpp.
References clang::ArraySubscriptExpr::getBase(), and clang::ArraySubscriptExpr::getIdx().
bool ByteCodeExprGen::VisitBinaryOperator | ( | const BinaryOperator * | E | ) |
Definition at line 189 of file ByteCodeExprGen.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::Type::isFloatingType(), clang::BinaryOperator::isLogicalOp(), LT, and clang::interp::PT_Ptr.
Visits an expression and converts it to a boolean.
Definition at line 922 of file ByteCodeExprGen.cpp.
References clang::Expr::getType().
Definition at line 1581 of file ByteCodeExprGen.cpp.
References clang::CallExpr::arguments(), clang::CallExpr::getCallReturnType(), clang::CallExpr::getDirectCallee(), and clang::Type::isVoidType().
Definition at line 1605 of file ByteCodeExprGen.cpp.
References clang::CallExpr::arguments(), clang::CallExpr::getBuiltinCallee(), clang::CallExpr::getCalleeDecl(), clang::CallExpr::getCallReturnType(), clang::interp::Function::hasRVO(), clang::interp::Function::isConstexpr(), clang::interp::Function::isFullyCompiled(), and clang::Type::isVoidType().
Definition at line 64 of file ByteCodeExprGen.cpp.
References dereference(), FromDecl, clang::interp::Record::getBase(), clang::CastExpr::getCastKind(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), and clang::interp::Record::Base::Offset.
bool ByteCodeExprGen::VisitCharacterLiteral | ( | const CharacterLiteral * | E | ) |
Definition at line 609 of file ByteCodeExprGen.cpp.
References clang::CharacterLiteral::getValue().
bool ByteCodeExprGen::VisitCompoundAssignOperator | ( | const CompoundAssignOperator * | E | ) |
Definition at line 721 of file ByteCodeExprGen.cpp.
References clang::CompoundAssignOperator::getComputationLHSType(), clang::CompoundAssignOperator::getComputationResultType(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::Type::isFloatingType(), clang::Type::isPointerType(), and LT.
bool ByteCodeExprGen::VisitCompoundLiteralExpr | ( | const CompoundLiteralExpr * | E | ) |
Definition at line 875 of file ByteCodeExprGen.cpp.
References clang::CompoundLiteralExpr::getInitializer(), clang::Expr::getType(), clang::CompoundLiteralExpr::isFileScope(), and P.
bool ByteCodeExprGen::VisitConstantExpr | ( | const ConstantExpr * | E | ) |
Definition at line 449 of file ByteCodeExprGen.cpp.
References clang::FullExpr::getSubExpr().
bool ByteCodeExprGen::VisitCXXBoolLiteralExpr | ( | const CXXBoolLiteralExpr * | E | ) |
Definition at line 1681 of file ByteCodeExprGen.cpp.
References clang::CXXBoolLiteralExpr::getValue().
bool ByteCodeExprGen::VisitCXXDefaultArgExpr | ( | const CXXDefaultArgExpr * | E | ) |
Definition at line 1675 of file ByteCodeExprGen.cpp.
References clang::CXXDefaultArgExpr::getExpr().
bool ByteCodeExprGen::VisitCXXDefaultInitExpr | ( | const CXXDefaultInitExpr * | E | ) |
Definition at line 1669 of file ByteCodeExprGen.cpp.
References clang::CXXDefaultInitExpr::getExpr().
bool ByteCodeExprGen::VisitCXXMemberCallExpr | ( | const CXXMemberCallExpr * | E | ) |
Definition at line 1659 of file ByteCodeExprGen.cpp.
References clang::CXXMemberCallExpr::getImplicitObjectArgument().
bool ByteCodeExprGen::VisitCXXNullPtrLiteralExpr | ( | const CXXNullPtrLiteralExpr * | E | ) |
Definition at line 1690 of file ByteCodeExprGen.cpp.
bool ByteCodeExprGen::VisitCXXThisExpr | ( | const CXXThisExpr * | E | ) |
Definition at line 1699 of file ByteCodeExprGen.cpp.
Toplevel visitDecl().
We get here from evaluateAsInitializer(). We need to evaluate the initializer and return its value.
Definition at line 1497 of file ByteCodeExprGen.cpp.
References clang::ValueDecl::getType(), clang::Decl::isInvalidDecl(), and P.
bool ByteCodeExprGen::VisitDeclRefExpr | ( | const DeclRefExpr * | E | ) |
Definition at line 1820 of file ByteCodeExprGen.cpp.
References clang::DeclRefExpr::getDecl(), Offset, P, and clang::interp::PT_Ptr.
Definition at line 1482 of file ByteCodeExprGen.cpp.
bool ByteCodeExprGen::VisitExprWithCleanups | ( | const ExprWithCleanups * | E | ) |
Definition at line 819 of file ByteCodeExprGen.cpp.
References clang::ExprWithCleanups::getNumObjects(), and clang::FullExpr::getSubExpr().
bool ByteCodeExprGen::VisitFloatCompoundAssignOperator | ( | const CompoundAssignOperator * | E | ) |
Definition at line 615 of file ByteCodeExprGen.cpp.
References clang::CompoundAssignOperator::getComputationLHSType(), clang::CompoundAssignOperator::getComputationResultType(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::Type::isFloatingType(), and LT.
bool ByteCodeExprGen::VisitFloatingLiteral | ( | const FloatingLiteral * | E | ) |
Definition at line 176 of file ByteCodeExprGen.cpp.
References clang::FloatingLiteral::getValue().
|
inlineprotected |
Visits an initializer for a global.
Definition at line 158 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
bool ByteCodeExprGen::VisitImplicitValueInitExpr | ( | const ImplicitValueInitExpr * | E | ) |
Definition at line 397 of file ByteCodeExprGen.cpp.
References clang::Expr::getType(), and clang::Type::isPointerType().
Compiles an initializer.
Definition at line 1425 of file ByteCodeExprGen.cpp.
References clang::Initializer, clang::Type::isArrayType(), and clang::Type::isRecordType().
Referenced by clang::interp::ByteCodeExprGen< Emitter >::visitGlobalInitializer(), clang::interp::ByteCodeExprGen< Emitter >::visitLocalInitializer(), and clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().
bool ByteCodeExprGen::VisitInitListExpr | ( | const InitListExpr * | E | ) |
Definition at line 434 of file ByteCodeExprGen.cpp.
References clang::InitListExpr::inits().
bool ByteCodeExprGen::VisitIntegerLiteral | ( | const IntegerLiteral * | E | ) |
Definition at line 168 of file ByteCodeExprGen.cpp.
References clang::interp::LE().
|
inlineprotected |
Visits an initializer for a local.
Definition at line 147 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
bool ByteCodeExprGen::VisitLogicalBinOp | ( | const BinaryOperator * | E | ) |
Definition at line 338 of file ByteCodeExprGen.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), and clang::BinaryOperator::isLogicalOp().
bool ByteCodeExprGen::VisitMaterializeTemporaryExpr | ( | const MaterializeTemporaryExpr * | E | ) |
Definition at line 833 of file ByteCodeExprGen.cpp.
References clang::MaterializeTemporaryExpr::getLifetimeExtendedTemporaryDecl(), clang::MaterializeTemporaryExpr::getStorageDuration(), clang::MaterializeTemporaryExpr::getSubExpr(), P, and clang::SD_Static.
bool ByteCodeExprGen::VisitMemberExpr | ( | const MemberExpr * | E | ) |
Definition at line 530 of file ByteCodeExprGen.cpp.
References clang::interp::Record::Field::Decl, clang::MemberExpr::getBase(), clang::interp::Record::getField(), clang::MemberExpr::getMemberDecl(), clang::DeclContext::getParent(), clang::ValueDecl::getType(), clang::Type::isReferenceType(), clang::Member, clang::interp::Record::Field::Offset, and clang::interp::PT_Ptr.
bool ByteCodeExprGen::VisitOpaqueValueExpr | ( | const OpaqueValueExpr * | E | ) |
Definition at line 567 of file ByteCodeExprGen.cpp.
References clang::OpaqueValueExpr::getSourceExpr().
Definition at line 184 of file ByteCodeExprGen.cpp.
References clang::ParenExpr::getSubExpr().
bool ByteCodeExprGen::VisitPointerArithBinOp | ( | const BinaryOperator * | E | ) |
Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
Definition at line 290 of file ByteCodeExprGen.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::Type::isIntegerType(), clang::Type::isPointerType(), and LT.
bool ByteCodeExprGen::VisitPointerCompoundAssignOperator | ( | const CompoundAssignOperator * | E | ) |
Definition at line 686 of file ByteCodeExprGen.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), LT, and clang::interp::PT_Ptr.
|
protected |
Compiles a record initializer.
Definition at line 1349 of file ByteCodeExprGen.cpp.
References clang::interp::Record::getField(), clang::Initializer, clang::interp::Function::isConstexpr(), and clang::interp::Record::Field::Offset.
bool ByteCodeExprGen::VisitStringLiteral | ( | const StringLiteral * | E | ) |
Definition at line 603 of file ByteCodeExprGen.cpp.
References P.
bool ByteCodeExprGen::VisitSubstNonTypeTemplateParmExpr | ( | const SubstNonTypeTemplateParmExpr * | E | ) |
Definition at line 443 of file ByteCodeExprGen.cpp.
References clang::SubstNonTypeTemplateParmExpr::getReplacement().
|
inlineprotected |
Visits a delegated initializer.
Definition at line 172 of file ByteCodeExprGen.h.
References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().
bool ByteCodeExprGen::VisitUnaryExprOrTypeTraitExpr | ( | const UnaryExprOrTypeTraitExpr * | E | ) |
Definition at line 476 of file ByteCodeExprGen.cpp.
References AlignOfType(), clang::UnaryExprOrTypeTraitExpr::getArgumentExpr(), clang::ASTContext::getDeclAlign(), clang::UnaryExprOrTypeTraitExpr::getKind(), clang::Expr::getType(), clang::UnaryExprOrTypeTraitExpr::getTypeOfArgument(), clang::ASTContext::getTypeSizeInChars(), clang::Expr::IgnoreParens(), clang::UnaryExprOrTypeTraitExpr::isArgumentType(), clang::Type::isConstantSizeType(), clang::Type::isDependentType(), clang::Type::isFunctionType(), clang::Type::isVoidType(), and clang::CharUnits::One().
bool ByteCodeExprGen::VisitUnaryOperator | ( | const UnaryOperator * | E | ) |
Definition at line 1706 of file ByteCodeExprGen.cpp.
References dereference(), clang::UnaryOperator::getOpcode(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), and clang::interp::PT_Ptr.
Creates and initializes a variable from the given decl.
Definition at line 1530 of file ByteCodeExprGen.cpp.
References clang::VarDecl::getInit(), clang::ValueDecl::getType(), clang::QualType::isConstQualified(), clang::QualType::isNull(), Offset, and P.
|
friend |
Definition at line 187 of file ByteCodeExprGen.h.
Definition at line 187 of file ByteCodeExprGen.h.
|
friend |
Definition at line 187 of file ByteCodeExprGen.h.
|
friend |
Definition at line 187 of file ByteCodeExprGen.h.
|
friend |
Definition at line 187 of file ByteCodeExprGen.h.
|
friend |
Definition at line 187 of file ByteCodeExprGen.h.
|
protected |
Current argument index. Needed to emit ArrayInitIndexExpr.
Definition at line 270 of file ByteCodeExprGen.h.
Referenced by clang::interp::ArrayIndexScope< Emitter >::ArrayIndexScope().
|
protected |
Current compilation context.
Definition at line 48 of file ByteCodeExprGen.h.
Referenced by clang::interp::ByteCodeExprGen< Emitter >::classify().
|
protected |
Flag indicating if return value is to be discarded.
Definition at line 273 of file ByteCodeExprGen.h.
Referenced by clang::interp::OptionScope< Emitter >::OptionScope().
|
protected |
Variable to storage mapping.
Definition at line 261 of file ByteCodeExprGen.h.
|
protected |
OpaqueValueExpr to location mapping.
Definition at line 264 of file ByteCodeExprGen.h.
|
protected |
Program to link to.
Definition at line 50 of file ByteCodeExprGen.h.
|
protected |
Current scope.
Definition at line 267 of file ByteCodeExprGen.h.
Referenced by clang::interp::VariableScope< Emitter >::VariableScope().