clang
3.7.0
|
#include <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 31 of file SValBuilder.h.
|
inline |
Definition at line 62 of file SValBuilder.h.
|
inlinevirtual |
Definition at line 71 of file SValBuilder.h.
|
inline |
Definition at line 145 of file SValBuilder.h.
References clang::ento::SymbolManager::conjureSymbol(), and SymMgr.
|
inline |
Definition at line 153 of file SValBuilder.h.
References clang::ento::SymbolManager::conjureSymbol(), and SymMgr.
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 109 of file SValBuilder.cpp.
References clang::LocationContext::getAnalysisDeclContext(), clang::AnalysisDeclContext::getASTContext(), clang::ASTContext::getPointerType(), clang::Expr::getType(), and clang::Expr::isGLValue().
Referenced by clang::ento::ExprEngine::bindReturnValue(), clang::ento::ExprEngine::ProcessInitializer(), clang::ento::ExprEngine::Visit(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitCast(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), clang::ento::ExprEngine::VisitCXXCatchStmt(), clang::ento::ExprEngine::VisitCXXNewExpr(), clang::ento::ExprEngine::VisitDeclStmt(), clang::ento::ExprEngine::VisitGuardedExpr(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal | ( | const void * | symbolTag, |
const Expr * | expr, | ||
const LocationContext * | LCtx, | ||
QualType | type, | ||
unsigned | count | ||
) |
Definition at line 124 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::conjureSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::Loc::isLocType(), MemMgr, and SymMgr.
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal | ( | const Stmt * | stmt, |
const LocationContext * | LCtx, | ||
QualType | type, | ||
unsigned | visitCount | ||
) |
Definition at line 141 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::conjureSymbol(), clang::ento::MemRegionManager::getSymbolicRegion(), clang::ento::Loc::isLocType(), MemMgr, and SymMgr.
Definition at line 76 of file SValBuilder.cpp.
References ArrayIndexTy, ArrayIndexWidth, clang::ento::SVal::castAs(), evalCastFromNonLoc(), clang::ento::SVal::getAs(), and clang::ento::SVal::isUnknownOrUndef().
Referenced by clang::ento::StoreManager::getLValueElement().
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 333 of file SValBuilder.cpp.
References clang::BO_Add, 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(), and evalEQ().
|
pure virtual |
Create a new value which represents a binary expression with two memory location operands.
Referenced by evalBinOp().
|
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().
|
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(), and scaleValue().
Definition at line 399 of file SValBuilder.cpp.
References clang::ento::ProgramStateManager::ArrayToPointer(), clang::BO_NE, 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(), getConstantVal(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::ento::ExprEngine::VisitCast(), clang::ento::ExprEngine::VisitCXXNewExpr(), and clang::ento::ExprEngine::VisitLogicalExpr().
|
protectedpure virtual |
Referenced by evalCast().
|
protectedpure virtual |
Referenced by convertToArrayIndex().
Referenced by clang::ento::ExprEngine::evalComplement().
DefinedOrUnknownSVal SValBuilder::evalEQ | ( | ProgramStateRef | state, |
DefinedOrUnknownSVal | lhs, | ||
DefinedOrUnknownSVal | rhs | ||
) |
Definition at line 362 of file SValBuilder.cpp.
References clang::BO_EQ, clang::ento::SVal::castAs(), evalBinOp(), and getConditionType().
Referenced by clang::ento::ExprEngine::processSwitch(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().
Referenced by clang::ento::ExprEngine::evalMinus().
|
inline |
Definition at line 130 of file SValBuilder.h.
References ArrayIndexTy.
Referenced by addValue(), clang::ento::TypedValueRegion::getExtent(), clang::ento::StringRegion::getExtent(), and scaleValue().
|
inline |
Definition at line 134 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 135 of file SValBuilder.h.
References BasicVals.
DefinedSVal SValBuilder::getBlockPointer | ( | const BlockDecl * | block, |
CanQualType | locTy, | ||
const LocationContext * | locContext, | ||
unsigned | blockCount | ||
) |
Definition at line 203 of file SValBuilder.cpp.
References clang::LocationContext::getAnalysisDeclContext(), clang::ento::MemRegionManager::getBlockDataRegion(), clang::ento::MemRegionManager::getBlockTextRegion(), and MemMgr.
Referenced by clang::ento::ExprEngine::VisitBlockExpr().
|
inline |
Definition at line 126 of file SValBuilder.h.
References clang::ASTContext::BoolTy, Context, clang::ASTContext::getLangOpts(), and clang::ASTContext::IntTy.
Referenced by assumeCollectionNonEmpty(), evalEQ(), and clang::ento::ExprEngine::getInitialState().
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 157 of file SValBuilder.cpp.
References clang::ento::SymbolManager::canSymbolicate(), clang::ento::SymbolManager::conjureSymbol(), clang::ento::MemRegionManager::getSymbolicHeapRegion(), clang::Expr::getType(), clang::ento::Loc::isLocType(), MemMgr, and SymMgr.
Referenced by 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 229 of file SValBuilder.cpp.
References AttributeLangSupport::C, clang::CK_ArrayToPointerDecay, evalCast(), clang::Expr::EvaluateAsInt(), clang::CastExpr::getCastKind(), getContext(), getRegionManager(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::CharacterLiteral::getValue(), clang::Expr::IgnoreParens(), clang::Expr::isGLValue(), clang::ento::Loc::isLocType(), clang::Expr::isNullPointerConstant(), makeBoolVal(), makeIntVal(), makeLoc(), makeNull(), makeZeroVal(), clang::None, clang::Expr::NPC_ValueDependentIsNotNull, and clang::Result.
Referenced by clang::ento::Environment::getSVal(), and clang::ento::ExprEngine::Visit().
|
inline |
Definition at line 121 of file SValBuilder.h.
References Context.
Referenced by clang::ento::SimpleConstraintManager::assume(), clang::ento::ProgramState::assumeInBound(), clang::ento::StoreManager::CastRetrievedVal(), collectSubRegionBindings(), getConstantVal(), getCXXThis(), getExistingLazyBinding(), clang::ento::TypedValueRegion::getExtent(), clang::ento::FieldRegion::getExtent(), clang::CXXInstanceCall::getInitialStackFrameContents(), clang::ento::StoreManager::MakeElementRegion(), and makeZeroElementRegion().
|
inline |
Definition at line 122 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 215 of file SValBuilder.cpp.
References getContext(), getRegionManager(), and clang::CXXMethodDecl::getThisType().
Referenced by clang::CallEventManager::getCaller(), clang::CXXInstanceCall::getInitialStackFrameContents(), clang::CXXConstructorCall::getInitialStackFrameContents(), clang::ento::ExprEngine::getInitialState(), getRegionForConstructedObject(), 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 222 of file SValBuilder.cpp.
References getContext(), clang::ASTContext::getPointerType(), getRegionManager(), and clang::TypeDecl::getTypeForDecl().
DefinedOrUnknownSVal SValBuilder::getDerivedRegionValueSymbolVal | ( | SymbolRef | parentSymbol, |
const TypedValueRegion * | region | ||
) |
Definition at line 184 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(), MemMgr, and SymMgr.
DefinedSVal SValBuilder::getFunctionPointer | ( | const FunctionDecl * | func | ) |
Definition at line 199 of file SValBuilder.cpp.
References clang::ento::MemRegionManager::getFunctionTextRegion(), and MemMgr.
Referenced by clang::ento::ExprEngine::VisitCommonDeclRefExpr(), and clang::ento::ExprEngine::VisitMemberExpr().
|
pure virtual |
DefinedSVal SValBuilder::getMetadataSymbolVal | ( | const void * | symbolTag, |
const MemRegion * | region, | ||
const Expr * | expr, | ||
QualType | type, | ||
unsigned | count | ||
) |
Definition at line 168 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 140 of file SValBuilder.h.
References MemMgr.
Referenced by addParameterValuesToBindings(), getConstantVal(), getCXXThis(), getRegionForConstructedObject(), and clang::ento::ExprEngine::VisitCXXThisExpr().
|
inline |
Definition at line 141 of file SValBuilder.h.
References MemMgr.
DefinedOrUnknownSVal SValBuilder::getRegionValueSymbolVal | ( | const TypedValueRegion * | region | ) |
Make a unique symbol for value of region.
Definition at line 95 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(), MemMgr, and SymMgr.
|
inline |
Definition at line 124 of file SValBuilder.h.
References StateMgr.
Referenced by clang::BlockCall::getInitialStackFrameContents(), clang::CXXConstructorCall::getInitialStackFrameContents(), and clang::ObjCMethodCall::getInitialStackFrameContents().
|
inline |
Definition at line 137 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 138 of file SValBuilder.h.
References SymMgr.
Definition at line 73 of file SValBuilder.h.
References clang::ento::SymExpr::getType().
Definition at line 77 of file SValBuilder.h.
References Context, clang::ASTContext::getCanonicalType(), and clang::Type::isIntegralOrEnumerationType().
|
inline |
Definition at line 226 of file SValBuilder.h.
References ArrayIndexTy, and BasicVals.
Referenced by getValue(), clang::ento::StoreManager::MakeElementRegion(), scaleValue(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().
|
inline |
Definition at line 238 of file SValBuilder.h.
References clang::ObjCBoolLiteralExpr::getValue(), and makeTruthVal().
Referenced by getConstantVal().
nonloc::ConcreteInt SValBuilder::makeBoolVal | ( | const CXXBoolLiteralExpr * | boolean | ) |
Definition at line 90 of file SValBuilder.cpp.
References clang::CXXBoolLiteralExpr::getValue(), and makeTruthVal().
|
inline |
Definition at line 212 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getCompoundValData().
Referenced by clang::ento::ExprEngine::VisitInitListExpr().
|
inline |
Definition at line 248 of file SValBuilder.h.
References BasicVals.
|
inline |
Definition at line 232 of file SValBuilder.h.
References BasicVals, clang::Expr::getType(), clang::APIntStorage::getValue(), and clang::Type::isUnsignedIntegerOrEnumerationType().
Referenced by assumeCollectionNonEmpty(), clang::ento::nonloc::ConcreteInt::evalComplement(), clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(), clang::ento::nonloc::ConcreteInt::evalMinus(), getConstantVal(), clang::ento::TypedValueRegion::getExtent(), clang::ento::StringRegion::getExtent(), makeZeroVal(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), clang::ento::ExprEngine::VisitIncrementDecrementOperator(), clang::ento::ExprEngine::VisitLogicalExpr(), clang::ento::ExprEngine::VisitObjCForCollectionStmt(), clang::ento::ExprEngine::VisitOffsetOfExpr(), and clang::ento::ExprEngine::VisitUnaryExprOrTypeTraitExpr().
|
inline |
Definition at line 244 of file SValBuilder.h.
References BasicVals.
Definition at line 252 of file SValBuilder.h.
References BasicVals.
|
inline |
Definition at line 256 of file SValBuilder.h.
References BasicVals, and clang::ento::Loc::isLocType().
Definition at line 263 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getIntValue().
|
inline |
Definition at line 267 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getIntWithPtrWidth().
Referenced by clang::ento::ExprEngine::Visit().
|
inline |
Definition at line 216 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getLazyCompoundValData().
Definition at line 300 of file SValBuilder.h.
References clang::ento::MemRegionManager::getSymbolicRegion(), and MemMgr.
Referenced by addParameterValuesToBindings(), getConstantVal(), clang::ento::StoreManager::getLValueVar(), and clang::ento::ExprEngine::VisitObjCForCollectionStmt().
Definition at line 304 of file SValBuilder.h.
|
inline |
Definition at line 308 of file SValBuilder.h.
References clang::AddrLabelExpr::getLabel().
|
inline |
Definition at line 312 of file SValBuilder.h.
References BasicVals.
Definition at line 272 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getPersistentSValWithData().
NonLoc SValBuilder::makeNonLoc | ( | const SymExpr * | lhs, |
BinaryOperator::Opcode | op, | ||
const llvm::APSInt & | rhs, | ||
QualType | type | ||
) |
Definition at line 44 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getSymIntExpr(), clang::ento::Loc::isLocType(), and SymMgr.
Referenced by evalCast(), and makeSymExprValNN().
NonLoc SValBuilder::makeNonLoc | ( | const llvm::APSInt & | rhs, |
BinaryOperator::Opcode | op, | ||
const SymExpr * | lhs, | ||
QualType | type | ||
) |
Definition at line 54 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 62 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getSymSymExpr(), clang::ento::Loc::isLocType(), and SymMgr.
Create a NonLoc value for cast.
Definition at line 69 of file SValBuilder.cpp.
References clang::ento::SymbolManager::getCastSymbol(), clang::ento::Loc::isLocType(), and SymMgr.
|
inline |
Definition at line 296 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getZeroWithPtrWidth().
Referenced by getConstantVal(), makeZeroVal(), clang::ento::ExprEngine::VisitCast(), and clang::ento::ExprEngine::VisitUnaryOperator().
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 304 of file SValBuilder.cpp.
References clang::ento::SymExpr::computeComplexity(), clang::ento::SVal::getAs(), clang::ento::SVal::getAsSymExpr(), and makeNonLoc().
|
inline |
Definition at line 288 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getTruthValue().
Referenced by evalCast(), makeBoolVal(), and clang::ento::ExprEngine::VisitObjCForCollectionStmt().
|
inline |
Definition at line 292 of file SValBuilder.h.
References BasicVals, and clang::ento::BasicValueFactory::getTruthValue().
|
inline |
Definition at line 222 of file SValBuilder.h.
References ArrayIndexTy, and BasicVals.
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 clang::Type::isIntegralOrEnumerationType(), clang::ento::Loc::isLocType(), makeIntVal(), and makeNull().
Referenced by getConstantVal(), clang::ento::ExprEngine::getInitialState(), clang::ento::ExprEngine::VisitCXXConstructExpr(), clang::ento::ExprEngine::VisitIncrementDecrementOperator(), clang::ento::ExprEngine::VisitInitListExpr(), and clang::ento::ExprEngine::VisitUnaryOperator().
|
protected |
The scalar type to use for array indices.
Definition at line 48 of file SValBuilder.h.
Referenced by convertToArrayIndex(), getArrayIndexType(), makeArrayIndex(), and makeZeroArrayIndex().
|
protected |
The width of the scalar type used for array indices.
Definition at line 51 of file SValBuilder.h.
Referenced by convertToArrayIndex().
|
protected |
Manager of APSInt values.
Definition at line 37 of file SValBuilder.h.
Referenced by getBasicValueFactory(), makeArrayIndex(), makeCompoundVal(), makeIntLocVal(), makeIntVal(), makeIntValWithPtrWidth(), makeLazyCompoundVal(), makeLoc(), makeLocAsInteger(), makeNull(), makeTruthVal(), and makeZeroArrayIndex().
|
protected |
Definition at line 34 of file SValBuilder.h.
Referenced by evalCast(), getConditionType(), getContext(), and haveSameType().
|
protected |
Manages the creation of memory regions.
Definition at line 43 of file SValBuilder.h.
Referenced by conjureSymbolVal(), getBlockPointer(), getConjuredHeapSymbolVal(), getDerivedRegionValueSymbolVal(), getFunctionPointer(), getMetadataSymbolVal(), getRegionManager(), getRegionValueSymbolVal(), and makeLoc().
|
protected |
Definition at line 45 of file SValBuilder.h.
Referenced by evalCast(), and getStateManager().
|
protected |
Manages the creation of symbols.
Definition at line 40 of file SValBuilder.h.
Referenced by conjureSymbol(), conjureSymbolVal(), getConjuredHeapSymbolVal(), getDerivedRegionValueSymbolVal(), getMetadataSymbolVal(), getRegionValueSymbolVal(), getSymbolManager(), and makeNonLoc().