clang 18.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/Interp/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 | 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. | |
std::optional< PrimType > | classify (QualType T) const |
Classifies an expression. | |
const CXXMethodDecl * | getOverridingFunction (const CXXRecordDecl *DynamicDecl, const CXXRecordDecl *StaticDecl, const CXXMethodDecl *InitialFunction) const |
const Function * | getOrCreateFunction (const FunctionDecl *FD) |
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 26 of file Context.cpp.
Context::~Context | ( | ) |
Cleans up the constexpr VM.
Definition at line 28 of file Context.cpp.
Classifies an expression.
Definition at line 91 of file Context.cpp.
References classify(), clang::ASTContext::getIntWidth(), clang::Type::isBooleanType(), clang::Type::isFloatingType(), clang::Type::isFunctionPointerType(), clang::Type::isFunctionReferenceType(), clang::Type::isFunctionType(), clang::Type::isNullPtrType(), clang::Type::isPointerType(), clang::Type::isReferenceType(), clang::Type::isSignedIntegerOrEnumerationType(), clang::Type::isSpecificBuiltinType(), clang::Type::isUnsignedIntegerOrEnumerationType(), clang::interp::PT_Bool, clang::interp::PT_Float, clang::interp::PT_FnPtr, 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, and clang::interp::PT_Uint8.
Referenced by classify(), clang::interp::ByteCodeExprGen< Emitter >::classify(), clang::interp::ByteCodeEmitter::compileFunc(), clang::interp::Program::createDescriptor(), clang::interp::InterpFrame::describe(), clang::interp::Program::getOrCreateRecord(), and clang::interp::Pointer::toRValue().
Evaluates a toplevel initializer.
Definition at line 71 of file Context.cpp.
References clang::C, clang::interp::InterpStack::clear(), clang::interp::InterpStack::empty(), Parent, and clang::Result.
Evaluates a toplevel expression as an rvalue.
Definition at line 54 of file Context.cpp.
References clang::C, clang::interp::InterpStack::clear(), clang::interp::InterpStack::empty(), Parent, and clang::Result.
|
inline |
Returns the AST context.
Definition at line 58 of file Context.h.
Referenced by clang::interp::Program::getOrCreateDummy().
unsigned Context::getCharBit | ( | ) | const |
Returns CHAR_BIT.
Definition at line 150 of file Context.cpp.
References clang::TargetInfo::getCharWidth(), and clang::ASTContext::getTargetInfo().
Referenced by clang::interp::Program::createGlobalString().
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 156 of file Context.cpp.
References clang::ASTContext::getFloatTypeSemantics().
const LangOptions & Context::getLangOpts | ( | ) | const |
Returns the language options.
Definition at line 89 of file Context.cpp.
References clang::ASTContext::getLangOpts().
const Function * Context::getOrCreateFunction | ( | const FunctionDecl * | FD | ) |
Definition at line 215 of file Context.cpp.
References clang::interp::Function::isConstexpr(), clang::interp::Function::isDefined(), and clang::interp::Function::isFullyCompiled().
const CXXMethodDecl * Context::getOverridingFunction | ( | const CXXRecordDecl * | DynamicDecl, |
const CXXRecordDecl * | StaticDecl, | ||
const CXXMethodDecl * | InitialFunction | ||
) | const |
|
inline |
bool Context::isPotentialConstantExpr | ( | State & | Parent, |
const FunctionDecl * | FnDecl | ||
) |
Checks if a function is a potential constant expression.
Definition at line 30 of file Context.cpp.
References clang::interp::InterpStack::empty(), clang::interp::Function::hasBody(), clang::interp::Function::isConstexpr(), and Parent.
Returns whether we should create a global variable for the given ValueDecl.
Definition at line 80 of file Context.h.
References V.
Referenced by clang::interp::Program::createGlobal(), clang::interp::ByteCodeExprGen< Emitter >::visitDecl(), and clang::interp::ByteCodeExprGen< Emitter >::visitVarDecl().