]> granicus.if.org Git - clang/commitdiff
Add a new method because sometimes the type of the conjured symbol is not the
authorZhongxing Xu <xuzhongxing@gmail.com>
Thu, 9 Apr 2009 06:30:17 +0000 (06:30 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Thu, 9 Apr 2009 06:30:17 +0000 (06:30 +0000)
type of the expression where we create the symbol.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68692 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/SVals.h
lib/Analysis/CFRefCount.cpp
lib/Analysis/SVals.cpp

index 6667f9323b113b93bbd6106ef58441f105fe5279..9d9d9d8091ab6aa7d778d75352bbf83ec7eeccd5 100644 (file)
@@ -78,6 +78,8 @@ public:
 
   static SVal GetConjuredSymbolVal(SymbolManager& SymMgr, MemRegionManager&,
                                    const Expr *E, unsigned Count);  
+  static SVal GetConjuredSymbolVal(SymbolManager &SymMgr, MemRegionManager&,
+                                   const Expr* E, QualType T, unsigned Count);
 
   inline bool isUnknown() const {
     return getRawKind() == UnknownKind;
index 9f48fffc28ed22898b24da30bac7657d97609640..5d1834f9297e29004cd11255101af171f74d976b 100644 (file)
@@ -1761,7 +1761,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
           
             if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())){
               SVal V = SVal::GetConjuredSymbolVal(Eng.getSymbolManager(),
-                           Eng.getStoreManager().getRegionManager(), *I, Count);
+                        Eng.getStoreManager().getRegionManager(), *I, T, Count);
               state = state.BindLoc(Loc::MakeVal(R), V);
             }
             else if (const RecordType *RT = T->getAsStructureType()) {
index cf3e800d994ae283c04a3258078abe54e79309bb..ddb2da611fb9fbc2448f93e496718de4ba5460f3 100644 (file)
@@ -312,6 +312,19 @@ SVal SVal::GetConjuredSymbolVal(SymbolManager &SymMgr, MemRegionManager& MRMgr,
   return UnknownVal();
 }
 
+SVal SVal::GetConjuredSymbolVal(SymbolManager &SymMgr, MemRegionManager& MRMgr,
+                                const Expr* E, QualType T, unsigned Count) {
+  SymbolRef sym = SymMgr.getConjuredSymbol(E, T, Count);
+
+  if (Loc::IsLocType(T))
+    return Loc::MakeVal(MRMgr.getSymbolicRegion(sym));
+
+  if (T->isIntegerType() && T->isScalarType())
+    return NonLoc::MakeVal(sym);
+
+  return UnknownVal();
+}
+
 nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, Loc V,
                                                 unsigned Bits) {
   return LocAsInteger(Vals.getPersistentSValWithData(V, Bits));