clang 20.0.0git
|
Holds all information required to evaluate constexpr code in a module. More...
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/Context.h"
Public Member Functions | |
Context (ASTContext &Ctx) | |
Initialises the constexpr VM. | |
~Context () | |
Cleans up the constexpr VM. | |
bool | isPotentialConstantExpr (State &Parent, const FunctionDecl *FnDecl) |
Checks if a function is a potential constant expression. | |
bool | evaluateAsRValue (State &Parent, const Expr *E, APValue &Result) |
Evaluates a toplevel expression as an rvalue. | |
bool | evaluate (State &Parent, const Expr *E, APValue &Result) |
Like evaluateAsRvalue(), but does no implicit lvalue-to-rvalue conversion. | |
bool | evaluateAsInitializer (State &Parent, const VarDecl *VD, APValue &Result) |
Evaluates a toplevel initializer. | |
ASTContext & | getASTContext () const |
Returns the AST context. | |
const LangOptions & | getLangOpts () const |
Returns the language options. | |
InterpStack & | getStack () |
Returns the interpreter stack. | |
unsigned | getCharBit () const |
Returns CHAR_BIT. | |
const llvm::fltSemantics & | getFloatSemantics (QualType T) const |
Return the floating-point semantics for T. | |
uint32_t | getBitWidth (QualType T) const |
Return the size of T in bits. | |
std::optional< PrimType > | classify (QualType T) const |
Classifies a type. | |
std::optional< PrimType > | classify (const Expr *E) const |
Classifies an expression. | |
const CXXMethodDecl * | getOverridingFunction (const CXXRecordDecl *DynamicDecl, const CXXRecordDecl *StaticDecl, const CXXMethodDecl *InitialFunction) const |
const Function * | getOrCreateFunction (const FunctionDecl *FD) |
Program & | getProgram () const |
Returns the program. This is only needed for unittests. | |
unsigned | collectBaseOffset (const RecordDecl *BaseDecl, const RecordDecl *DerivedDecl) const |
const Record * | getRecord (const RecordDecl *D) const |
unsigned | getEvalID () const |
Static Public Member Functions | |
static bool | shouldBeGloballyIndexed (const ValueDecl *VD) |
Returns whether we should create a global variable for the given ValueDecl. | |
Holds all information required to evaluate constexpr code in a module.
Context::Context | ( | ASTContext & | Ctx | ) |
Initialises the constexpr VM.
Definition at line 24 of file Context.cpp.
Context::~Context | ( | ) |
Cleans up the constexpr VM.
Definition at line 26 of file Context.cpp.
Classifies an expression.
Definition at line 77 of file Context.h.
References classify(), E, clang::interp::PT_FnPtr, and clang::interp::PT_Ptr.
Classifies a type.
Definition at line 130 of file Context.cpp.
References classify(), clang::Type::getAs(), clang::ASTContext::getIntWidth(), clang::Type::isAnyComplexType(), clang::Type::isBlockPointerType(), clang::Type::isBooleanType(), clang::Type::isFloatingType(), clang::Type::isFunctionPointerType(), clang::Type::isFunctionReferenceType(), clang::Type::isFunctionType(), clang::Type::isMemberPointerType(), clang::Type::isNullPtrType(), clang::Type::isObjCObjectPointerType(), clang::Type::isPointerOrReferenceType(), clang::Type::isSignedIntegerOrEnumerationType(), clang::Type::isSpecificBuiltinType(), clang::Type::isUnsignedIntegerOrEnumerationType(), clang::Type::isVectorType(), clang::interp::PT_Bool, clang::interp::PT_Float, clang::interp::PT_FnPtr, clang::interp::PT_IntAP, clang::interp::PT_IntAPS, clang::interp::PT_MemberPtr, 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, and clang::T.
Referenced by clang::interp::Compiler< Emitter >::classify(), classify(), clang::interp::ByteCodeEmitter::compileFunc(), clang::interp::ByteCodeEmitter::compileObjCBlock(), clang::interp::Program::createDescriptor(), clang::interp::InterpFrame::describe(), clang::interp::Program::getOrCreateDummy(), clang::interp::Program::getOrCreateRecord(), and clang::interp::Pointer::toRValue().
unsigned Context::collectBaseOffset | ( | const RecordDecl * | BaseDecl, |
const RecordDecl * | DerivedDecl | ||
) | const |
Definition at line 281 of file Context.cpp.
References clang::interp::Record::bases(), and clang::interp::Record::getNumBases().
Referenced by clang::interp::MemberPointer::toPointer().
Like evaluateAsRvalue(), but does no implicit lvalue-to-rvalue conversion.
Definition at line 72 of file Context.cpp.
References clang::C, clang::interp::InterpStack::clear(), E, clang::interp::InterpStack::empty(), Parent, and clang::Result.
Evaluates a toplevel initializer.
Definition at line 98 of file Context.cpp.
References clang::C, clang::interp::CheckGlobalInitialized(), clang::interp::InterpStack::clear(), clang::interp::InterpStack::empty(), clang::ValueDecl::getType(), clang::Type::isArrayType(), clang::Type::isRecordType(), Parent, clang::Result, and shouldBeGloballyIndexed().
Evaluates a toplevel expression as an rvalue.
Definition at line 44 of file Context.cpp.
References clang::C, clang::interp::InterpStack::clear(), E, clang::interp::InterpStack::empty(), clang::Expr::isGLValue(), Parent, and clang::Result.
|
inline |
Returns the AST context.
Definition at line 61 of file Context.h.
Referenced by clang::interp::EvaluationResult::dump(), clang::interp::Program::dump(), clang::interp::EvaluationResult::toAPValue(), clang::interp::EvaluationResult::toRValue(), and clang::interp::Pointer::toRValue().
|
inline |
Return the size of T in bits.
Definition at line 71 of file Context.h.
References clang::ASTContext::getIntWidth(), and clang::T.
unsigned Context::getCharBit | ( | ) | const |
Returns CHAR_BIT.
Definition at line 197 of file Context.cpp.
References clang::TargetInfo::getCharWidth(), and clang::ASTContext::getTargetInfo().
Referenced by clang::interp::Program::createGlobalString().
|
inline |
Definition at line 112 of file Context.h.
Referenced by clang::interp::Program::createGlobalString(), clang::interp::EvalEmitter::createLocal(), clang::interp::Program::getOrCreateDummy(), and clang::interp::InterpFrame::getParamPointer().
const llvm::fltSemantics & Context::getFloatSemantics | ( | QualType | T | ) | const |
Return the floating-point semantics for T.
Simple wrapper around getFloatTypeSemantics() to make code a little shorter.
Definition at line 203 of file Context.cpp.
References clang::ASTContext::getFloatTypeSemantics(), and clang::T.
const LangOptions & Context::getLangOpts | ( | ) | const |
Returns the language options.
Definition at line 128 of file Context.cpp.
References clang::ASTContext::getLangOpts().
const Function * Context::getOrCreateFunction | ( | const FunctionDecl * | FD | ) |
Definition at line 264 of file Context.cpp.
References clang::Func.
const CXXMethodDecl * Context::getOverridingFunction | ( | const CXXRecordDecl * | DynamicDecl, |
const CXXRecordDecl * | StaticDecl, | ||
const CXXMethodDecl * | InitialFunction | ||
) | const |
|
inline |
Returns the program. This is only needed for unittests.
Definition at line 105 of file Context.h.
Referenced by clang::interp::MemberPointer::toFunctionPointer().
const Record * Context::getRecord | ( | const RecordDecl * | D | ) | const |
Definition at line 312 of file Context.cpp.
References D.
Referenced by clang::interp::MemberPointer::toPointer().
|
inline |
bool Context::isPotentialConstantExpr | ( | State & | Parent, |
const FunctionDecl * | FnDecl | ||
) |
Checks if a function is a potential constant expression.
Definition at line 28 of file Context.cpp.
References clang::interp::InterpStack::empty(), clang::Func, and Parent.
Returns whether we should create a global variable for the given ValueDecl.
Definition at line 97 of file Context.h.
References V.
Referenced by clang::interp::Program::createGlobal(), evaluateAsInitializer(), clang::interp::Compiler< Emitter >::visitDecl(), clang::interp::Compiler< Emitter >::visitDeclAndReturn(), and clang::interp::Compiler< Emitter >::visitVarDecl().