clang  mainline
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
clang::ento::SVal Class Reference

#include <SVals.h>

Inheritance diagram for clang::ento::SVal:
Inheritance graph
[legend]
Collaboration diagram for clang::ento::SVal:
Collaboration graph
[legend]

List of all members.

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 >
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 FunctionDeclgetAsFunctionDecl () 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 SymExprgetAsSymbolicExpression () const
const SymExprgetAsSymExpr () const
const MemRegiongetAsRegion () 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

Detailed Description

SVal - This represents a symbolic expression, which can be either an L-value or an R-value.

Definition at line 44 of file SVals.h.


Member Typedef Documentation

typedef SmallVector<SVal,5> clang::ento::SVal::BufferTy

BufferTy - A temporary buffer to hold a set of SVals.

Definition at line 96 of file SVals.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
BaseBits 
BaseMask 

Definition at line 54 of file SVals.h.

Enumerator:
UndefinedKind 
UnknownKind 
LocKind 
NonLocKind 

Definition at line 46 of file SVals.h.


Constructor & Destructor Documentation

clang::ento::SVal::SVal ( const void *  d,
bool  isLoc,
unsigned  ValKind 
) [inline, explicit, protected]

Definition at line 63 of file SVals.h.

clang::ento::SVal::SVal ( BaseKind  k,
const void *  D = nullptr 
) [inline, explicit, protected]

Definition at line 66 of file SVals.h.

clang::ento::SVal::SVal ( ) [inline, explicit]

Definition at line 70 of file SVals.h.


Member Function Documentation

template<typename T >
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

Definition at line 239 of file SVals.cpp.

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<<().

template<typename T >
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().

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.

Parameters:
IncludeBaseRegionsThe 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
SymbolRef SVal::getAsSymbol ( bool  IncludeBaseRegion = false) const

If this SVal wraps a symbol return that SymbolRef. Otherwise, return 0.

Casts are ignored during lookup.

Parameters:
IncludeBaseRegionsThe 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().

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 99 of file SVals.h.

References BaseMask.

Get the symbol in the SVal or its base region.

Definition at line 85 of file SVals.cpp.

References X.

Definition at line 98 of file SVals.h.

References Kind.

Referenced by isUndef(), isUnknown(), isUnknownOrUndef(), isValid(), operator==(), and Profile().

Definition at line 100 of file SVals.h.

References BaseBits, and BaseMask.

Referenced by clang::ento::SimpleConstraintManager::assumeAux().

hasConjuredSymbol - If this SVal wraps a conjured symbol, return true;

Definition at line 32 of file SVals.cpp.

bool SVal::isConstant ( int  I) const

Definition at line 178 of file SVals.cpp.

bool clang::ento::SVal::isUndef ( ) const [inline]
bool clang::ento::SVal::isUnknown ( ) const [inline]
bool clang::ento::SVal::isValid ( ) const [inline]
bool clang::ento::SVal::operator!= ( const SVal R) const [inline]

Definition at line 113 of file SVals.h.

bool clang::ento::SVal::operator== ( const SVal R) const [inline]

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 185 of file SVals.h.

Referenced by clang::ento::EnvironmentManager::removeDeadBindings().


Member Data Documentation

const void* clang::ento::SVal::Data [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().


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