9#ifndef LLVM_CLANG_AST_INTERP_INTERPHELPERS_H
10#define LLVM_CLANG_AST_INTERP_INTERPHELPERS_H
33 ArrayRef<int64_t> ArrayIndices, int64_t &
Result);
49 APSInt &&Index,
bool AllowReplace =
true);
54 if (!Ptr.isOnePastEnd() && !Ptr.isZeroSizeArray())
64 if (!Ptr.isOnePastEnd() && !Ptr.isZeroSizeArray())
78bool CheckMutable(InterpState &S, CodePtr OpPC, PtrView Ptr,
82 if (!Ptr.isBlockPointer())
90bool CheckLoad(InterpState &S, CodePtr OpPC, PtrView Ptr,
101 bool Activate =
true,
bool Diagnose =
false);
105 const Expr *E,
bool IsDynamic =
false);
114 S.
CCEDiag(E, diag::note_constexpr_overflow) << SrcValue << E->
getType();
120 if (NumElems > std::numeric_limits<unsigned>::max()) {
126 uint64_t Limit = S.
getLangOpts().ConstexprStepLimit;
127 if (Limit != 0 && NumElems > Limit) {
129 diag::note_constexpr_new_exceeds_limits, 1)
130 << NumElems << Limit;
139 if (RM == llvm::RoundingMode::Dynamic)
140 return llvm::RoundingMode::NearestTiesToEven;
147 diag::note_invalid_subexpr_in_const_expr)
152template <
typename SizeT>
154 unsigned ElemSize,
bool IsNoThrow) {
164 if ((NumElements.bitWidth() - NumElements.isSigned()) <
173 assert(MaxElements.isPositive());
174 if (NumElements.toAPSInt().getActiveBits() >
176 NumElements > MaxElements) {
178 if (NumElements.isSigned() && NumElements.isNegative()) {
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
This represents one expression.
RoundingMode getRoundingMode() const
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
A memory block, either on the stack or in the heap.
Pointer into the code segment.
SourceInfo getSource(CodePtr PC) const
Map a location to a source.
SourceRange getRange(CodePtr PC) const
const Expr * getExpr(CodePtr PC) const
InterpFrame * Current
The current frame.
A pointer to a memory block, live or dead.
OptionalDiagnostic Note(SourceLocation Loc, diag::kind DiagId)
Add a note to a prior diagnostic.
OptionalDiagnostic FFDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
Diagnose that the evaluation could not be folded (FF => FoldFailure)
ASTContext & getASTContext() const
bool noteUndefinedBehavior() const
Note that we hit something that was technically undefined behavior, but that we can evaluate past it ...
OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
Diagnose that the evaluation does not produce a C++11 core constant expression.
const LangOptions & getLangOpts() const
bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr, CheckSubobjectKind CSK)
Checks if a field from which a pointer is going to be derived is valid.
bool arrayElemPtrOpaque(InterpState &S, CodePtr OpPC, const Pointer &Ptr, APSInt &&Index, bool AllowReplace)
bool handleOverflow(InterpState &S, CodePtr OpPC, const T &SrcValue)
bool LT(InterpState &S, CodePtr OpPC)
bool CheckNewDeleteForms(InterpState &S, CodePtr OpPC, DynamicAllocator::Form AllocForm, DynamicAllocator::Form DeleteForm, const Descriptor *D, const Expr *NewExpr)
Diagnose mismatched new[]/delete or new/delete[] pairs.
static llvm::RoundingMode getRoundingMode(FPOptions FPO)
bool Call(InterpState &S, CodePtr OpPC, const Function *Func, uint32_t VarArgSize)
bool InterpretOffsetOf(InterpState &S, CodePtr OpPC, const OffsetOfExpr *E, ArrayRef< int64_t > ArrayIndices, int64_t &IntResult)
Interpret an offsetof operation.
bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
Checks if a pointer is live and accessible.
bool diagnoseUninitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
bool diagnoseDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, uint32_t BuiltinID)
Interpret a builtin function.
static bool Activate(InterpState &S)
bool DoMemcpy(InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest, bool Activate, bool Diagnose)
Copy the contents of Src into Dest.
bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr)
Checks if the array is offsetable.
bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK)
Checks if a pointer is a dummy pointer.
bool CheckMutable(InterpState &S, CodePtr OpPC, PtrView Ptr, AccessKinds AK)
Checks if a pointer points to a mutable field.
bool CheckArraySize(InterpState &S, CodePtr OpPC, uint64_t NumElems)
bool CheckLoad(InterpState &S, CodePtr OpPC, PtrView Ptr, AccessKinds AK)
UnsignedOrNone evaluateBuiltinObjectSize(const ASTContext &ASTCtx, unsigned Kind, Pointer &Ptr, const Expr *E, bool IsDynamic)
Evaluate __builtin_object_size or __builtin_dynamic_object_size for the given pointer and Kind.
bool Interpret(InterpState &S)
Interpreter entry point.
Top level wrappers for InstallAPI frontend operations.
CheckSubobjectKind
The order of this enum is important for diagnostics.
@ Result
The result type of a method or function.
AccessKinds
Kinds of access we can perform on an object, for diagnostics.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
Describes a memory block created by an allocation site.
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.