clang  4.0.0svn
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::ento::SVal Class Reference

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

#include <SVals.h>

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

Public Types

enum  BaseKind
 
enum  { BaseBits = 2, BaseMask = 0x3 }
 
typedef SmallVector< SVal, 5 > BufferTy
 BufferTy - A temporary buffer to hold a set of SVals. More...
 

Public Member Functions

 SVal ()
 
template<typename 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 FunctionDeclgetAsFunctionDecl () 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 SymExprgetAsSymbolicExpression () const
 getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression. More...
 
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
 The lowest 2 bits are a BaseKind (0 – 3). More...
 

Detailed Description

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

Definition at line 46 of file SVals.h.

Member Typedef Documentation

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.

Definition at line 48 of file SVals.h.

Constructor & Destructor Documentation

clang::ento::SVal::SVal ( const void *  d,
bool  isLoc,
unsigned  ValKind 
)
inlineexplicitprotected

Definition at line 63 of file SVals.h.

clang::ento::SVal::SVal ( BaseKind  k,
const void *  D = nullptr 
)
inlineexplicitprotected

Definition at line 66 of file SVals.h.

clang::ento::SVal::SVal ( )
inlineexplicit

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::SimpleConstraintManager::assumeWithinInclusiveRange(), clang::ento::ProgramState::assumeWithinInclusiveRange(), clang::ento::ProgramState::bindDefault(), clang::ento::ExprEngine::bindReturnValue(), clang::ento::StoreManager::CastRetrievedVal(), checkElementNonNil(), collectSubRegionBindings(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::createSimpleSValBuilder(), describeUninitializedArgumentInCall(), didPreviousFreeFail(), clang::ento::ExprEngine::evalBind(), clang::ento::SValBuilder::evalBinOp(), clang::ento::ExprEngine::evalBinOp(), evalBinOpFieldRegionFieldRegion(), clang::ento::SValBuilder::evalCast(), clang::ento::ExprEngine::evalComplement(), clang::ento::SValBuilder::evalEQ(), clang::ento::SValBuilder::evalIntegralCast(), clang::ento::ExprEngine::evalLoad(), clang::ento::ExprEngine::evalMinus(), clang::ento::ProgramStateTrait< SymbolSet >::GDMIndex(), getArgumentValueString(), getAsPointeeSymbol(), getFreeWhenDoneArg(), clang::ento::nonloc::LocAsInteger::getLoc(), clang::ento::StoreManager::getLValueElement(), clang::ento::nonloc::LocAsInteger::getPersistentLoc(), getSimplifiedOffsets(), isCPPStdLibraryFunction(), isGreaterEqual(), isInvalidSelf(), isNegative(), isRecordEmpty(), isSelfVar(), IsZeroByteAllocation(), parameterTypeFromSVal(), 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(), suppressReport(), clang::ento::bugreporter::trackNullOrUndefValue(), treatUnusedNewEscaped(), 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().

LLVM_DUMP_METHOD void SVal::dump ( ) const

Definition at line 239 of file SVals.cpp.

References dumpToStream().

Referenced by isValid().

void SVal::dumpToStream ( raw_ostream &  OS) const
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.

References clang::None.

Referenced by adjustReturnValue(), clang::ento::SimpleConstraintManager::assume(), assumeCollectionNonEmpty(), clang::ento::ProgramState::assumeWithinInclusiveRange(), clang::ento::ProgramState::bindLoc(), clang::ento::SimpleConstraintManager::canReasonAbout(), checkCollectionNonNil(), clang::ento::mpi::MPIChecker::checkMissingWaits(), checkValueAtLValForInvariantViolation(), collectSubRegionBindings(), clang::ento::SValBuilder::convertToArrayIndex(), clang::ento::ExprEngine::CreateCXXTemporaryObject(), clang::ento::createSimpleSValBuilder(), describeUninitializedArgumentInCall(), didPreviousFreeFail(), clang::ento::ExprEngine::evalBind(), clang::ento::SValBuilder::evalBinOp(), evalBinOpFieldRegionFieldRegion(), clang::ento::SValBuilder::evalCast(), clang::ento::StoreManager::evalDerivedToBase(), clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(), clang::ento::ExprEngine::evalLoad(), clang::ento::ProgramStateTrait< SymbolSet >::GDMIndex(), GetAllocationSite(), clang::ento::ElementRegion::getAsArrayOffset(), clang::ento::MemRegion::getAsOffset(), getAsPointeeSymbol(), GetCFNumberSize(), clang::CXXInstanceCall::getCXXThisVal(), clang::ento::BugReporterVisitor::getDefaultEndPath(), clang::ento::MemRegion::getDescriptiveName(), getExistingLazyBinding(), getFreeWhenDoneArg(), clang::ento::ExprEngine::getInitialState(), clang::ento::ProgramState::getLValue(), clang::ento::StoreManager::getLValueElement(), clang::ento::StackHintGeneratorForSymbol::getMessage(), getMethodReceiverIfKnownImmutable(), getNullConstraint(), getReceiverNullability(), getSimplifiedOffsets(), clang::ento::ProgramState::getSVal(), getValue(), isARCNilInitializedLocal(), isBooleanType(), isGreaterEqual(), isNegative(), isRecordEmpty(), isSelfVar(), clang::ento::ProgramState::killBinding(), lookThroughImplicitCasts(), 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::ScanReachableSymbols::scan(), suppressReport(), clang::ento::bugreporter::trackNullOrUndefValue(), treatUnusedNewEscaped(), updateOutParameter(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitDeclStmt(), clang::ento::SValExplainer::VisitElementRegion(), clang::ento::ExprEngine::VisitGCCAsmStmt(), clang::ento::FindLastStoreBRVisitor::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(), clang::ento::SimpleFunctionCall::getDecl(), isSynthesizedAccessor(), and isValid().

SymbolRef SVal::getAsLocSymbol ( bool  IncludeBaseRegions = false) const

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.

Parameters
IncludeBaseRegionsThe 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 69 of file SVals.cpp.

References clang::ento::MemRegion::getSymbolicBase(), clang::ento::MemRegion::StripCasts(), and X.

Referenced by didPreviousFreeFail(), evalBinOpFieldRegionFieldRegion(), getAsPointeeSymbol(), getAsSymbol(), getFreeWhenDoneArg(), clang::ento::StackHintGeneratorForSymbol::getMessage(), GetReturnType(), getStopTrackingHardEquivalent(), clang::ento::StoreManager::FindUniqueBinding::HandleBinding(), isValid(), clang::ento::bugreporter::trackNullOrUndefValue(), and updateOutParameter().

const MemRegion * SVal::getAsRegion ( ) const

Definition at line 135 of file SVals.cpp.

References X.

Referenced by addValue(), clang::ento::StoreManager::attemptDownCast(), clang::ento::ProgramState::bindLoc(), clang::ento::mpi::MPIChecker::checkMissingWaits(), collectSubRegionBindings(), describeUninitializedArgumentInCall(), didPreviousFreeFail(), evalBinOpFieldRegionFieldRegion(), clang::ento::SValBuilder::evalCast(), clang::ento::ExprEngine::evalLoad(), getAsPointeeSymbol(), clang::BlockCall::getBlockRegion(), clang::CallEventManager::getCaller(), clang::CXXInstanceCall::getExtraInvalidatedValues(), clang::ObjCMethodCall::getExtraInvalidatedValues(), getFreeWhenDoneArg(), hasDefinition(), clang::ento::CallEvent::invalidateRegions(), isARCNilInitializedLocal(), isBooleanType(), isCPPStdLibraryFunction(), isDebuggingContext(), clang::ento::BugReport::isInteresting(), isNSStringType(), isRecordEmpty(), clang::ento::ProgramState::isTainted(), isTemporaryPRValue(), isValid(), makeZeroElementRegion(), clang::ento::BugReport::markInteresting(), mayInlineCallKind(), clang::ento::ConditionBRVisitor::patternMatch(), clang::ento::ExprEngine::ProcessDeleteDtor(), clang::ento::ExprEngine::ProcessInitializer(), llvm::FoldingSetTrait< AllocKind >::Profile(), recordFixedType(), regionMatchesCXXRecordType(), suppressReport(), clang::ento::bugreporter::trackNullOrUndefValue(), updateOutParameter(), 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
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 clang::ento::createSimpleSValBuilder(), clang::ento::SValBuilder::evalIntegralCast(), getAsSymExpr(), isValid(), clang::ento::ScanReachableSymbols::scan(), and symbol_begin().

const SymExpr * SVal::getAsSymExpr ( ) const
BaseKind clang::ento::SVal::getBaseKind ( ) const
inline

Definition at line 99 of file SVals.h.

References BaseMask.

Referenced by dumpToStream(), and clang::ento::SValVisitor< SValExplainer, std::string >::Visit().

SymbolRef SVal::getLocSymbolInBase ( ) const

Get the symbol in the SVal or its base region.

Definition at line 85 of file SVals.cpp.

References X.

Referenced by didPreviousFreeFail(), and isValid().

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
bool SVal::hasConjuredSymbol ( ) const

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

Definition at line 32 of file SVals.cpp.

Referenced by isValid().

bool SVal::isConstant ( ) const
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::isUnknownOrUndef ( ) const
inline
bool clang::ento::SVal::isValid ( ) const
inline
bool SVal::isZeroConstant ( ) const
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
SymExpr::symbol_iterator clang::ento::SVal::symbol_begin ( ) const
inline
SymExpr::symbol_iterator clang::ento::SVal::symbol_end ( ) const
inline

Member Data Documentation

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


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