clang
6.0.0
|
#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
Protected Member Functions | |
virtual SVal | evalCastFromNonLoc (NonLoc val, QualType castTy)=0 |
virtual SVal | evalCastFromLoc (Loc val, QualType castTy)=0 |
Protected Attributes | |
ASTContext & | Context |
BasicValueFactory | BasicVals |
Manager of APSInt values. More... | |
SymbolManager | SymMgr |
Manages the creation of symbols. More... | |
MemRegionManager | MemMgr |
Manages the creation of memory regions. More... | |
ProgramStateManager & | StateMgr |
const QualType | ArrayIndexTy |
The scalar type to use for array indices. More... | |
const unsigned | ArrayIndexWidth |
The width of the scalar type used for array indices. More... | |
Definition at line 32 of file SValBuilder.h.
|
inline |
Definition at line 63 of file SValBuilder.h.
|
inlinevirtual |
Definition at line 72 of file SValBuilder.h.
|
inline |
Definition at line 155 of file SValBuilder.h.
References clang::ento::SymbolManager::conjureSymbol().
|
inline |
Definition at line 163 of file SValBuilder.h.
References clang::ento::SymbolManager::conjureSymbol(), conjureSymbolVal(), clang::ast_matchers::expr, getConjuredHeapSymbolVal(), getRegionValueSymbolVal(), makeZeroVal(), and clang::ast_matchers::stmt.
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal | ( | const void * | symbolTag, |
const Expr * | expr, | ||
const LocationContext * | LCtx, | ||
unsigned | count | ||
) |
Create a new symbol with a unique 'name'.
We resort to conjured symbols when we cannot construct a derived symbol. The advantage of symbols derived/built from other symbols is that we preserve the relation between related(or even equivalent) expressions, so conjured symbols should be used sparingly.
Definition at line 115 of file SValBuilder.cpp.
References clang::LocationContext::getAnalysisDeclContext(), clang::AnalysisDeclContext::getASTContext(), clang::ASTContext::getPointerType(), clang::Expr::getType(), clang::Expr::isGLValue(), clang::Type::isNullPtrType(), makeZeroVal(), and clang::T.
Referenced by conjureOffsetSymbolOnLocation(), conjureSymbol(), clang::ento::ExprEngine::handleLVectorSplat(), clang::ento::ExprEngine::ProcessInitializer(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitCXXCatchStmt(), clang::ento::ExprEngine::VisitCXXNewExpr(), and clang::ento::ExprEngine::VisitGuardedExpr().
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal | ( | const void * | symbolTag, |
const Expr * | expr, | ||
const LocationContext * | LCtx, | ||
QualType | type, | ||
unsigned | count | ||
) |
Definition at line 133 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::conjureSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::Loc::isLocType(), clang::Type::isNullPtrType(), makeZeroVal(), MemMgr, and SymMgr.
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal | ( | const Stmt * | stmt, |
const LocationContext * | LCtx, | ||
QualType | type, | ||
unsigned | visitCount | ||
) |
Definition at line 153 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::conjureSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::Loc::isLocType(), clang::Type::isNullPtrType(), makeZeroVal(), MemMgr, and SymMgr.
Definition at line 79 of file SValBuilder.cpp.
References clang::ento::SVal::getAs(), and clang::ento::SVal::isUnknownOrUndef().
Referenced by clang::ento::StoreManager::getLValueElement(), and makeArrayIndex().
Referenced by clang::ento::StoreManager::CastRetrievedVal(), and evalCast().
SVal SValBuilder::evalBinOp | ( | ProgramStateRef | state, |
BinaryOperator::Opcode | op, | ||
SVal | lhs, | ||
SVal | rhs, | ||
QualType | type | ||
) |
Definition at line 382 of file SValBuilder.cpp.
References clang::ento::SVal::castAs(), evalBinOpLL(), evalBinOpLN(), evalBinOpNN(), clang::ento::SVal::getAs(), clang::ento::SVal::isUndef(), and clang::ento::SVal::isUnknown().
Referenced by assumeCollectionNonEmpty(), clang::ento::ExprEngine::evalBinOp(), evalComparison(), evalEQ(), and haveSameType().
|
pure virtual |
Create a new value which represents a binary expression with two memory location operands.
Referenced by evalBinOp(), and haveSameType().
|
pure virtual |
Create a new value which represents a binary expression with a memory location and non-location operands.
For example, this would be used to evaluate a pointer arithmetic operation.
Referenced by evalBinOp(), and haveSameType().
|
pure virtual |
Create a new value which represents a binary expression with two non- location operands.
Referenced by addValue(), clang::ento::ProgramState::assumeInBound(), evalBinOp(), clang::ento::ExprEngine::evalBinOp(), evalIntegralCast(), getSimplifiedOffsets(), haveSameType(), and scaleValue().
Definition at line 492 of file SValBuilder.cpp.
References clang::ento::ProgramStateManager::ArrayToPointer(), clang::ento::SVal::castAs(), clang::ento::StoreManager::castRegion(), Context, dispatchCast(), evalCastFromLoc(), clang::ento::SVal::getAs(), clang::ento::SVal::getAsRegion(), clang::ento::SVal::getAsSymbol(), getBasicValueFactory(), clang::QualType::getCanonicalType(), clang::ASTContext::getCanonicalType(), clang::ASTContext::getPointerType(), clang::ento::ProgramStateManager::getStoreManager(), clang::Type::isBlockPointerType(), clang::Type::isBooleanType(), clang::ento::SVal::isConstant(), clang::Type::isFunctionPointerType(), clang::Type::isFunctionType(), clang::Type::isIntegralOrEnumerationType(), clang::ento::Loc::isLocType(), clang::Type::isMemberPointerType(), clang::Type::isPointerType(), clang::Type::isReferenceType(), clang::ento::SVal::isUnknownOrUndef(), clang::Type::isVariableArrayType(), clang::ento::SVal::isZeroConstant(), makeNonLoc(), makeTruthVal(), shouldBeModeledWithNoOp(), and StateMgr.
Referenced by clang::ento::SimpleConstraintManager::assume(), evalIntegralCast(), clang::ento::ExprEngine::handleLValueBitCast(), haveSameType(), clang::ento::ExprEngine::VisitCXXNewExpr(), and clang::ento::ExprEngine::VisitLogicalExpr().
|
protectedpure virtual |
Referenced by evalCast().
|
protectedpure virtual |
Referenced by clang::ento::ExprEngine::evalComplement(), and haveSameType().
DefinedOrUnknownSVal SValBuilder::evalEQ | ( | ProgramStateRef | state, |
DefinedOrUnknownSVal | lhs, | ||
DefinedOrUnknownSVal | rhs | ||
) |
Definition at line 416 of file SValBuilder.cpp.
References clang::ento::SVal::castAs(), evalBinOp(), and getConditionType().
Referenced by GetCFNumberSize(), and haveSameType().
SVal SValBuilder::evalIntegralCast | ( | ProgramStateRef | state, |
SVal | val, | ||
QualType | castTy, | ||
QualType | originalType | ||
) |
Definition at line 455 of file SValBuilder.cpp.
References clang::ento::SVal::castAs(), evalBinOpNN(), evalCast(), clang::ento::SVal::getAsSymbolicExpression(), getConditionType(), getContext(), clang::ento::APSIntType::getMaxValue(), clang::Type::isUnsignedIntegerType(), makeIntVal(), and makeNonLoc().
Referenced by haveSameType().
Referenced by clang::ento::ExprEngine::evalMinus(), and haveSameType().
|
inline |
Definition at line 140 of file SValBuilder.h.
References ArrayIndexTy.
Referenced by addValue(), clang::ento::TypedValueRegion::getExtent(), clang::ento::StringRegion::getExtent(), and scaleValue().
|
inline |
Definition at line 144 of file SValBuilder.h.
References BasicVals.
Referenced by clang::ento::ProgramState::assumeInBound(), clang::ento::nonloc::ConcreteInt::evalBinOp(), evalCast(), clang::ento::SimpleConstraintManager::getBasicVals(), and clang::ento::StoreManager::getLValueElement().
|
inline |
Definition at line 145 of file SValBuilder.h.
References BasicVals.
DefinedSVal SValBuilder::getBlockPointer | ( | const BlockDecl * | block, |
CanQualType | locTy, | ||
const LocationContext * | locContext, | ||
unsigned | blockCount | ||
) |
Definition at line 240 of file SValBuilder.cpp.
References clang::LocationContext::getAnalysisDeclContext(), clang::ento::MemRegionManager::getBlockCodeRegion(), clang::ento::MemRegionManager::getBlockDataRegion(), and MemMgr.
Referenced by clang::ento::ExprEngine::VisitBlockExpr().
|
inline |
Definition at line 136 of file SValBuilder.h.
References clang::ASTContext::BoolTy, clang::ASTContext::getLangOpts(), and clang::ASTContext::IntTy.
Referenced by assumeCollectionNonEmpty(), evalComparison(), evalEQ(), evalIntegralCast(), clang::ento::ExprEngine::getInitialState(), and getSimplifiedOffsets().
DefinedOrUnknownSVal SValBuilder::getConjuredHeapSymbolVal | ( | const Expr * | E, |
const LocationContext * | LCtx, | ||
unsigned | Count | ||
) |
Conjure a symbol representing heap allocated memory region.
Note, the expression should represent a location.
Definition at line 172 of file SValBuilder.cpp.
Referenced by conjureSymbol(), and clang::ento::ExprEngine::VisitCXXNewExpr().
Returns the value of E
, if it can be determined in a non-path-sensitive manner.
If E
is not a constant or cannot be modeled, returns None
.
Definition at line 266 of file SValBuilder.cpp.
|
inline |
Definition at line 131 of file SValBuilder.h.
References Context.
Referenced by addValue(), clang::ento::SimpleConstraintManager::assume(), clang::ento::ProgramState::assumeInBound(), clang::ento::StoreManager::CastRetrievedVal(), evalIntegralCast(), getCXXThis(), getExistingLazyBinding(), clang::ento::TypedValueRegion::getExtent(), clang::ento::FieldRegion::getExtent(), clang::CXXInstanceCall::getInitialStackFrameContents(), clang::ento::StoreManager::MakeElementRegion(), and makeZeroElementRegion().
|
inline |
Definition at line 132 of file SValBuilder.h.
References Context.
loc::MemRegionVal SValBuilder::getCXXThis | ( | const CXXMethodDecl * | D, |
const StackFrameContext * | SFC | ||
) |
Return a memory region for the 'this' object reference.
Definition at line 252 of file SValBuilder.cpp.
References getContext(), getRegionManager(), and clang::CXXMethodDecl::getThisType().
Referenced by clang::CallEventManager::getCaller(), clang::BlockCall::getInitialStackFrameContents(), clang::CXXInstanceCall::getInitialStackFrameContents(), clang::CXXConstructorCall::getInitialStackFrameContents(), clang::ento::ExprEngine::getInitialState(), makeLoc(), makeZeroElementRegion(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::processCallExit(), clang::ento::ExprEngine::ProcessInitializer(), clang::ento::ExprEngine::ProcessMemberDtor(), and clang::ento::ExprEngine::VisitCXXConstructExpr().
loc::MemRegionVal SValBuilder::getCXXThis | ( | const CXXRecordDecl * | D, |
const StackFrameContext * | SFC | ||
) |
Return a memory region for the 'this' object reference.
Definition at line 259 of file SValBuilder.cpp.
References getContext(), clang::ASTContext::getPointerType(), getRegionManager(), clang::TypeDecl::getTypeForDecl(), and clang::T.
DefinedOrUnknownSVal SValBuilder::getDerivedRegionValueSymbolVal | ( | SymbolRef | parentSymbol, |
const TypedValueRegion * | region | ||
) |
Definition at line 202 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::getDerivedSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::TypedValueRegion::getValueType(), clang::ento::Loc::isLocType(), clang::Type::isNullPtrType(), makeZeroVal(), MemMgr, SymMgr, and clang::T.
DefinedSVal SValBuilder::getFunctionPointer | ( | const FunctionDecl * | func | ) |
Definition at line 236 of file SValBuilder.cpp.
References clang::ento::MemRegionManager::getFunctionCodeRegion(), and MemMgr.
Referenced by getMemberPointer().
|
pure virtual |
Evaluates a given SVal.
If the SVal has only one possible (integer) value, that value is returned. Otherwise, returns NULL.
Referenced by haveSameType().
DefinedSVal SValBuilder::getMemberPointer | ( | const DeclaratorDecl * | DD | ) |
Definition at line 220 of file SValBuilder.cpp.
References getFunctionPointer(), and clang::prec::PointerToMember.
DefinedSVal SValBuilder::getMetadataSymbolVal | ( | const void * | symbolTag, |
const MemRegion * | region, | ||
const Expr * | expr, | ||
QualType | type, | ||
const LocationContext * | LCtx, | ||
unsigned | count | ||
) |
Definition at line 185 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::getMetadataSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::Loc::isLocType(), MemMgr, and SymMgr.
|
inline |
Definition at line 150 of file SValBuilder.h.
References MemMgr.
Referenced by addParameterValuesToBindings(), getCXXThis(), makeZeroElementRegion(), clang::ento::ExprEngine::VisitCXXConstructExpr(), clang::ento::ExprEngine::VisitCXXThisExpr(), and clang::ento::ExprEngine::VisitLambdaExpr().
|
inline |
Definition at line 151 of file SValBuilder.h.
References MemMgr.
DefinedOrUnknownSVal SValBuilder::getRegionValueSymbolVal | ( | const TypedValueRegion * | region | ) |
Make a unique symbol for value of region.
Definition at line 98 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::getRegionValueSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::TypedValueRegion::getValueType(), clang::ento::Loc::isLocType(), clang::Type::isNullPtrType(), makeZeroVal(), MemMgr, SymMgr, and clang::T.
Referenced by conjureSymbol().
|
inline |
Definition at line 134 of file SValBuilder.h.
References StateMgr.
|
inline |
Definition at line 147 of file SValBuilder.h.
References SymMgr.
Referenced by clang::ento::AllocaRegion::getExtent(), clang::ento::TypedValueRegion::getExtent(), clang::ento::SymbolicRegion::getExtent(), clang::ento::SimpleConstraintManager::getSymbolManager(), and clang::ento::CheckerContext::getSymbolManager().
|
inline |
Definition at line 148 of file SValBuilder.h.
References SymMgr.
Definition at line 74 of file SValBuilder.h.
References clang::ento::SymExpr::getType().
Definition at line 78 of file SValBuilder.h.
References evalBinOp(), evalBinOpLL(), evalBinOpLN(), evalBinOpNN(), evalCast(), evalComplement(), evalEQ(), evalIntegralCast(), evalMinus(), clang::ASTContext::getCanonicalType(), getKnownValue(), clang::Type::isIntegralOrEnumerationType(), makeSymExprValNN(), simplifySVal(), clang::CodeGen::state, and State.
|
inline |
Definition at line 248 of file SValBuilder.h.
References convertToArrayIndex().
Referenced by clang::ento::mpi::MPIChecker::checkMissingWaits(), getValue(), clang::ento::StoreManager::MakeElementRegion(), and scaleValue().
|
inline |
Definition at line 260 of file SValBuilder.h.
References clang::ObjCBoolLiteralExpr::getValue(), and makeTruthVal().
nonloc::ConcreteInt SValBuilder::makeBoolVal | ( | const CXXBoolLiteralExpr * | boolean | ) |
Definition at line 93 of file SValBuilder.cpp.
References clang::CXXBoolLiteralExpr::getValue(), and makeTruthVal().
|
inline |
Definition at line 226 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getCompoundValData().
Referenced by makeZeroVal(), and clang::ento::ExprEngine::VisitInitListExpr().
|
inline |
Definition at line 270 of file SValBuilder.h.
|
inline |
Definition at line 254 of file SValBuilder.h.
References clang::Expr::getType(), clang::APIntStorage::getValue(), and clang::Type::isUnsignedIntegerOrEnumerationType().
Referenced by assumeCollectionNonEmpty(), clang::ento::nonloc::ConcreteInt::evalComplement(), evalIntegralCast(), clang::ento::nonloc::ConcreteInt::evalMinus(), clang::ento::TypedValueRegion::getExtent(), clang::ento::StringRegion::getExtent(), getSimplifiedOffsets(), makeZeroVal(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ExprEngine::VisitOffsetOfExpr().
|
inline |
Definition at line 266 of file SValBuilder.h.
Definition at line 274 of file SValBuilder.h.
|
inline |
Definition at line 278 of file SValBuilder.h.
References clang::ento::Loc::isLocType().
Definition at line 285 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getIntValue().
|
inline |
Definition at line 289 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getIntWithPtrWidth().
|
inline |
Definition at line 230 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getLazyCompoundValData().
Definition at line 329 of file SValBuilder.h.
References clang::ento::MemRegionManager::getSymbolicRegion().
Referenced by clang::ento::StoreManager::getLValueVar().
Definition at line 333 of file SValBuilder.h.
|
inline |
Definition at line 337 of file SValBuilder.h.
References clang::AddrLabelExpr::getLabel().
|
inline |
Definition at line 341 of file SValBuilder.h.
References clang::ento::createSimpleSValBuilder(), and getCXXThis().
Definition at line 294 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getPersistentSValWithData(), and makeNonLoc().
NonLoc SValBuilder::makeNonLoc | ( | const SymExpr * | lhs, |
BinaryOperator::Opcode | op, | ||
const llvm::APSInt & | rhs, | ||
QualType | type | ||
) |
Definition at line 47 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getSymIntExpr(), clang::ento::Loc::isLocType(), and SymMgr.
Referenced by evalCast(), evalIntegralCast(), makeLocAsInteger(), and makeSymExprValNN().
NonLoc SValBuilder::makeNonLoc | ( | const llvm::APSInt & | rhs, |
BinaryOperator::Opcode | op, | ||
const SymExpr * | lhs, | ||
QualType | type | ||
) |
Definition at line 57 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getIntSymExpr(), clang::ento::Loc::isLocType(), and SymMgr.
NonLoc SValBuilder::makeNonLoc | ( | const SymExpr * | lhs, |
BinaryOperator::Opcode | op, | ||
const SymExpr * | rhs, | ||
QualType | type | ||
) |
Definition at line 65 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getSymSymExpr(), clang::ento::Loc::isLocType(), and SymMgr.
Create a NonLoc value for cast.
Definition at line 72 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getCastSymbol(), clang::ento::Loc::isLocType(), and SymMgr.
|
inline |
Definition at line 325 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getZeroWithPtrWidth().
Referenced by makeZeroVal().
Create NULL pointer, with proper pointer bit-width for given address space.
type | pointer type. |
Definition at line 321 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getZeroWithTypeSize().
|
inline |
Definition at line 236 of file SValBuilder.h.
References clang::prec::PointerToMember.
|
inline |
Definition at line 240 of file SValBuilder.h.
References clang::prec::PointerToMember.
SVal SValBuilder::makeSymExprValNN | ( | ProgramStateRef | state, |
BinaryOperator::Opcode | op, | ||
NonLoc | lhs, | ||
NonLoc | rhs, | ||
QualType | resultTy | ||
) |
Constructs a symbolic expression for two non-location values.
Definition at line 353 of file SValBuilder.cpp.
References clang::ento::SymExpr::computeComplexity(), clang::ento::SVal::getAs(), clang::ento::SVal::getAsSymExpr(), and makeNonLoc().
Referenced by haveSameType().
|
inline |
Definition at line 310 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getTruthValue().
Referenced by evalCast(), and makeBoolVal().
|
inline |
Definition at line 314 of file SValBuilder.h.
References clang::ento::BasicValueFactory::getTruthValue().
|
inline |
Definition at line 244 of file SValBuilder.h.
Referenced by computeExtentBegin(), clang::ento::StoreManager::GetElementZeroRegion(), and makeZeroElementRegion().
DefinedOrUnknownSVal SValBuilder::makeZeroVal | ( | QualType | type | ) |
Construct an SVal representing '0' for the specified type.
Definition at line 32 of file SValBuilder.cpp.
References BasicVals, clang::ento::BasicValueFactory::getEmptySValList(), clang::Type::isAnyComplexType(), clang::Type::isArrayType(), clang::Type::isIntegralOrEnumerationType(), clang::ento::Loc::isLocType(), clang::Type::isRecordType(), clang::Type::isVectorType(), makeCompoundVal(), makeIntVal(), and makeNull().
Referenced by conjureSymbol(), conjureSymbolVal(), GetCFNumberSize(), getDerivedRegionValueSymbolVal(), clang::ento::ExprEngine::getInitialState(), getRegionValueSymbolVal(), supportsNilWithFloatRet(), clang::ento::ExprEngine::VisitCXXConstructExpr(), and clang::ento::ExprEngine::VisitInitListExpr().
|
pure virtual |
Simplify symbolic expressions within a given SVal.
Return an SVal that represents the same value, but is hopefully easier to work with than the original SVal.
Referenced by haveSameType().
|
protected |
The scalar type to use for array indices.
Definition at line 49 of file SValBuilder.h.
Referenced by getArrayIndexType().
|
protected |
The width of the scalar type used for array indices.
Definition at line 52 of file SValBuilder.h.
|
protected |
Manager of APSInt values.
Definition at line 38 of file SValBuilder.h.
Referenced by getBasicValueFactory(), and makeZeroVal().
|
protected |
Definition at line 35 of file SValBuilder.h.
Referenced by evalCast(), and getContext().
|
protected |
Manages the creation of memory regions.
Definition at line 44 of file SValBuilder.h.
Referenced by conjureSymbolVal(), getBlockPointer(), getDerivedRegionValueSymbolVal(), getFunctionPointer(), getMetadataSymbolVal(), getRegionManager(), and getRegionValueSymbolVal().
|
protected |
Definition at line 46 of file SValBuilder.h.
Referenced by evalCast(), and getStateManager().
|
protected |
Manages the creation of symbols.
Definition at line 41 of file SValBuilder.h.
Referenced by conjureSymbolVal(), getDerivedRegionValueSymbolVal(), getMetadataSymbolVal(), getRegionValueSymbolVal(), getSymbolManager(), and makeNonLoc().