clang API Documentation
#include <SVals.h>
Public Types | |
enum | BaseKind { UndefinedKind = 0, UnknownKind = 1, LocKind = 2, NonLocKind = 3 } |
enum | { BaseBits = 2, BaseMask = 0x3 } |
typedef SmallVector< SVal, 5 > | BufferTy |
BufferTy - A temporary buffer to hold a set of SVals. | |
Public Member Functions | |
SVal () | |
template<typename T > | |
T | castAs () const |
Convert to the specified SVal type, asserting that this SVal is of the desired type. | |
template<typename T > | |
Optional< T > | getAs () const |
Convert to the specified SVal type, returning None if this SVal is not of the desired type. | |
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; | |
const FunctionDecl * | getAsFunctionDecl () const |
SymbolRef | getAsLocSymbol (bool IncludeBaseRegions=false) const |
If this SVal is a location and wraps a symbol, return that SymbolRef. Otherwise return 0. | |
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. Otherwise, return 0. | |
const SymExpr * | getAsSymbolicExpression () const |
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 |
unsigned | Kind |
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
typedef SmallVector<SVal,5> clang::ento::SVal::BufferTy |
clang::ento::SVal::SVal | ( | const void * | d, |
bool | isLoc, | ||
unsigned | ValKind | ||
) | [inline, explicit, protected] |
clang::ento::SVal::SVal | ( | BaseKind | k, |
const void * | D = nullptr |
||
) | [inline, explicit, protected] |
clang::ento::SVal::SVal | ( | ) | [inline, explicit] |
T clang::ento::SVal::castAs | ( | ) | const [inline] |
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Definition at line 75 of file SVals.h.
Referenced by addValue(), clang::ento::SimpleConstraintManager::assume(), clang::ento::ProgramState::assume(), clang::ento::SimpleConstraintManager::assumeAux(), clang::ento::ProgramState::assumeInBound(), clang::ento::ProgramState::bindDefault(), clang::ento::ExprEngine::bindReturnValue(), checkElementNonNil(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::ExprEngine::evalBind(), clang::ento::SValBuilder::evalBinOp(), clang::ento::ExprEngine::evalBinOp(), clang::ento::SValBuilder::evalCast(), clang::ento::ExprEngine::evalComplement(), clang::ento::SValBuilder::evalEQ(), clang::ento::ExprEngine::evalMinus(), getArgumentValueString(), clang::ento::nonloc::LocAsInteger::getLoc(), clang::ento::StoreManager::getLValueElement(), clang::ento::nonloc::LocAsInteger::getPersistentLoc(), 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(), clang::ento::FindLastStoreBRVisitor::registerStatementVarDecls(), clang::ento::bugreporter::trackNullOrUndefValue(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), clang::ento::ExprEngine::VisitCXXNewExpr(), clang::ento::ExprEngine::VisitIncrementDecrementOperator(), clang::ento::ExprEngine::VisitLogicalExpr(), clang::ento::ExprEngine::VisitObjCMessage(), and clang::ento::ExprEngine::VisitUnaryOperator().
void SVal::dump | ( | ) | const |
void SVal::dumpToStream | ( | raw_ostream & | OS | ) | const |
Reimplemented in clang::ento::Loc, and clang::ento::NonLoc.
Definition at line 241 of file SVals.cpp.
Referenced by llvm::operator<<().
Optional<T> clang::ento::SVal::getAs | ( | ) | const [inline] |
Convert to the specified SVal type, returning None if this SVal is not of the desired type.
Definition at line 86 of file SVals.h.
Referenced by adjustReturnValue(), clang::ento::SimpleConstraintManager::assume(), assumeCollectionNonEmpty(), clang::ento::ProgramState::bindLoc(), clang::ento::SimpleConstraintManager::canReasonAbout(), checkCollectionNonNil(), collectSubRegionBindings(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::ExprEngine::evalBind(), clang::ento::SValBuilder::evalBinOp(), clang::ento::SValBuilder::evalCast(), clang::ento::StoreManager::evalDerivedToBase(), clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(), clang::ento::ExprEngine::evalLoad(), clang::ento::ElementRegion::getAsArrayOffset(), clang::ento::MemRegion::getAsOffset(), getAsPointeeSymbol(), clang::CXXInstanceCall::getCXXThisVal(), getExistingLazyBinding(), clang::ento::ExprEngine::getInitialState(), clang::ento::ProgramState::getLValue(), clang::ento::StoreManager::getLValueElement(), clang::ento::StackHintGeneratorForSymbol::getMessage(), clang::ento::ProgramState::getSVal(), getValue(), isSelfVar(), clang::ento::ProgramState::killBinding(), clang::ento::SValBuilder::makeSymExprValNN(), parameterTypeFromSVal(), clang::ento::ExprEngine::processIndirectGoto(), clang::ento::ExprEngine::ProcessInitializer(), clang::ento::ExprEngine::processPointerEscapedOnBind(), clang::ento::ExprEngine::processSwitch(), clang::ento::FindLastStoreBRVisitor::registerStatementVarDecls(), clang::ento::EnvironmentManager::removeDeadBindings(), clang::ento::ScanReachableSymbols::scan(), clang::ento::bugreporter::trackNullOrUndefValue(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitDeclStmt(), clang::ento::ExprEngine::VisitGCCAsmStmt(), clang::ento::FindLastStoreBRVisitor::VisitNode(), clang::ento::TrackConstraintBRVisitor::VisitNode(), clang::ento::ExprEngine::VisitObjCForCollectionStmt(), and clang::ento::ExprEngine::VisitUnaryOperator().
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 51 of file SVals.cpp.
References clang::ento::MemRegion::getAs(), and X.
Referenced by clang::ento::CheckerContext::getCalleeDecl(), and clang::ento::SimpleFunctionCall::getDecl().
SymbolRef SVal::getAsLocSymbol | ( | bool | IncludeBaseRegions = false | ) | const |
If this SVal is a location and wraps a symbol, return that SymbolRef. Otherwise return 0.
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. |
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 69 of file SVals.cpp.
References clang::ento::MemRegion::getSymbolicBase(), clang::ento::MemRegion::StripCasts(), and X.
Referenced by getAsSymbol(), clang::ento::StackHintGeneratorForSymbol::getMessage(), clang::ento::StoreManager::FindUniqueBinding::HandleBinding(), and clang::ento::bugreporter::trackNullOrUndefValue().
const MemRegion * SVal::getAsRegion | ( | ) | const |
Definition at line 135 of file SVals.cpp.
References X.
Referenced by clang::ento::ProgramState::addTaint(), clang::ento::ProgramState::bindLoc(), clang::ento::SValBuilder::evalCast(), clang::ento::StoreManager::evalDynamicCast(), clang::ento::ExprEngine::evalLoad(), clang::CallEventManager::getCaller(), getRegionForConstructedObject(), clang::ento::CallEvent::invalidateRegions(), clang::ento::BugReport::isInteresting(), clang::ento::ProgramState::isTainted(), isTemporaryPRValue(), clang::ento::BugReport::markInteresting(), mayInlineCallKind(), clang::ento::ConditionBRVisitor::patternMatch(), clang::ento::ExprEngine::ProcessDeleteDtor(), clang::ento::ExprEngine::ProcessInitializer(), regionMatchesCXXRecordType(), clang::ento::bugreporter::trackNullOrUndefValue(), clang::ento::ExprEngine::VisitBlockExpr(), clang::ento::ConditionBRVisitor::VisitConditionVariable(), clang::ento::ExprEngine::VisitCXXConstructExpr(), clang::ento::ExprEngine::VisitCXXDestructor(), and clang::ento::FindLastStoreBRVisitor::VisitNode().
SymbolRef SVal::getAsSymbol | ( | bool | IncludeBaseRegion = false | ) | const |
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 111 of file SVals.cpp.
References getAsLocSymbol(), and X.
Referenced by addSelfFlag(), clang::ento::ProgramState::addTaint(), clang::ento::SValBuilder::evalCast(), GetAllocationSite(), getAsSymbolicExpression(), getAsSymExpr(), getMethodReceiverIfKnownImmutable(), clang::ento::ProgramState::getSVal(), clang::ento::BugReport::isInteresting(), clang::ento::ProgramState::isNull(), clang::ento::BugReport::markInteresting(), clang::ento::ScanReachableSymbols::scan(), and setFlag().
const SymExpr * SVal::getAsSymbolicExpression | ( | ) | const |
getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression. Otherwise return NULL.
Definition at line 121 of file SVals.cpp.
References getAsSymbol(), and X.
Referenced by getAsSymExpr(), clang::ento::ScanReachableSymbols::scan(), and symbol_begin().
const SymExpr * SVal::getAsSymExpr | ( | ) | const |
Definition at line 128 of file SVals.cpp.
References getAsSymbol(), and getAsSymbolicExpression().
Referenced by clang::ento::SimpleConstraintManager::assumeAux(), clang::ento::ProgramState::isTainted(), and clang::ento::SValBuilder::makeSymExprValNN().
BaseKind clang::ento::SVal::getBaseKind | ( | ) | const [inline] |
SymbolRef SVal::getLocSymbolInBase | ( | ) | const |
unsigned clang::ento::SVal::getRawKind | ( | ) | const [inline] |
Definition at line 98 of file SVals.h.
References Kind.
Referenced by isUndef(), isUnknown(), isUnknownOrUndef(), isValid(), operator==(), and Profile().
unsigned clang::ento::SVal::getSubKind | ( | ) | const [inline] |
Definition at line 100 of file SVals.h.
References BaseBits, and BaseMask.
Referenced by clang::ento::SimpleConstraintManager::assumeAux().
bool SVal::hasConjuredSymbol | ( | ) | const |
bool SVal::isConstant | ( | ) | const |
Definition at line 174 of file SVals.cpp.
Referenced by clang::ento::SValBuilder::evalCast(), and clang::ento::ProgramState::isNull().
bool SVal::isConstant | ( | int | I | ) | const |
bool clang::ento::SVal::isUndef | ( | ) | const [inline] |
Definition at line 121 of file SVals.h.
References getRawKind(), and UndefinedKind.
Referenced by clang::ento::SValBuilder::evalBinOp(), clang::ento::ExprEngine::evalStore(), getArgumentValueString(), clang::ento::ExprEngine::processSwitch(), clang::ento::FindLastStoreBRVisitor::VisitNode(), clang::ento::UndefOrNullArgVisitor::VisitNode(), and clang::ento::ExprEngine::VisitObjCMessage().
bool clang::ento::SVal::isUnknown | ( | ) | const [inline] |
Definition at line 117 of file SVals.h.
References getRawKind(), and UnknownKind.
Referenced by addParameterValuesToBindings(), clang::ento::ProgramState::assume(), clang::ento::ProgramState::assumeInBound(), clang::ento::EnvironmentManager::bindExpr(), clang::ento::SValBuilder::evalBinOp(), clang::CXXInstanceCall::getInitialStackFrameContents(), clang::CXXConstructorCall::getInitialStackFrameContents(), clang::ento::ExprEngine::processBranch(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitCast(), clang::ento::ExprEngine::VisitDeclStmt(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().
bool clang::ento::SVal::isUnknownOrUndef | ( | ) | const [inline] |
Definition at line 125 of file SVals.h.
References getRawKind(), and UnknownKind.
Referenced by addValue(), clang::ento::ProgramState::assumeInBound(), clang::ento::StoreManager::CastRetrievedVal(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::SValBuilder::evalCast(), clang::CXXInstanceCall::getCXXThisVal(), clang::ento::StoreManager::getLValueElement(), clang::ento::ExprEngine::processBranch(), clang::ento::ExprEngine::ProcessInitializer(), and clang::ento::ExprEngine::VisitUnaryOperator().
bool clang::ento::SVal::isValid | ( | ) | const [inline] |
Definition at line 129 of file SVals.h.
References getRawKind(), and UnknownKind.
Referenced by clang::ento::ExprEngine::evalBinOp(), clang::ento::ExprEngine::evalComplement(), clang::ento::ExprEngine::evalMinus(), and clang::ObjCMethodCall::getReceiverSVal().
bool SVal::isZeroConstant | ( | ) | const |
Definition at line 186 of file SVals.cpp.
Referenced by clang::ento::SValBuilder::evalCast(), clang::ento::FieldRegion::getExtent(), isCallbackArg(), clang::ento::ProgramState::isNull(), clang::ento::MemRegion::StripCasts(), clang::ento::ExprEngine::VisitCast(), and clang::ento::UndefOrNullArgVisitor::VisitNode().
Definition at line 109 of file SVals.h.
References Data, and getRawKind().
void clang::ento::SVal::Profile | ( | llvm::FoldingSetNodeID & | ID | ) | const [inline] |
Definition at line 104 of file SVals.h.
References Data, and getRawKind().
Referenced by clang::ento::BasicValueFactory::getPersistentSValPair(), and clang::ento::BasicValueFactory::getPersistentSValWithData().
SymExpr::symbol_iterator clang::ento::SVal::symbol_begin | ( | ) | const [inline] |
Definition at line 177 of file SVals.h.
References getAsSymbolicExpression(), and clang::ento::SymExpr::symbol_begin().
Referenced by clang::ento::EnvironmentManager::removeDeadBindings().
SymExpr::symbol_iterator clang::ento::SVal::symbol_end | ( | ) | const [inline] |
Definition at line 185 of file SVals.h.
Referenced by clang::ento::EnvironmentManager::removeDeadBindings().
const void* clang::ento::SVal::Data [protected] |
Definition at line 57 of file SVals.h.
Referenced by clang::ento::nonloc::LazyCompoundVal::getCVData(), clang::ento::loc::GotoLabel::getLabel(), clang::ento::nonloc::LocAsInteger::getLoc(), clang::ento::nonloc::LocAsInteger::getNumBits(), clang::ento::nonloc::LocAsInteger::getPersistentLoc(), clang::ento::loc::MemRegionVal::getRegion(), clang::ento::nonloc::SymbolVal::getSymbol(), clang::ento::nonloc::ConcreteInt::getValue(), clang::ento::nonloc::CompoundVal::getValue(), clang::ento::loc::ConcreteInt::getValue(), operator==(), and Profile().
unsigned clang::ento::SVal::Kind [protected] |
The lowest 2 bits are a BaseKind (0 -- 3). The higher bits are an unsigned "kind" value.
Definition at line 61 of file SVals.h.
Referenced by getRawKind().