From 867418fdb53b351f7c88cb0255c4a250ea283c3a Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Thu, 9 Apr 2009 05:57:11 +0000 Subject: [PATCH] Create a symbolic region instead of a loc::SymbolVal. This is a continued step to eliminate the use of loc::SymbolVal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68685 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Analysis/PathSensitive/SVals.h | 4 ++-- lib/Analysis/GRExprEngine.cpp | 3 ++- lib/Analysis/SVals.cpp | 23 +++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h index 0f334f12f2..6667f9323b 100644 --- a/include/clang/Analysis/PathSensitive/SVals.h +++ b/include/clang/Analysis/PathSensitive/SVals.h @@ -76,8 +76,8 @@ public: static SVal GetRValueSymbolVal(SymbolManager& SymMgr, MemRegionManager& MRMgr, const MemRegion* R); - static SVal GetConjuredSymbolVal(SymbolManager& SymMgr, const Expr *E, - unsigned Count); + static SVal GetConjuredSymbolVal(SymbolManager& SymMgr, MemRegionManager&, + const Expr *E, unsigned Count); inline bool isUnknown() const { return getRawKind() == UnknownKind; diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 7e3fd45ab9..1fb7e5d966 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -2536,7 +2536,8 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, // Conjure a new symbol if necessary to recover precision. if (Result.isUnknown() || !getConstraintManager().canReasonAbout(Result)) - Result = SVal::GetConjuredSymbolVal(SymMgr, Ex, + Result = SVal::GetConjuredSymbolVal(SymMgr, + getStoreManager().getRegionManager(),Ex, Builder->getCurrentBlockCount()); state = BindExpr(state, U, U->isPostfix() ? V2 : Result); diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp index c5900b30cd..cf3e800d99 100644 --- a/lib/Analysis/SVals.cpp +++ b/lib/Analysis/SVals.cpp @@ -291,26 +291,23 @@ SVal SVal::GetRValueSymbolVal(SymbolManager& SymMgr, MemRegionManager& MRMgr, return Loc::MakeVal(MRMgr.getSymbolicRegion(sym)); // Only handle integers for now. - if (T->isIntegerType()) + if (T->isIntegerType() && T->isScalarType()) return NonLoc::MakeVal(sym); } return UnknownVal(); } -SVal SVal::GetConjuredSymbolVal(SymbolManager &SymMgr, const Expr* E, - unsigned Count) { - +SVal SVal::GetConjuredSymbolVal(SymbolManager &SymMgr, MemRegionManager& MRMgr, + const Expr* E, unsigned Count) { QualType T = E->getType(); - - if (Loc::IsLocType(T)) { - SymbolRef Sym = SymMgr.getConjuredSymbol(E, Count); - return loc::SymbolVal(Sym); - } - else if (T->isIntegerType() && T->isScalarType()) { - SymbolRef Sym = SymMgr.getConjuredSymbol(E, Count); - return nonloc::SymbolVal(Sym); - } + SymbolRef sym = SymMgr.getConjuredSymbol(E, Count); + + if (Loc::IsLocType(T)) + return Loc::MakeVal(MRMgr.getSymbolicRegion(sym)); + + if (T->isIntegerType() && T->isScalarType()) + return NonLoc::MakeVal(sym); return UnknownVal(); } -- 2.40.0