[cfe-commits] r68692 - in /cfe/trunk: include/clang/Analysis/PathSensitive/SVals.h lib/Analysis/CFRefCount.cpp lib/Analysis/SVals.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Apr 8 23:30:19 PDT 2009


Author: zhongxingxu
Date: Thu Apr  9 01:30:17 2009
New Revision: 68692

URL: http://llvm.org/viewvc/llvm-project?rev=68692&view=rev
Log:
Add a new method because sometimes the type of the conjured symbol is not the
type of the expression where we create the symbol.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/lib/Analysis/SVals.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=68692&r1=68691&r2=68692&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Thu Apr  9 01:30:17 2009
@@ -78,6 +78,8 @@
 
   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;

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=68692&r1=68691&r2=68692&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Apr  9 01:30:17 2009
@@ -1761,7 +1761,7 @@
           
             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()) {

Modified: cfe/trunk/lib/Analysis/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=68692&r1=68691&r2=68692&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/SVals.cpp (original)
+++ cfe/trunk/lib/Analysis/SVals.cpp Thu Apr  9 01:30:17 2009
@@ -312,6 +312,19 @@
   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));





More information about the cfe-commits mailing list