41 return Func->isConstexpr();
46 bool Recursing = !Stk.
empty();
51 if (Res.isInvalid()) {
74 bool Recursing = !Stk.
empty();
77 auto Res =
C.interpretExpr(
E);
78 if (Res.isInvalid()) {
101 bool Recursing = !Stk.
empty();
108 if (Res.isInvalid()) {
189 return classify(AT->getValueType());
191 if (
const auto *DT = dyn_cast<DecltypeType>(
T))
192 return classify(DT->getUnderlyingType());
233 assert(InitialFunction);
252 if (
Base == StaticDecl ||
Base->isDerivedFrom(StaticDecl)) {
260 "Couldn't find an overriding function in the class hierarchy?");
267 bool IsBeingCompiled =
Func &&
Func->isDefined() && !
Func->isFullyCompiled();
268 bool WasNotDefined =
Func && !
Func->isConstexpr() && !
Func->isDefined();
273 if (!
Func || WasNotDefined) {
285 const auto *FinalDecl = cast<CXXRecordDecl>(BaseDecl);
287 const Record *CurRecord = P->getOrCreateRecord(CurDecl);
288 assert(CurDecl && FinalDecl);
290 unsigned OffsetSum = 0;
294 for (
const Record::Base &B : CurRecord->
bases()) {
295 const auto *BaseDecl = cast<CXXRecordDecl>(B.Decl);
297 if (BaseDecl == FinalDecl || BaseDecl->isDerivedFrom(FinalDecl)) {
298 OffsetSum += B.Offset;
304 if (CurDecl == FinalDecl)
308 assert(OffsetSum > 0);
313 return P->getOrCreateRecord(
D);
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getIntWidth(QualType T) const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
const LangOptions & getLangOpts() const
const TargetInfo & getTargetInfo() const
Represents a base class of a C++ class.
QualType getType() const
Retrieves the type of the base class.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getCorrespondingMethodDeclaredInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find if RD declares a function that overrides this function, and if so, return it.
Represents a C++ struct/union/class.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
base_class_iterator bases_begin()
This represents one expression.
Represents a function declaration or definition.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
Represents a struct/union/class.
unsigned getCharWidth() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
bool isFunctionReferenceType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool isUnsignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is unsigned or an enumeration types whose underlying ...
bool isFunctionPointerType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isAnyComplexType() const
bool isMemberPointerType() const
bool isPointerOrReferenceType() const
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isFloatingType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
Represents a variable declaration or definition.
Pointer into the code segment.
Compilation context for expressions.
const LangOptions & getLangOpts() const
Returns the language options.
~Context()
Cleans up the constexpr VM.
Context(ASTContext &Ctx)
Initialises the constexpr VM.
bool evaluate(State &Parent, const Expr *E, APValue &Result)
Like evaluateAsRvalue(), but does no implicit lvalue-to-rvalue conversion.
unsigned getCharBit() const
Returns CHAR_BIT.
bool evaluateAsInitializer(State &Parent, const VarDecl *VD, APValue &Result)
Evaluates a toplevel initializer.
const llvm::fltSemantics & getFloatSemantics(QualType T) const
Return the floating-point semantics for T.
static bool shouldBeGloballyIndexed(const ValueDecl *VD)
Returns whether we should create a global variable for the given ValueDecl.
unsigned collectBaseOffset(const RecordDecl *BaseDecl, const RecordDecl *DerivedDecl) const
const Record * getRecord(const RecordDecl *D) const
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.
const CXXMethodDecl * getOverridingFunction(const CXXRecordDecl *DynamicDecl, const CXXRecordDecl *StaticDecl, const CXXMethodDecl *InitialFunction) const
std::optional< PrimType > classify(QualType T) const
Classifies a type.
const Function * getOrCreateFunction(const FunctionDecl *FD)
Frame storing local variables.
void clear()
Clears the stack without calling any destructors.
bool empty() const
Returns whether the stack is empty.
The program contains and links the bytecode for all functions.
Structure/Class descriptor.
unsigned getNumBases() const
llvm::iterator_range< const_base_iter > bases() const
Interface for the VM to interact with the AST walker's context.
Defines the clang::TargetInfo interface.
bool Interpret(InterpState &S, APValue &Result)
Interpreter entry point.
bool CheckGlobalInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr)
Check if a global variable is initialized.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T