[cfe-commits] r50924 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRExprEngine.h include/clang/Analysis/PathSensitive/RValues.h lib/Analysis/CFRefCount.cpp lib/Analysis/GRExprEngine.cpp lib/Analysis/GRSimpleVals.cpp

Ted Kremenek kremenek at apple.com
Fri May 9 16:45:33 PDT 2008


Author: kremenek
Date: Fri May  9 18:45:33 2008
New Revision: 50924

URL: http://llvm.org/viewvc/llvm-project?rev=50924&view=rev
Log:
Rename IsPointerType to LVal::IsLValType, and update CFRefCount::EvalSummary to use IsLValType when conjuring symbols for return values (this fixes a bug with an assertion firing in the analyzer when two qualified objective-c types were compared).

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
    cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/lib/Analysis/GRSimpleVals.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Fri May  9 18:45:33 2008
@@ -648,18 +648,6 @@
   
   ValueState* MarkBranch(ValueState* St, Stmt* Terminator, bool branchTaken);
 };
-} // end clang namespace
-
-
-//===----------------------------------------------------------------------===//
-// Utility
-//===----------------------------------------------------------------------===//
-
-namespace clang {
-  
-static inline bool IsPointerType(QualType T) {
-  return T->isPointerType() || T->isObjCQualifiedIdType();
-}
   
 } // end clang namespace
 

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

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/RValues.h Fri May  9 18:45:33 2008
@@ -157,6 +157,10 @@
   static inline bool classof(const RVal* V) {
     return V->getBaseKind() == LValKind;
   }
+  
+  static inline bool IsLValType(QualType T) {
+    return T->isPointerType() || T->isObjCQualifiedIdType();
+  }
 };
   
 //==------------------------------------------------------------------------==//

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

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri May  9 18:45:33 2008
@@ -1230,9 +1230,9 @@
         unsigned Count = Builder.getCurrentBlockCount();
         SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count);
         
-        RVal X = Ex->getType()->isPointerType() 
-        ? cast<RVal>(lval::SymbolVal(Sym)) 
-        : cast<RVal>(nonlval::SymbolVal(Sym));
+        RVal X = LVal::IsLValType(Ex->getType())
+               ? cast<RVal>(lval::SymbolVal(Sym)) 
+               : cast<RVal>(nonlval::SymbolVal(Sym));
         
         St = StateMgr.SetRVal(St, Ex, X, Eng.getCFG().isBlkExpr(Ex), false);
       }      

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri May  9 18:45:33 2008
@@ -795,7 +795,7 @@
   // abstract address of the base object.
   NodeSet Tmp;
   
-  if (IsPointerType(Base->getType())) // Base always is an LVal.
+  if (LVal::IsLValType(Base->getType())) // Base always is an LVal.
     Visit(Base, Pred, Tmp);
   else  
     VisitLVal(Base, Pred, Tmp);
@@ -842,7 +842,7 @@
   
   if (asLVal) {
       
-    if (IsPointerType(Base->getType())) // Base always is an LVal.
+    if (LVal::IsLValType(Base->getType())) // Base always is an LVal.
       Visit(Base, Pred, Tmp);
     else  
       VisitLVal(Base, Pred, Tmp);
@@ -869,7 +869,7 @@
     ValueState* St = GetState(*I);
     RVal BaseV = GetRVal(St, Base);
     
-    if (IsPointerType(Base->getType())) {
+    if (LVal::IsLValType(Base->getType())) {
     
       assert (M->isArrow());
       
@@ -1389,7 +1389,7 @@
     }
   
     // Check for casts from pointers to integers.
-    if (T->isIntegerType() && IsPointerType(ExTy)) {
+    if (T->isIntegerType() && LVal::IsLValType(ExTy)) {
       unsigned bits = getContext().getTypeSize(ExTy);
     
       // FIXME: Determine if the number of bits of the target type is 
@@ -1402,7 +1402,7 @@
     }
     
     // Check for casts from integers to pointers.
-    if (IsPointerType(T) && ExTy->isIntegerType())
+    if (LVal::IsLValType(T) && ExTy->isIntegerType())
       if (nonlval::LValAsInteger *LV = dyn_cast<nonlval::LValAsInteger>(&V)) {
         // Just unpackage the lval and return it.
         V = LV->getLVal();
@@ -1481,7 +1481,7 @@
 
         QualType T = VD->getType();
         
-        if (IsPointerType(T))
+        if (LVal::IsLValType(T))
           St = SetRVal(St, lval::DeclVal(VD),
                        lval::ConcreteInt(BasicVals.getValue(0, T)));
         else if (T->isIntegerType())
@@ -1499,7 +1499,7 @@
 
       QualType T = VD->getType();
 
-      if (IsPointerType(T) || T->isIntegerType()) {
+      if (LVal::IsLValType(T) || T->isIntegerType()) {
         
         RVal V = Ex ? GetRVal(St, Ex) : UndefinedVal();
         
@@ -1510,7 +1510,7 @@
           unsigned Count = Builder->getCurrentBlockCount();
           SymbolID Sym = SymMgr.getConjuredSymbol(Ex, Count);
           
-          V = IsPointerType(Ex->getType())
+          V = LVal::IsLValType(Ex->getType())
             ? cast<RVal>(lval::SymbolVal(Sym)) 
             : cast<RVal>(nonlval::SymbolVal(Sym));            
         }
@@ -1965,7 +1965,7 @@
             unsigned Count = Builder->getCurrentBlockCount();
             SymbolID Sym = SymMgr.getConjuredSymbol(B->getRHS(), Count);
             
-            RightV = IsPointerType(B->getRHS()->getType()) 
+            RightV = LVal::IsLValType(B->getRHS()->getType()) 
                    ? cast<RVal>(lval::SymbolVal(Sym)) 
                    : cast<RVal>(nonlval::SymbolVal(Sym));            
           }

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

==============================================================================
--- cfe/trunk/lib/Analysis/GRSimpleVals.cpp (original)
+++ cfe/trunk/lib/Analysis/GRSimpleVals.cpp Fri May  9 18:45:33 2008
@@ -379,10 +379,10 @@
   BasicValueFactory& BasicVals = Eng.getBasicVals();
   
   llvm::APSInt V = cast<nonlval::ConcreteInt>(X).getValue();
-  V.setIsUnsigned(T->isUnsignedIntegerType() || IsPointerType(T));
+  V.setIsUnsigned(T->isUnsignedIntegerType() || LVal::IsLValType(T));
   V.extOrTrunc(Eng.getContext().getTypeSize(T));
   
-  if (IsPointerType(T))
+  if (LVal::IsLValType(T))
     return lval::ConcreteInt(BasicVals.getValue(V));
   else
     return nonlval::ConcreteInt(BasicVals.getValue(V));
@@ -398,7 +398,7 @@
   //   can be introduced by the frontend for corner cases, e.g
   //   casting from va_list* to __builtin_va_list&.
   //
-  if (IsPointerType(T) || T->isReferenceType())
+  if (LVal::IsLValType(T) || T->isReferenceType())
     return X;
   
   assert (T->isIntegerType());
@@ -409,7 +409,7 @@
   BasicValueFactory& BasicVals = Eng.getBasicVals();
   
   llvm::APSInt V = cast<lval::ConcreteInt>(X).getValue();
-  V.setIsUnsigned(T->isUnsignedIntegerType() || IsPointerType(T));
+  V.setIsUnsigned(T->isUnsignedIntegerType() || LVal::IsLValType(T));
   V.extOrTrunc(Eng.getContext().getTypeSize(T));
 
   return nonlval::ConcreteInt(BasicVals.getValue(V));
@@ -672,7 +672,7 @@
     unsigned Count = Builder.getCurrentBlockCount();
     SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count);
         
-    RVal X = IsPointerType(CE->getType())
+    RVal X = LVal::IsLValType(CE->getType())
              ? cast<RVal>(lval::SymbolVal(Sym)) 
              : cast<RVal>(nonlval::SymbolVal(Sym));
     





More information about the cfe-commits mailing list