clang 22.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

virtual ~State ()
virtual bool noteUndefinedBehavior ()=0
virtual bool keepEvaluatingAfterFailure () const =0
virtual bool keepEvaluatingAfterSideEffect () const =0
virtual FramegetCurrentFrame ()=0
virtual const FramegetBottomFrame () const =0
virtual bool hasActiveDiagnostic ()=0
virtual void setActiveDiagnostic (bool Flag)=0
virtual void setFoldFailureDiagnostic (bool Flag)=0
virtual Expr::EvalStatusgetEvalStatus () const =0
virtual ASTContextgetASTContext () const =0
virtual bool hasPriorDiagnostic ()=0
virtual unsigned getCallStackDepth ()=0
virtual bool noteSideEffect ()=0
bool checkingPotentialConstantExpression () const
 Are we checking whether the expression is a potential constant expression?
bool checkingForUndefinedBehavior () const
 Are we checking an expression for overflow?
 State ()=default
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 (const 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 (const 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

Detailed Description

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

Definition at line 79 of file State.h.

Constructor & Destructor Documentation

◆ ~State()

State::~State ( )
virtual

Definition at line 19 of file State.cpp.

References ~State().

Referenced by ~State().

◆ 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(), Diag(), getEvalStatus(), and hasActiveDiagnostic().

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 ( const 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(), Diag(), getEvalStatus(), and setActiveDiagnostic().

Referenced by clang::interp::Assume(), clang::interp::CallVirt(), clang::interp::CastFloatingIntegral(), clang::interp::CastPointerIntegral(), CCEDiag(), CCEDiag(), CCEDiag(), 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::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_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

Are we checking an expression for overflow?

Definition at line 103 of file State.h.

References CheckingForUndefinedBehavior.

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

◆ checkingPotentialConstantExpression()

◆ FFDiag() [1/3]

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

◆ FFDiag() [2/3]

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

◆ 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::CheckCallable(), 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(), diagnoseMissingInitializer(), diagnoseNonConstVariable(), clang::interp::DiagnoseUninitialized(), clang::interp::DiagnoseUninitializedSubobject(), diagnoseUnknownDecl(), clang::interp::Divc(), clang::interp::DoBitCastPtr(), FFDiag(), FFDiag(), FFDiag(), clang::interp::Free(), clang::interp::getField(), clang::interp::InitElem(), clang::interp::InitElemPop(), clang::interp::interp__builtin_elementwise_countzeroes(), 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::NoRet(), clang::interp::runRecordDestructor(), clang::interp::SubPtr(), and clang::interp::Unsupported().

◆ getASTContext()

virtual ASTContext & clang::interp::State::getASTContext ( ) const
pure virtual

Implemented in clang::interp::InterpState.

Referenced by report().

◆ 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 Frame * clang::interp::State::getCurrentFrame ( )
pure virtual

Implemented in clang::interp::InterpState.

◆ getEvalStatus()

virtual Expr::EvalStatus & clang::interp::State::getEvalStatus ( ) const
pure virtual

Implemented in clang::interp::InterpState.

Referenced by addNotes(), CCEDiag(), FFDiag(), and FFDiag().

◆ hasActiveDiagnostic()

virtual bool clang::interp::State::hasActiveDiagnostic ( )
pure virtual

Implemented in clang::interp::InterpState.

Referenced by addNotes(), and Note().

◆ hasPriorDiagnostic()

virtual bool clang::interp::State::hasPriorDiagnostic ( )
pure virtual

Implemented in clang::interp::InterpState.

◆ keepEvaluatingAfterFailure()

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

Implemented in clang::interp::InterpState.

◆ keepEvaluatingAfterSideEffect()

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

Implemented in clang::interp::InterpState.

◆ Note()

◆ noteSideEffect()

virtual bool clang::interp::State::noteSideEffect ( )
pure virtual

Implemented in clang::interp::InterpState.

◆ noteUndefinedBehavior()

virtual bool clang::interp::State::noteUndefinedBehavior ( )
pure virtual

Implemented in clang::interp::InterpState.

◆ report()

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

◆ setActiveDiagnostic()

virtual void clang::interp::State::setActiveDiagnostic ( bool Flag)
pure virtual

Implemented in clang::interp::InterpState.

Referenced by CCEDiag(), FFDiag(), and FFDiag().

◆ setFoldFailureDiagnostic()

virtual void clang::interp::State::setFoldFailureDiagnostic ( bool Flag)
pure virtual

Implemented in clang::interp::InterpState.

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 169 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 161 of file State.h.

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

◆ EvalMode

◆ 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 156 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: