clang
7.0.0
|
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 | BaseKind |
enum | { BaseBits = 2, BaseMask = 0x3 } |
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. More... | |
template<typename T > | |
Optional< T > | getAs () const |
Convert to the specified SVal type, returning None if this SVal is not of the desired type. More... | |
unsigned | getRawKind () const |
BaseKind | getBaseKind () const |
unsigned | getSubKind () const |
void | Profile (llvm::FoldingSetNodeID &ID) const |
bool | operator== (const SVal &R) const |
bool | operator!= (const 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 |
bool | hasConjuredSymbol () const |
hasConjuredSymbol - If this SVal wraps a conjured symbol, return true; More... | |
const FunctionDecl * | getAsFunctionDecl () const |
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl, return that FunctionDecl. More... | |
SymbolRef | getAsLocSymbol (bool IncludeBaseRegions=false) const |
If this SVal is a location and wraps a symbol, return that SymbolRef. More... | |
SymbolRef | getLocSymbolInBase () const |
Get the symbol in the SVal or its base region. More... | |
SymbolRef | getAsSymbol (bool IncludeBaseRegions=false) const |
If this SVal wraps a symbol return that SymbolRef. More... | |
const SymExpr * | getAsSymbolicExpression () const |
getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression. More... | |
const SymExpr * | getAsSymExpr () const |
const MemRegion * | getAsRegion () const |
void | dumpToStream (raw_ostream &OS) const |
void | dump () const |
SymExpr::symbol_iterator | symbol_begin () const |
SymExpr::symbol_iterator | symbol_end () const |
Protected Member Functions | |
SVal (const void *d, bool isLoc, unsigned ValKind) | |
SVal (BaseKind k, const void *D=nullptr) | |
Protected Attributes | |
const void * | Data = nullptr |
unsigned | Kind = 0 |
The lowest 2 bits are a BaseKind (0 – 3). More... | |
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
|
inlineexplicitprotected |
|
inlineexplicitprotected |
|
explicitdefault |
|
inline |
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition at line 104 of file SVals.h.
Referenced by addValue(), clang::ento::SimpleConstraintManager::assume(), clang::ento::ProgramState::assume(), clang::ento::ProgramState::assumeInBound(), clang::ento::SimpleConstraintManager::assumeInclusiveRange(), clang::ento::ProgramState::assumeInclusiveRange(), clang::ento::ProgramState::bindDefaultInitial(), clang::ento::ProgramState::bindDefaultZero(), clang::ento::StoreManager::CastRetrievedVal(), checkElementNonNil(), clang::ento::createSimpleSValBuilder(), doRearrangeUnchecked(), clang::ento::ExprEngine::evalBind(), clang::ento::SValBuilder::evalBinOp(), clang::ento::ExprEngine::evalBinOp(), clang::ento::SValBuilder::evalCast(), evalComparison(), clang::ento::ExprEngine::evalComplement(), clang::ento::SValBuilder::evalEQ(), clang::ento::SValBuilder::evalIntegralCast(), clang::ento::ExprEngine::evalMinus(), getArgumentValueString(), clang::ento::nonloc::LocAsInteger::getLoc(), clang::ento::StoreManager::getLValueElement(), getObjectVal(), clang::ento::nonloc::LocAsInteger::getPersistentLoc(), getSimplifiedOffsets(), isArrayIndexOutOfBounds(), isRecordEmpty(), isSelfVar(), IsZeroByteAllocation(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::processBranch(), clang::ento::ExprEngine::processCallExit(), clang::ento::ExprEngine::ProcessMemberDtor(), clang::ento::ExprEngine::processSwitch(), tryRearrange(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), and clang::ento::ExprEngine::VisitObjCMessage().
LLVM_DUMP_METHOD void SVal::dump | ( | ) | const |
Definition at line 281 of file SVals.cpp.
References dumpToStream().
void SVal::dumpToStream | ( | raw_ostream & | OS | ) | const |
Definition at line 283 of file SVals.cpp.
References getBaseKind().
Referenced by dump(), getArgumentValueString(), and clang::ento::operator<<().
|
inline |
Convert to the specified SVal type, returning None if this SVal is not of the desired type.
Definition at line 112 of file SVals.h.
Referenced by clang::ento::ProgramState::addTaint(), adjustReturnValue(), clang::ento::SimpleConstraintManager::assume(), assumeCollectionNonEmpty(), clang::ento::ProgramState::assumeInclusiveRange(), assumeNoOverflow(), clang::ento::ProgramState::bindLoc(), checkCollectionNonNil(), clang::ento::mpi::MPIChecker::checkMissingWaits(), checkValueAtLValForInvariantViolation(), collectSubRegionBindings(), conjureOffsetSymbolOnLocation(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::ExprEngine::CreateCXXTemporaryObject(), clang::ento::CreateRangeConstraintManager(), clang::ento::createSimpleSValBuilder(), describeUninitializedArgumentInCall(), clang::ento::ExprEngine::evalBind(), clang::ento::SValBuilder::evalBinOp(), clang::ento::SValBuilder::evalCast(), evalComparison(), clang::ento::StoreManager::evalDerivedToBase(), clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(), clang::ento::ExprEngine::evalLoad(), clang::ento::ElementRegion::getAsArrayOffset(), getAsPointeeSymbol(), GetCFNumberSize(), clang::CXXInstanceCall::getCXXThisVal(), clang::ento::MemRegion::getDescriptiveName(), getExistingLazyBinding(), clang::ento::ExprEngine::getInitialState(), clang::ento::ProgramState::getLValue(), clang::ento::StoreManager::getLValueElement(), getNonNullAttrs(), getNullConstraint(), getObjectVal(), getReceiverNullability(), getSimplifiedOffsets(), clang::ento::ProgramState::getSVal(), getValue(), isInRelation(), isRecordEmpty(), isSelfVar(), clang::ento::ProgramState::killBinding(), clang::ento::SValBuilder::makeSymExprValNN(), parameterTypeFromSVal(), clang::ento::ExprEngine::processIndirectGoto(), clang::ento::ExprEngine::ProcessInitializer(), clang::ento::ExprEngine::processPointerEscapedOnBind(), clang::ento::ScanReachableSymbols::scan(), showBRDefaultDiagnostics(), showBRDiagnostics(), showBRParamDiagnostics(), clang::ento::ExprEngine::VisitCXXConstructExpr(), clang::ento::ExprEngine::VisitCXXNewExpr(), and clang::ento::ExprEngine::VisitGCCAsmStmt().
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 63 of file SVals.cpp.
References clang::ento::MemRegion::getAs(), and X.
Referenced by clang::ento::CheckerContext::getCalleeDecl(), clang::ento::SimpleFunctionCall::getDecl(), and isSynthesizedAccessor().
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 85 of file SVals.cpp.
References clang::ento::MemRegion::getSymbolicBase(), clang::ento::MemRegion::StripCasts(), and X.
Referenced by getAsPointeeSymbol(), getAsSymbol(), GetReturnType(), clang::ento::StoreManager::FindUniqueBinding::HandleBinding(), isGeneralizedObjectRef(), and updateOutParameter().
const MemRegion * SVal::getAsRegion | ( | ) | const |
Definition at line 151 of file SVals.cpp.
References X.
Referenced by clang::ento::ProgramState::addTaint(), addValue(), assumeNoOverflow(), clang::ento::StoreManager::attemptDownCast(), clang::ento::ProgramState::bindLoc(), clang::ento::StoreManager::CastRetrievedVal(), clang::ento::mpi::MPIChecker::checkMissingWaits(), describeUninitializedArgumentInCall(), clang::ento::SValBuilder::evalCast(), getAsPointeeSymbol(), clang::BlockCall::getBlockRegion(), clang::CallEventManager::getCaller(), clang::CXXInstanceCall::getExtraInvalidatedValues(), clang::ObjCMethodCall::getExtraInvalidatedValues(), hasDefinition(), clang::ento::CallEvent::invalidateRegions(), isDebuggingContext(), clang::ento::BugReport::isInteresting(), isNSStringType(), isRecordEmpty(), clang::ento::ProgramState::isTainted(), clang::ento::BugReport::markInteresting(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), clang::ento::ExprEngine::ProcessDeleteDtor(), clang::ento::ExprEngine::ProcessInitializer(), clang::ento::ExprEngine::ProcessTemporaryDtor(), recordFixedType(), regionMatchesCXXRecordType(), updateOutParameter(), clang::ento::ExprEngine::VisitBlockExpr(), clang::ento::ExprEngine::VisitCXXConstructExpr(), and clang::ento::ExprEngine::VisitCXXNewExpr().
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 127 of file SVals.cpp.
References getAsLocSymbol(), and X.
Referenced by addSelfFlag(), clang::ento::ProgramState::addTaint(), clang::ento::SimpleConstraintManager::assumeInclusiveRange(), clang::ento::SValBuilder::evalCast(), GetAllocationSite(), getArgumentValueString(), getAsPointeeSymbol(), getAsSymbolicExpression(), getAsSymExpr(), getExistingLazyBinding(), clang::CXXConstructorCall::getExtraInvalidatedValues(), getMethodReceiverIfKnownImmutable(), GetReturnType(), getReturnTypeForMethod(), clang::ento::ProgramState::getSVal(), hasFlag(), clang::ento::BugReport::isInteresting(), clang::ento::ProgramState::isNull(), clang::ento::BugReport::markInteresting(), clang::ento::ScanReachableSymbols::scan(), setFlag(), tryRearrange(), and updateOutParameter().
const SymExpr * SVal::getAsSymbolicExpression | ( | ) | const |
getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression.
Otherwise return NULL.
Definition at line 137 of file SVals.cpp.
References getAsSymbol(), and X.
Referenced by clang::ento::SValBuilder::evalIntegralCast(), getAsSymExpr(), and clang::ento::ScanReachableSymbols::scan().
const SymExpr * SVal::getAsSymExpr | ( | ) | const |
Definition at line 144 of file SVals.cpp.
References getAsSymbol(), and getAsSymbolicExpression().
Referenced by clang::ento::SimpleConstraintManager::assume(), clang::ento::SimpleConstraintManager::assumeInclusiveRange(), getAsPointeeSymbol(), clang::ento::ProgramState::isTainted(), and clang::ento::SValBuilder::makeSymExprValNN().
|
inline |
Definition at line 119 of file SVals.h.
Referenced by dumpToStream(), and clang::ento::SValVisitor< SValExplainer, std::string >::Visit().
SymbolRef SVal::getLocSymbolInBase | ( | ) | const |
|
inline |
Definition at line 118 of file SVals.h.
Referenced by operator==().
|
inline |
Definition at line 120 of file SVals.h.
Referenced by clang::ento::SimpleConstraintManager::assume(), clang::ento::SimpleConstraintManager::assumeInclusiveRange(), clang::ento::StoreManager::CastRetrievedVal(), clang::ento::NonLoc::dumpToStream(), clang::ento::Loc::dumpToStream(), tryRearrange(), and clang::ento::SValVisitor< SValExplainer, std::string >::Visit().
bool SVal::hasConjuredSymbol | ( | ) | const |
bool SVal::isConstant | ( | ) | const |
Definition at line 218 of file SVals.cpp.
Referenced by clang::ento::SValBuilder::evalCast(), clang::ento::ProgramState::isNull(), and isZeroConstant().
|
inline |
Definition at line 141 of file SVals.h.
Referenced by describeUninitializedArgumentInCall(), clang::ento::SValBuilder::evalBinOp(), clang::ento::ExprEngine::evalLoad(), clang::ento::ExprEngine::evalStore(), getArgumentValueString(), getAsPointeeSymbol(), isLeftShiftResultUnrepresentable(), clang::ento::ExprEngine::processSwitch(), showBRDefaultDiagnostics(), showBRDiagnostics(), showBRParamDiagnostics(), clang::ento::ExprEngine::VisitObjCMessage(), and wasRegionOfInterestModifiedAt().
|
inline |
Definition at line 137 of file SVals.h.
Referenced by clang::ento::ProgramState::assume(), clang::ento::ProgramState::assumeInBound(), clang::ento::ProgramState::assumeInclusiveRange(), clang::ento::EnvironmentManager::bindExpr(), conjureOffsetSymbolOnLocation(), clang::ento::SValBuilder::evalBinOp(), clang::CXXInstanceCall::getInitialStackFrameContents(), clang::CXXConstructorCall::getInitialStackFrameContents(), clang::ento::ExprEngine::handleLValueBitCast(), isRecordEmpty(), clang::ento::ExprEngine::processBranch(), clang::ento::ExprEngine::VisitBinaryOperator(), and clang::ento::ExprEngine::VisitCXXNewExpr().
|
inline |
Definition at line 145 of file SVals.h.
Referenced by addValue(), clang::ento::ProgramState::assumeInBound(), clang::ento::StoreManager::CastRetrievedVal(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::ExprEngine::CreateCXXTemporaryObject(), clang::ento::SValBuilder::evalCast(), evalComparison(), clang::CXXInstanceCall::getCXXThisVal(), getExistingLazyBinding(), clang::ento::StoreManager::getLValueElement(), clang::ento::ExprEngine::processBranch(), and clang::ento::ExprEngine::ProcessInitializer().
|
inline |
Definition at line 149 of file SVals.h.
Referenced by clang::ento::ExprEngine::evalBinOp(), clang::ento::ExprEngine::evalComplement(), clang::ento::ExprEngine::evalMinus(), clang::ObjCMethodCall::getReceiverSVal(), and isArrayIndexOutOfBounds().
bool SVal::isZeroConstant | ( | ) | const |
Definition at line 230 of file SVals.cpp.
References isConstant().
Referenced by clang::ento::SValBuilder::evalCast(), clang::ento::FieldRegion::getExtent(), and clang::ento::ProgramState::isNull().
Definition at line 129 of file SVals.h.
References Data, and getRawKind().
|
inline |
Definition at line 124 of file SVals.h.
Referenced by clang::ento::BasicValueFactory::getPersistentSValPair(), clang::ento::BasicValueFactory::getPersistentSValWithData(), and clang::ento::SymbolicRegion::Profile().
|
inline |
Definition at line 197 of file SVals.h.
References clang::ento::SymExpr::symbol_begin().
|
inline |
Definition at line 205 of file SVals.h.
References clang::ento::SymExpr::symbol_end().
|
protected |
Definition at line 87 of file SVals.h.
Referenced by clang::ento::nonloc::LazyCompoundVal::getRegion(), clang::ento::nonloc::LazyCompoundVal::getStore(), and operator==().
|
protected |