13#ifndef LLVM_CLANG_AST_INTERP_INTERPSTATE_H
14#define LLVM_CLANG_AST_INTERP_INTERPSTATE_H
68 return M->getSource(F, PC);
70 assert(F &&
"Function cannot be null");
80 Alloc = std::make_unique<DynamicAllocator>();
93 void *
allocate(
size_t Size,
unsigned Align = 8)
const {
96 return Allocator->Allocate(Size, Align);
99 return static_cast<T *
>(
allocate(
Num *
sizeof(T),
alignof(T)));
102 template <
typename T> T
allocAP(
unsigned BitWidth) {
103 unsigned NumWords = APInt::getNumWords(BitWidth);
106 uint64_t *Mem = (uint64_t *)this->
allocate(NumWords *
sizeof(uint64_t));
108 return T(Mem, BitWidth);
113 return Floating(llvm::APFloatBase::SemanticsToEnum(Sem));
116 APInt::getNumWords(llvm::APFloatBase::getSizeInBits(Sem));
117 uint64_t *Mem = (uint64_t *)this->
allocate(NumWords *
sizeof(uint64_t));
119 return Floating(Mem, llvm::APFloatBase::SemanticsToEnum(Sem));
138 std::unique_ptr<DynamicAllocator> Alloc;
140 mutable std::optional<llvm::BumpPtrAllocator> Allocator;
171 std::pair<const Expr *, const LifetimeExtendedTemporaryDecl *>>
182 : Ctx(Ctx), OldCC(Ctx.ConstantContextOverride) {
186 Ctx.ConstantContextOverride =
Value;
190 Ctx.ConstantContextOverride = OldCC;
196 std::optional<bool> OldCC;
Represents a C++ struct/union/class.
This represents one expression.
A (possibly-)qualified type.
Encodes a location in the source.
Represents a variable declaration or definition.
A memory block, either on the stack or in the heap.
Pointer into the code segment.
Holds all information required to evaluate constexpr code in a module.
Descriptor for a dead block.
Manages dynamic memory allocations done during bytecode interpretation.
If a Floating is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Base class for stack frames, shared between VM and walker.
SourceInfo getSource(CodePtr PC) const
Returns the source information at a given PC.
Frame storing local variables.
Stack frame storing temporaries and parameters.
InterpStateCCOverride(InterpState &Ctx, bool Value)
const Frame * getBottomFrame() const override
SmallVectorImpl< PartialDiagnosticAt > * PrevDiags
Things needed to do speculative execution.
unsigned getCallStackDepth() override
InterpFrame BottomFrame
Bottom function frame.
Context & getContext() const
DynamicAllocator & getAllocator()
Context & Ctx
Interpreter Context.
void * allocate(size_t Size, unsigned Align=8) const
bool noteStep(CodePtr OpPC)
Note that a step has been executed.
Floating allocFloat(const llvm::fltSemantics &Sem)
const unsigned EvalID
ID identifying this evaluation.
llvm::SmallVector< const Block * > InitializingBlocks
List of blocks we're currently running either constructors or destructors for.
SourceInfo getSource(const Function *F, CodePtr PC) const override
Delegates source mapping to the mapper.
InterpState(const State &Parent, Program &P, InterpStack &Stk, Context &Ctx, SourceMapper *M=nullptr)
InterpState(const InterpState &)=delete
bool stepsLeft() const override
llvm::SmallVector< std::pair< const Expr *, const LifetimeExtendedTemporaryDecl * > > SeenGlobalTemporaries
InterpStack & Stk
Temporary stack.
bool maybeDiagnoseDanglingAllocations()
Diagnose any dynamic allocations that haven't been freed yet.
SourceLocation EvalLocation
Source location of the evaluating expression.
unsigned StepsLeft
Steps left during evaluation.
const VarDecl * EvaluatingDecl
Declaration we're initializing/evaluting, if any.
InterpFrame * Current
The current frame.
const CXXRecordDecl ** allocMemberPointerPath(unsigned Length)
const Frame * getCurrentFrame() override
std::optional< bool > ConstantContextOverride
const bool InfiniteSteps
Whether infinite evaluation steps have been requested.
InterpState & operator=(const InterpState &)=delete
friend class InterpStateCCOverride
T * allocate(size_t Num=1) const
void deallocate(Block *B)
Deallocates a pointer.
T allocAP(unsigned BitWidth)
void setEvalLocation(SourceLocation SL)
unsigned SpeculationDepth
friend class EvaluationResult
StdAllocatorCaller getStdAllocatorCaller(StringRef Name) const
bool inConstantContext() const
Program & P
Reference to the module containing all bytecode.
The program contains and links the bytecode for all functions.
Describes the statement/declaration an opcode was generated from.
Interface for classes which map locations to sources.
Expr::EvalStatus & getEvalStatus() const
State(ASTContext &ASTCtx, Expr::EvalStatus &EvalStatus)
The JSON file list parser is used to communicate input to InstallAPI.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...