clang  7.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 "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"

Inheritance diagram for clang::ento::SVal:
Inheritance graph
Collaboration diagram for clang::ento::SVal:
Collaboration graph

Public Types

enum  BaseKind
enum  { BaseBits = 2, BaseMask = 0x3 }

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. More...
template<typename T >
Optional< TgetAs () 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 63 of file SVals.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 71 of file SVals.h.

◆ BaseKind

Definition at line 65 of file SVals.h.

Constructor & Destructor Documentation

◆ SVal() [1/3]

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

Definition at line 80 of file SVals.h.

◆ SVal() [2/3]

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

Definition at line 83 of file SVals.h.

◆ SVal() [3/3]

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

Definition at line 87 of file SVals.h.

Member Function Documentation

◆ castAs()

template<typename T >
T clang::ento::SVal::castAs ( ) const

◆ dump()

LLVM_DUMP_METHOD void SVal::dump ( ) const

Definition at line 272 of file SVals.cpp.

References dumpToStream().

◆ dumpToStream()

void SVal::dumpToStream ( raw_ostream &  OS) const

Definition at line 274 of file SVals.cpp.

References getBaseKind().

Referenced by dump(), getArgumentValueString(), and clang::ento::operator<<().

◆ getAs()

template<typename T >
Optional<T> clang::ento::SVal::getAs ( ) const

Convert to the specified SVal type, returning None if this SVal is not of the desired type.

Definition at line 100 of file SVals.h.

References clang::T.

Referenced by clang::ento::ProgramState::addTaint(), adjustReturnValue(), clang::ento::SimpleConstraintManager::assume(), assumeCollectionNonEmpty(), clang::ento::ProgramState::assumeInclusiveRange(), clang::ento::ProgramState::bindLoc(), checkCollectionNonNil(), clang::ento::mpi::MPIChecker::checkMissingWaits(), checkValueAtLValForInvariantViolation(), 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::evalLoad(), clang::ento::ElementRegion::getAsArrayOffset(), clang::ento::MemRegion::getAsOffset(), getAsPointeeSymbol(), GetCFNumberSize(), clang::CXXInstanceCall::getCXXThisVal(), clang::ento::MemRegion::getDescriptiveName(), getExistingLazyBinding(), clang::ento::ExprEngine::getInitialState(), clang::ento::ProgramState::getLValue(), clang::ento::StoreManager::getLValueElement(), getNullConstraint(), getReceiverNullability(), getSimplifiedOffsets(), clang::ento::ProgramState::getSVal(), getValue(), 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::VisitCXXNewExpr(), clang::ento::ExprEngine::VisitGCCAsmStmt(), and clang::ento::FindLastStoreBRVisitor::VisitNode().

◆ getAsFunctionDecl()

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 52 of file SVals.cpp.

References clang::ento::MemRegion::getAs(), and X.

Referenced by clang::ento::CheckerContext::getCalleeDecl(), clang::ento::SimpleFunctionCall::getDecl(), and isSynthesizedAccessor().

◆ getAsLocSymbol()

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.

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

◆ getAsRegion()

const MemRegion * SVal::getAsRegion ( ) const

◆ getAsSymbol()

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

◆ getAsSymbolicExpression()

const SymExpr * SVal::getAsSymbolicExpression ( ) const

getAsSymbolicExpression - If this Sval wraps a symbolic expression then return that expression.

Otherwise return NULL.

Definition at line 126 of file SVals.cpp.

References getAsSymbol(), and X.

Referenced by clang::ento::SValBuilder::evalIntegralCast(), getAsSymExpr(), and clang::ento::ScanReachableSymbols::scan().

◆ getAsSymExpr()

const SymExpr * SVal::getAsSymExpr ( ) const

◆ getBaseKind()

BaseKind clang::ento::SVal::getBaseKind ( ) const

◆ getLocSymbolInBase()

SymbolRef SVal::getLocSymbolInBase ( ) const

Get the symbol in the SVal or its base region.

Definition at line 90 of file SVals.cpp.

References X.

◆ getRawKind()

unsigned clang::ento::SVal::getRawKind ( ) const

Definition at line 106 of file SVals.h.

Referenced by operator==().

◆ getSubKind()

unsigned clang::ento::SVal::getSubKind ( ) const

◆ hasConjuredSymbol()

bool SVal::hasConjuredSymbol ( ) const

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

Definition at line 33 of file SVals.cpp.

◆ isConstant() [1/2]

bool SVal::isConstant ( ) const

◆ isConstant() [2/2]

bool SVal::isConstant ( int  I) const

Definition at line 211 of file SVals.cpp.

◆ isUndef()

bool clang::ento::SVal::isUndef ( ) const

◆ isUnknown()

bool clang::ento::SVal::isUnknown ( ) const

◆ isUnknownOrUndef()

bool clang::ento::SVal::isUnknownOrUndef ( ) const

◆ isValid()

bool clang::ento::SVal::isValid ( ) const

◆ isZeroConstant()

bool SVal::isZeroConstant ( ) const

◆ operator!=()

bool clang::ento::SVal::operator!= ( const SVal R) const

Definition at line 121 of file SVals.h.

◆ operator==()

bool clang::ento::SVal::operator== ( const SVal R) const

Definition at line 117 of file SVals.h.

References Data, and getRawKind().

◆ Profile()

void clang::ento::SVal::Profile ( llvm::FoldingSetNodeID &  ID) const

◆ symbol_begin()

SymExpr::symbol_iterator clang::ento::SVal::symbol_begin ( ) const

Definition at line 185 of file SVals.h.

References clang::ento::SymExpr::symbol_begin().

◆ symbol_end()

SymExpr::symbol_iterator clang::ento::SVal::symbol_end ( ) const

Definition at line 193 of file SVals.h.

References clang::ento::SymExpr::symbol_end().

Member Data Documentation

◆ Data

const void* clang::ento::SVal::Data

◆ Kind

unsigned clang::ento::SVal::Kind

The lowest 2 bits are a BaseKind (0 – 3).

The higher bits are an unsigned "kind" value.

Definition at line 78 of file SVals.h.

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