clang 20.0.0git
|
SVal - This represents a symbolic expression, which can be either an L-value or an R-value. More...
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
Public Types | |
enum | SValKind : unsigned char |
Public Member Functions | |
SVal ()=default | |
template<typename T > | |
T | castAs () const |
Convert to the specified SVal type, asserting that this SVal is of the desired type. | |
template<typename T > | |
std::optional< T > | getAs () const |
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type. | |
SValKind | getKind () const |
StringRef | getKindStr () const |
void | Profile (llvm::FoldingSetNodeID &ID) const |
bool | operator== (SVal R) const |
bool | operator!= (SVal R) const |
bool | isUnknown () const |
bool | isUndef () const |
bool | isUnknownOrUndef () const |
bool | isValid () const |
bool | isConstant () const |
bool | isConstant (int I) const |
bool | isZeroConstant () const |
const FunctionDecl * | getAsFunctionDecl () const |
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl, return that FunctionDecl. | |
SymbolRef | getAsLocSymbol (bool IncludeBaseRegions=false) const |
If this SVal is a location and wraps a symbol, return that SymbolRef. | |
SymbolRef | getLocSymbolInBase () const |
Get the symbol in the SVal or its base region. | |
SymbolRef | getAsSymbol (bool IncludeBaseRegions=false) const |
If this SVal wraps a symbol return that SymbolRef. | |
const llvm::APSInt * | getAsInteger () const |
If this SVal is loc::ConcreteInt or nonloc::ConcreteInt, return a pointer to APSInt which is held in it. | |
const MemRegion * | getAsRegion () const |
void | printJson (raw_ostream &Out, bool AddQuotes) const |
printJson - Pretty-prints in JSON format. | |
void | dumpToStream (raw_ostream &OS) const |
void | dump () const |
llvm::iterator_range< SymExpr::symbol_iterator > | symbols () const |
QualType | getType (const ASTContext &) const |
Try to get a reasonable type for the given value. | |
Protected Member Functions | |
SVal (SValKind Kind, const void *Data=nullptr) | |
template<typename T > | |
const T * | castDataAs () const |
Protected Attributes | |
const void * | Data = nullptr |
SValKind | Kind = UndefinedValKind |
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
enum clang::ento::SVal::SValKind : unsigned char |
|
inlineexplicitprotected |
|
explicitdefault |
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition at line 83 of file SVals.h.
Referenced by addInstanceOfTransition(), clang::ento::ProgramState::assume(), clang::ento::ProgramState::assumeInBoundDual(), clang::ento::ProgramState::assumeInclusiveRange(), clang::ento::SimpleConstraintManager::assumeInternal(), clang::ento::ProgramState::bindDefaultInitial(), clang::ento::ProgramState::bindDefaultZero(), clang::ento::ExprEngine::bindReturnValue(), clang::ento::CoreEngine::dispatchWorkItem(), doRearrangeUnchecked(), clang::ento::SValBuilder::evalBinOp(), evalComparison(), clang::ento::SValBuilder::evalEQ(), clang::ento::SValBuilder::evalIntegralCast(), clang::ento::ExprEngine::evalLoad(), getArgumentValueString(), clang::ento::SValBuilder::getConjuredHeapSymbolVal(), getIndex(), clang::ento::nonloc::LocAsInteger::getLoc(), clang::ento::StoreManager::getLValueElement(), isArrayIndexOutOfBounds(), isSelfVar(), IsZeroByteAllocation(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), clang::ento::ExprEngine::processCallExit(), clang::ento::ExprEngine::processSwitch(), reAssume(), clang::ento::errno_modeling::setErrnoForStdFailure(), clang::ento::ExprEngine::VisitCXXNewAllocatorCall(), clang::ento::ExprEngine::VisitIncrementDecrementOperator(), and clang::ento::ExprEngine::VisitObjCMessage().
void SVal::dumpToStream | ( | raw_ostream & | OS | ) | const |
Definition at line 294 of file SVals.cpp.
References clang::ento::NonLoc::classof(), and clang::ento::Loc::classof().
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
Definition at line 87 of file SVals.h.
Referenced by clang::ento::iterator::advancePosition(), assumeCollectionNonEmpty(), clang::ento::SimpleConstraintManager::assumeInternal(), clang::ento::iterator::assumeNoOverflow(), clang::ento::ProgramState::bindLoc(), checkCollectionNonNil(), checkValueAtLValForInvariantViolation(), collectSubRegionBindings(), compareValueToThreshold(), computeOffset(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::CoreEngine::dispatchWorkItem(), clang::ento::SValBuilder::evalBinOp(), clang::ento::retaincountchecker::RetainCountChecker::evalCall(), clang::ento::SValBuilder::evalIntegralCast(), clang::ento::SValBuilder::evalUnaryOp(), clang::ento::ElementRegion::getAsArrayOffset(), getAsPointeeSymbol(), getConcreteValue(), clang::ento::MemRegion::getDescriptiveName(), getFuchsiaHandleSymbols(), clang::ento::ExprEngine::getInitialState(), clang::ento::iterator::getIteratorPosition(), clang::ento::ProgramState::getLValue(), clang::ento::StoreManager::getLValueElement(), clang::ento::StackHintGeneratorForSymbol::getMessage(), getReceiverNullability(), getSimplifiedOffsets(), hasVisibleUpdate(), clang::ento::SValBuilder::makeSymExprValNN(), parameterTypeFromSVal(), populateObjCForDestinationSet(), clang::ento::ExprEngine::processSwitch(), REGISTER_MAP_WITH_PROGRAMSTATE(), clang::ento::ScanReachableSymbols::scan(), clang::ento::iterator::setIteratorPosition(), showBRDefaultDiagnostics(), showBRDiagnostics(), showBRParamDiagnostics(), updateOutParameters(), clang::ento::ExprEngine::VisitCXXNewExpr(), and clang::ento::SValExplainer::VisitElementRegion().
const FunctionDecl * SVal::getAsFunctionDecl | ( | ) | const |
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl, return that FunctionDecl.
Otherwise return 0.
Definition at line 46 of file SVals.cpp.
References clang::ento::MemRegion::getAs(), and X.
Referenced by clang::ento::CheckerContext::getCalleeDecl(), clang::ento::SimpleFunctionCall::getDecl(), and clang::ento::CXXInstanceCall::getDecl().
const llvm::APSInt * SVal::getAsInteger | ( | ) | const |
If this SVal is loc::ConcreteInt or nonloc::ConcreteInt, return a pointer to APSInt which is held in it.
Otherwise, return nullptr.
Definition at line 112 of file SVals.cpp.
Referenced by clang::ento::ExprEngine::ProcessAutomaticObjDtor(), clang::ento::ExprEngine::ProcessDeleteDtor(), and clang::ento::ExprEngine::ProcessMemberDtor().
If this SVal is a location and wraps a symbol, return that SymbolRef.
If this SVal is a location (subclasses Loc) and wraps a symbol, return that SymbolRef.
Otherwise return 0.
Casts are ignored during lookup.
IncludeBaseRegions | The boolean that controls whether the search should continue to the base regions if the region is not symbolic. |
Otherwise return 0.
Implicit casts (ex: void* -> char*) can turn Symbolic region into Element region. If that is the case, gets the underlining region. When IncludeBaseRegions is set to true and the SubRegion is non-symbolic, the first symbolic parent region is returned.
Definition at line 68 of file SVals.cpp.
References getAsRegion(), and clang::ento::MemRegion::getSymbolicBase().
Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkPostCall(), getAsSymbol(), clang::ento::StackHintGeneratorForSymbol::getMessage(), clang::ento::StoreManager::FindUniqueBinding::HandleBinding(), and updateOutParameters().
const MemRegion * SVal::getAsRegion | ( | ) | const |
Definition at line 120 of file SVals.cpp.
References X.
Referenced by addCastTransition(), addInstanceOfTransition(), clang::ento::ProgramState::bindLoc(), clang::ento::ExprEngine::bindReturnValue(), clang::ento::retaincountchecker::RetainCountChecker::checkBind(), clang::ento::mpi::MPIChecker::checkDoubleNonblocking(), clang::ento::ExprEngine::computeObjectUnderConstruction(), computeOffset(), clang::ento::StoreManager::evalDerivedToBase(), getAsLocSymbol(), clang::ento::BlockCall::getBlockRegion(), clang::ento::CallEventManager::getCaller(), getConstructedRegion(), clang::ento::CXXInstanceCall::getDeclForDynamicType(), getExceedsMsgs(), clang::ento::CXXInstanceCall::getExtraInvalidatedValues(), clang::ento::ObjCMethodCall::getExtraInvalidatedValues(), clang::ento::iterator::getIteratorPosition(), clang::ento::getPointeeVal(), clang::ento::ObjCMethodCall::getRuntimeDefinition(), clang::ento::tagged_union_modeling::handleConstructorAndAssignment(), clang::ento::ConditionBRVisitor::patternMatch(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::ProcessDeleteDtor(), clang::ento::ExprEngine::ProcessInitializer(), REGISTER_MAP_WITH_PROGRAMSTATE(), clang::ento::iterator::setIteratorPosition(), updateOutParameters(), clang::ento::ExprEngine::VisitCXXNewExpr(), clang::ento::ExprEngine::VisitMemberExpr(), and wasRegionOfInterestModifiedAt().
If this SVal wraps a symbol return that SymbolRef.
Otherwise, return 0.
Casts are ignored during lookup.
IncludeBaseRegions | The boolean that controls whether the search should continue to the base regions if the region is not symbolic. |
Definition at line 104 of file SVals.cpp.
References getAsLocSymbol(), and X.
Referenced by addSelfFlag(), clang::ento::retaincountchecker::RetainCountChecker::checkPostStmt(), clang::ento::retaincountchecker::RetainCountChecker::checkSummary(), clang::ento::SValBuilder::evalIntegralCast(), GetAllocationSite(), getFuchsiaHandleSymbols(), clang::ento::iterator::getIteratorPosition(), hasFlag(), clang::ento::SValBuilder::makeSymExprValNN(), clang::ento::retaincountchecker::RetainCountChecker::processSummaryOfInlined(), REGISTER_MAP_WITH_PROGRAMSTATE(), clang::ento::ScanReachableSymbols::scan(), setFlag(), clang::ento::iterator::setIteratorPosition(), clang::ento::simplify(), symbols(), and tryRearrange().
|
inline |
Definition at line 91 of file SVals.h.
References Kind.
Referenced by assertEqualBitWidths(), clang::ento::CoreEngine::dispatchWorkItem(), isUndef(), isUnknown(), and Profile().
StringRef SVal::getKindStr | ( | ) | const |
SymbolRef SVal::getLocSymbolInBase | ( | ) | const |
QualType SVal::getType | ( | const ASTContext & | Context | ) | const |
Try to get a reasonable type for the given value.
Definition at line 181 of file SVals.cpp.
Referenced by clang::ento::iterator::advancePosition(), assertEqualBitWidths(), checkParamsForPreconditionViolation(), checkSelfIvarsForInvariantViolation(), clang::ento::CXXInstanceCall::getCXXThisVal(), and clang::ento::ExprEngine::processCallExit().
bool SVal::isConstant | ( | ) | const |
|
inline |
Definition at line 107 of file SVals.h.
References getKind().
Referenced by clang::ento::SValBuilder::evalBinOp(), clang::ento::ExprEngine::evalLoad(), clang::ento::ExprEngine::evalStore(), getArgumentValueString(), isUnknownOrUndef(), clang::ento::ExprEngine::processSwitch(), showBRDefaultDiagnostics(), showBRDiagnostics(), showBRParamDiagnostics(), clang::ento::ExprEngine::VisitLogicalExpr(), clang::ento::UndefOrNullArgVisitor::VisitNode(), clang::ento::ExprEngine::VisitObjCMessage(), and wasRegionOfInterestModifiedAt().
|
inline |
Definition at line 105 of file SVals.h.
References getKind().
Referenced by addParameterValuesToBindings(), clang::ento::ProgramState::assume(), assumeCondition(), clang::ento::ProgramState::assumeInBoundDual(), clang::ento::ProgramState::assumeInclusiveRange(), conjureOffsetSymbolOnLocation(), clang::ento::SValBuilder::evalBinOp(), clang::ento::retaincountchecker::RetainCountChecker::evalCall(), clang::ento::CXXInstanceCall::getInitialStackFrameContents(), clang::ento::AnyCXXConstructorCall::getInitialStackFrameContents(), clang::ento::ObjCMethodCall::getInitialStackFrameContents(), clang::ento::ExprEngine::handleLValueBitCast(), isUnknownOrUndef(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitCast(), clang::ento::ExprEngine::VisitCXXNewExpr(), and clang::ento::ExprEngine::VisitDeclStmt().
|
inline |
Definition at line 109 of file SVals.h.
References isUndef(), and isUnknown().
Referenced by clang::ento::ProgramState::assumeInBoundDual(), clang::ento::SValBuilder::convertToArrayIndex(), evalComparison(), clang::ento::CXXInstanceCall::getCXXThisVal(), isValid(), clang::ento::ExprEngine::ProcessInitializer(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().
|
inline |
Definition at line 111 of file SVals.h.
References isUnknownOrUndef().
Referenced by clang::ento::ExprEngine::evalLoad(), and clang::ento::ObjCMethodCall::getReceiverSVal().
bool SVal::isZeroConstant | ( | ) | const |
Definition at line 258 of file SVals.cpp.
Referenced by clang::ento::ExprEngine::VisitCast(), and clang::ento::UndefOrNullArgVisitor::VisitNode().
void SVal::printJson | ( | raw_ostream & | Out, |
bool | AddQuotes | ||
) | const |
printJson - Pretty-prints in JSON format.
Definition at line 285 of file SVals.cpp.
References clang::JsonFormat().
|
inline |
|
inline |
Definition at line 156 of file SVals.h.
References getAsSymbol().
Referenced by clang::ento::SymbolReaper::markElementIndicesLive().
|
protected |
Definition at line 68 of file SVals.h.
Referenced by castDataAs(), clang::ento::nonloc::PointerToMember::getPTMData(), clang::ento::nonloc::SymbolVal::getSymbol(), operator==(), and Profile().
|
protected |
Definition at line 69 of file SVals.h.
Referenced by getKind(), and operator==().