clang 23.0.0git
clang::interp::State Class Referenceabstract

Interface for the VM to interact with the AST walker's context. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/State.h"

Inheritance diagram for clang::interp::State:
[legend]

Public Member Functions

 State (ASTContext &ASTCtx, Expr::EvalStatus &EvalStatus)
virtual ~State ()
virtual const FramegetCurrentFrame ()=0
virtual const FramegetBottomFrame () const =0
virtual unsigned getCallStackDepth ()=0
virtual bool stepsLeft () const =0
Expr::EvalStatusgetEvalStatus () const
ASTContextgetASTContext () const
const LangOptionsgetLangOpts () const
bool noteSideEffect () const
 Note that we have had a side-effect, and determine whether we should keep evaluating.
bool keepEvaluatingAfterFailure () const
 Should we continue evaluation as much as possible after encountering a construct which can't be reduced to a value?
bool keepEvaluatingAfterSideEffect () const
 Should we continue evaluation after encountering a side-effect that we couldn't model?
bool noteUndefinedBehavior () const
 Note that we hit something that was technically undefined behavior, but that we can evaluate past it (such as signed overflow or floating-point division by zero.)
bool checkingPotentialConstantExpression () const
 Are we checking whether the expression is a potential constant expression?
bool checkingForUndefinedBehavior () const
 Are we checking an expression for overflow?
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)
OptionalDiagnostic FFDiag (const Expr *E, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
OptionalDiagnostic FFDiag (SourceInfo SI, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
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.
OptionalDiagnostic CCEDiag (const Expr *E, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
OptionalDiagnostic CCEDiag (SourceInfo SI, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)
OptionalDiagnostic Note (SourceLocation Loc, diag::kind DiagId)
 Add a note to a prior diagnostic.
void addNotes (ArrayRef< PartialDiagnosticAt > Diags)
 Add a stack of notes to a prior diagnostic.
DiagnosticBuilder report (SourceLocation Loc, diag::kind DiagId)
 Directly reports a diagnostic message.

Public Attributes

bool InConstantContext = false
 Whether or not we're in a context where the front end requires a constant value.
bool CheckingPotentialConstantExpression = false
 Whether we're checking that an expression is a potential constant expression.
bool CheckingForUndefinedBehavior = false
 Whether we're checking for an expression that has undefined behavior.
EvaluationMode EvalMode
ASTContextCtx
Expr::EvalStatusEvalStatus

Detailed Description

Interface for the VM to interact with the AST walker's context.

Definition at line 81 of file State.h.

Constructor & Destructor Documentation

◆ State()

clang::interp::State::State ( ASTContext & ASTCtx,
Expr::EvalStatus & EvalStatus )
inline

Definition at line 83 of file State.h.

References Ctx, and EvalStatus.

Referenced by clang::interp::InterpState::InterpState(), and clang::interp::InterpState::InterpState().

◆ ~State()

State::~State ( )
virtual

Definition at line 19 of file State.cpp.

References ~State().

Referenced by ~State().

Member Function Documentation

◆ addNotes()

void State::addNotes ( ArrayRef< PartialDiagnosticAt > Diags)

Add a stack of notes to a prior diagnostic.

Definition at line 69 of file State.cpp.

References addNotes(), and EvalStatus.

Referenced by addNotes().

◆ CCEDiag() [1/3]

OptionalDiagnostic State::CCEDiag ( const Expr * E,
diag::kind DiagId = diag::note_invalid_subexpr_in_const_expr,
unsigned ExtraNotes = 0 )

Definition at line 53 of file State.cpp.

References CCEDiag(), and clang::Expr::getExprLoc().

◆ CCEDiag() [2/3]

OptionalDiagnostic State::CCEDiag ( SourceInfo SI,
diag::kind DiagId = diag::note_invalid_subexpr_in_const_expr,
unsigned ExtraNotes = 0 )

Definition at line 58 of file State.cpp.

References CCEDiag(), and clang::interp::SourceInfo::getLoc().

◆ CCEDiag() [3/3]

OptionalDiagnostic State::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.

FIXME: Stop evaluating if we're in EM_ConstantExpression or EM_PotentialConstantExpression mode and we produce one of these.

Definition at line 42 of file State.cpp.

References CCEDiag(), and EvalStatus.

Referenced by clang::interp::Assume(), clang::interp::CallVirt(), clang::interp::CastFloatingIntegral(), CCEDiag(), CCEDiag(), CCEDiag(), clang::interp::CheckBitCast(), clang::interp::CheckCallable(), clang::interp::CheckConstant(), clang::interp::CheckDecl(), clang::interp::CheckDivRem(), clang::interp::CheckDowncast(), clang::interp::CheckDynamicMemoryAllocation(), clang::interp::CheckFloatResult(), clang::interp::CheckNonNullArg(), clang::interp::CheckNonNullArgs(), clang::interp::CheckPointerToIntegralCast(), clang::interp::CheckPseudoDtor(), clang::interp::CheckShift(), clang::interp::CmpHelper< Pointer >(), clang::interp::CmpHelperEQ< MemberPointer >(), clang::interp::convertDoubleToFloatStrict(), clang::interp::diagnoseEnumValue(), clang::interp::diagnoseNonConstexprBuiltin(), clang::interp::DiagTypeid(), clang::interp::DoShift(), clang::interp::DoShiftAP(), clang::interp::FnPtrCast(), clang::interp::GetIntPtr(), clang::interp::GetPtrDerivedPop(), clang::interp::handleFixedPointOverflow(), clang::interp::handleOverflow(), clang::interp::interp__builtin_assume_aligned(), clang::interp::interp__builtin_infer_alloc_token(), clang::interp::interp__builtin_is_within_lifetime(), clang::interp::interp__builtin_operator_delete(), clang::interp::InvalidCast(), clang::interp::InterpState::maybeDiagnoseDanglingAllocations(), clang::interp::OffsetHelper(), clang::interp::PtrPtrCast(), clang::interp::ShiftFixedPoint(), and clang::interp::SizelessVectorElementSize().

◆ checkingForUndefinedBehavior()

bool clang::interp::State::checkingForUndefinedBehavior ( ) const
inline

◆ checkingPotentialConstantExpression()

◆ FFDiag() [1/3]

OptionalDiagnostic State::FFDiag ( const Expr * E,
diag::kind DiagId = diag::note_invalid_subexpr_in_const_expr,
unsigned ExtraNotes = 0 )

Definition at line 26 of file State.cpp.

References EvalStatus, FFDiag(), and clang::Expr::getExprLoc().

◆ FFDiag() [2/3]

OptionalDiagnostic State::FFDiag ( SourceInfo SI,
diag::kind DiagId = diag::note_invalid_subexpr_in_const_expr,
unsigned ExtraNotes = 0 )

Definition at line 34 of file State.cpp.

References EvalStatus, FFDiag(), and clang::interp::SourceInfo::getLoc().

◆ FFDiag() [3/3]

OptionalDiagnostic State::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)

Definition at line 21 of file State.cpp.

References FFDiag().

Referenced by clang::interp::AllocN(), clang::interp::ArrayDecay(), clang::interp::BitCastPrim(), clang::interp::CallPtr(), clang::interp::CallVirt(), clang::interp::CheckActive(), clang::interp::CheckArray(), clang::interp::CheckArraySize(), clang::interp::CheckArraySize(), clang::interp::CheckBitCast(), CheckBitcastType(), clang::interp::CheckCallDepth(), clang::interp::CheckConst(), clang::interp::checkConstructor(), clang::interp::CheckDeleteSource(), clang::interp::CheckDestructor(), clang::interp::CheckDivRem(), clang::interp::CheckDummy(), clang::interp::CheckFieldsInitialized(), clang::interp::CheckFloatResult(), CheckGlobal(), clang::interp::CheckGlobalLoad(), clang::interp::CheckLifetime(), clang::interp::CheckLiteralType(), clang::interp::CheckLive(), clang::interp::CheckLoad(), clang::interp::CheckLocalLoad(), clang::interp::CheckMutable(), clang::interp::CheckNewDeleteForms(), clang::interp::CheckNewTypeMismatch(), clang::interp::CheckNull(), clang::interp::CheckNull(), clang::interp::CheckRange(), clang::interp::CheckRange(), clang::interp::EvaluationResult::checkReturnValue(), clang::interp::CheckSubobject(), CheckTemporary(), clang::interp::CheckThis(), clang::interp::CheckVolatile(), clang::interp::CheckWeak(), clang::interp::CMP3(), clang::interp::CmpHelper< Pointer >(), clang::interp::CmpHelperEQ< MemberPointer >(), clang::interp::CmpHelperEQ< Pointer >(), clang::interp::Destroy(), clang::interp::diagnoseCallableDecl(), diagnoseMissingInitializer(), diagnoseNonConstVariable(), clang::interp::DiagnoseUninitialized(), clang::interp::DiagnoseUninitializedSubobject(), diagnoseUnknownDecl(), clang::interp::Divc(), clang::interp::DoBitCastPtr(), FFDiag(), FFDiag(), FFDiag(), clang::interp::Free(), clang::interp::GetDynamicDecl(), clang::interp::getField(), clang::interp::InitElem(), clang::interp::InitElemPop(), clang::interp::interp__builtin_elementwise_countzeroes(), clang::interp::interp__builtin_ia32_vcvtps2ph(), clang::interp::interp__builtin_is_aligned_up_down(), clang::interp::interp__builtin_memchr(), clang::interp::interp__builtin_memcmp(), clang::interp::interp__builtin_memcpy(), clang::interp::interp__builtin_operator_delete(), clang::interp::interp__builtin_operator_new(), clang::interp::InterpretBuiltin(), clang::interp::Invalid(), clang::interp::InvalidCast(), clang::interp::InvalidDeclRef(), clang::interp::InvalidNewDeleteExpr(), clang::interp::InvalidShuffleVectorIndex(), clang::interp::InvalidStore(), clang::interp::NoRet(), clang::interp::InterpState::noteStep(), clang::interp::runRecordDestructor(), clang::interp::SubPtr(), and clang::interp::Unsupported().

◆ getASTContext()

ASTContext & clang::interp::State::getASTContext ( ) const
inline

Definition at line 93 of file State.h.

References Ctx.

Referenced by clang::interp::AllocN(), clang::interp::BitCastPrim(), clang::interp::CallPtr(), clang::interp::CheckArraySize(), clang::interp::CheckBitCast(), CheckBitcastType(), clang::interp::CheckConstant(), clang::interp::CheckDecl(), clang::interp::CheckDeleteSource(), clang::interp::CheckNewDeleteForms(), clang::interp::CheckNewTypeMismatch(), clang::interp::CheckPointerToIntegralCast(), CheckTemporary(), clang::interp::CMP3(), clang::interp::CmpHelper< Pointer >(), clang::interp::CmpHelperEQ< Pointer >(), clang::interp::Destroy(), clang::interp::diagnoseNonConstexprBuiltin(), clang::interp::DiagnoseUninitialized(), clang::interp::DoBitCast(), clang::interp::DoBitCastPtr(), clang::interp::DoBitCastPtr(), clang::interp::Free(), clang::interp::GetDynamicDecl(), clang::interp::getField(), clang::interp::GetPtrBase(), clang::interp::GetPtrBasePop(), clang::interp::handleFixedPointOverflow(), clang::interp::interp__builtin_assume_aligned(), clang::interp::interp__builtin_atomic_lock_free(), clang::interp::interp__builtin_c11_atomic_is_lock_free(), clang::interp::interp__builtin_eh_return_data_regno(), clang::interp::interp__builtin_elementwise_countzeroes(), clang::interp::interp__builtin_ia32_cvt_vec2mask(), clang::interp::interp__builtin_ia32_cvtpd2ps(), clang::interp::interp__builtin_ia32_cvtsd2ss(), clang::interp::interp__builtin_ia32_movmsk_op(), clang::interp::interp__builtin_ia32_phminposuw(), clang::interp::interp__builtin_ia32_pternlog(), clang::interp::interp__builtin_ia32_shift_with_count(), clang::interp::interp__builtin_ia32_shuffle_generic(), clang::interp::interp__builtin_ia32_test_op(), clang::interp::interp__builtin_ia32_vcvtps2ph(), clang::interp::interp__builtin_inf(), clang::interp::interp__builtin_infer_alloc_token(), clang::interp::interp__builtin_is_aligned_up_down(), clang::interp::interp__builtin_memchr(), clang::interp::interp__builtin_memcmp(), clang::interp::interp__builtin_memcpy(), clang::interp::interp__builtin_nan(), clang::interp::interp__builtin_object_size(), clang::interp::interp__builtin_operator_delete(), clang::interp::interp__builtin_operator_new(), clang::interp::interp__builtin_os_log_format_buffer_size(), clang::interp::interp__builtin_overflowop(), clang::interp::interp__builtin_strcmp(), clang::interp::interp__builtin_strlen(), clang::interp::interp__builtin_x86_pack(), clang::interp::interp_builtin_horizontal_fp_binop(), clang::interp::interp_builtin_horizontal_int_binop(), clang::interp::InterpretBuiltin(), clang::interp::InterpretOffsetOf(), clang::interp::InterpState::InterpState(), clang::interp::InterpState::InterpState(), clang::interp::PtrPtrCast(), clang::interp::pushInteger(), and clang::interp::SubPtr().

◆ getBottomFrame()

virtual const Frame * clang::interp::State::getBottomFrame ( ) const
pure virtual

Implemented in clang::interp::InterpState.

◆ getCallStackDepth()

virtual unsigned clang::interp::State::getCallStackDepth ( )
pure virtual

Implemented in clang::interp::InterpState.

◆ getCurrentFrame()

virtual const Frame * clang::interp::State::getCurrentFrame ( )
pure virtual

Implemented in clang::interp::InterpState.

◆ getEvalStatus()

◆ getLangOpts()

const LangOptions & clang::interp::State::getLangOpts ( ) const
inline

Definition at line 94 of file State.h.

References Ctx.

Referenced by clang::interp::Call(), clang::interp::CallVirt(), clang::interp::CheckArraySize(), clang::interp::CheckBitCast(), clang::interp::CheckBitCast(), clang::interp::CheckCallable(), clang::interp::CheckCallDepth(), clang::interp::CheckConstant(), clang::interp::CheckDummy(), clang::interp::CheckDynamicMemoryAllocation(), clang::interp::CheckExtern(), clang::interp::CheckGlobalLoad(), clang::interp::CheckLiteralType(), clang::interp::CheckLocalLoad(), clang::interp::CheckMutable(), clang::interp::CheckPointerToIntegralCast(), clang::interp::CheckPseudoDtor(), clang::interp::CheckRange(), clang::interp::CheckShift(), clang::interp::CheckThis(), clang::interp::CheckVolatile(), clang::interp::diagnoseCallableDecl(), clang::interp::diagnoseNonConstexprBuiltin(), diagnoseNonConstVariable(), clang::interp::DiagnoseUninitialized(), diagnoseUnknownDecl(), clang::interp::DoBitCastPtr(), clang::interp::DoShift(), clang::interp::DoShiftAP(), clang::interp::FnPtrCast(), clang::interp::getField(), clang::interp::GetIntPtr(), clang::interp::IncDecHelper(), clang::interp::InitElem(), clang::interp::InitElemPop(), clang::interp::interp__builtin_classify_type(), clang::interp::interp__builtin_operator_new(), clang::interp::InterpState::InterpState(), clang::interp::InterpState::InterpState(), clang::interp::InvalidCast(), clang::interp::InvalidNewDeleteExpr(), clang::interp::InvalidStore(), clang::interp::InterpState::maybeDiagnoseDanglingAllocations(), clang::interp::OffsetHelper(), clang::interp::PtrPtrCast(), and clang::interp::SubPtr().

◆ keepEvaluatingAfterFailure()

bool State::keepEvaluatingAfterFailure ( ) const

Should we continue evaluation as much as possible after encountering a construct which can't be reduced to a value?

Definition at line 178 of file State.cpp.

References checkingForUndefinedBehavior(), checkingPotentialConstantExpression(), clang::ConstantExpression, clang::ConstantExpressionUnevaluated, clang::ConstantFold, Ctx, EvalMode, clang::IgnoreSideEffects, keepEvaluatingAfterFailure(), and stepsLeft().

Referenced by keepEvaluatingAfterFailure().

◆ keepEvaluatingAfterSideEffect()

bool State::keepEvaluatingAfterSideEffect ( ) const

◆ Note()

◆ noteSideEffect()

bool clang::interp::State::noteSideEffect ( ) const
inline

Note that we have had a side-effect, and determine whether we should keep evaluating.

Definition at line 98 of file State.h.

References EvalStatus, and keepEvaluatingAfterSideEffect().

Referenced by clang::interp::SideEffect().

◆ noteUndefinedBehavior()

bool clang::interp::State::noteUndefinedBehavior ( ) const
inline

Note that we hit something that was technically undefined behavior, but that we can evaluate past it (such as signed overflow or floating-point division by zero.)

Definition at line 113 of file State.h.

References EvalStatus.

Referenced by clang::interp::CastFloatingIntegral(), clang::interp::CheckFloatResult(), clang::interp::CheckNull(), clang::interp::CheckShift(), clang::interp::DoShift(), clang::interp::DoShiftAP(), clang::interp::handleFixedPointOverflow(), and clang::interp::handleOverflow().

◆ report()

DiagnosticBuilder State::report ( SourceLocation Loc,
diag::kind DiagId )

Directly reports a diagnostic message.

Definition at line 74 of file State.cpp.

References Ctx, and report().

Referenced by clang::interp::AddSubMulHelper(), clang::interp::IncDecHelper(), clang::interp::interp__builtin_is_constant_evaluated(), clang::interp::Neg(), and report().

◆ stepsLeft()

virtual bool clang::interp::State::stepsLeft ( ) const
pure virtual

Member Data Documentation

◆ CheckingForUndefinedBehavior

bool clang::interp::State::CheckingForUndefinedBehavior = false

Whether we're checking for an expression that has undefined behavior.

If so, we will produce warnings if we encounter an operation that is always undefined.

Note that we still need to evaluate the expression normally when this is set; this is used when evaluating ICEs in C.

Definition at line 188 of file State.h.

Referenced by checkingForUndefinedBehavior(), clang::interp::InterpState::InterpState(), and clang::interp::InterpState::InterpState().

◆ CheckingPotentialConstantExpression

bool clang::interp::State::CheckingPotentialConstantExpression = false

Whether we're checking that an expression is a potential constant expression.

If so, do not fail on constructs that could become constant later on (such as a use of an undefined global).

Definition at line 180 of file State.h.

Referenced by checkingPotentialConstantExpression(), clang::interp::InterpState::InterpState(), and clang::interp::InterpState::InterpState().

◆ Ctx

ASTContext& clang::interp::State::Ctx

Definition at line 191 of file State.h.

Referenced by getASTContext(), getLangOpts(), keepEvaluatingAfterFailure(), report(), and State().

◆ EvalMode

◆ EvalStatus

Expr::EvalStatus& clang::interp::State::EvalStatus

◆ InConstantContext

bool clang::interp::State::InConstantContext = false

Whether or not we're in a context where the front end requires a constant value.

Definition at line 175 of file State.h.

Referenced by clang::interp::InterpState::inConstantContext(), clang::interp::InterpState::InterpState(), and clang::interp::InterpState::InterpState().


The documentation for this class was generated from the following files: