[cfe-commits] r63178 - /cfe/trunk/lib/Analysis/CFRefCount.cpp

Ted Kremenek kremenek at apple.com
Tue Jan 27 21:06:47 PST 2009


Author: kremenek
Date: Tue Jan 27 23:06:46 2009
New Revision: 63178

URL: http://llvm.org/viewvc/llvm-project?rev=63178&view=rev
Log:
retain/release checker: Output the name of the function that allocates an object.

Modified:
    cfe/trunk/lib/Analysis/CFRefCount.cpp

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

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Tue Jan 27 23:06:46 2009
@@ -2312,10 +2312,10 @@
   // Check if the type state has changed.
   
   const GRState* PrevSt = PrevN->getState();
-  const GRState* CurrSt = N->getState();
-  
+  GRStateRef CurrSt(N->getState(), cast<GRBugReporter>(BR).getStateManager());
+
   RefBindings PrevB = PrevSt->get<RefBindings>();
-  RefBindings CurrB = CurrSt->get<RefBindings>();
+  RefBindings CurrB = CurrSt.get<RefBindings>();
   
   const RefVal* PrevT = PrevB.lookup(Sym);
   const RefVal* CurrT = CurrB.lookup(Sym);
@@ -2332,10 +2332,17 @@
     Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
 
     if (CurrV.isOwned()) {
+      if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
+        // Get the name of the callee (if it is available).
+        SVal X = CurrSt.GetSVal(CE->getCallee());
 
-      if (isa<CallExpr>(S)) {
-        os <<  "Function call returns an object with a +1 retain count"
-                " (owning reference).";
+        if (loc::FuncVal* FV = dyn_cast<loc::FuncVal>(&X))
+          os << "Call to function '" << FV->getDecl()->getNameAsString() <<'\'';
+        else
+          os << "Function call";
+        
+        os << " returns an object with a +1 retain count"
+              " (owning reference).";
       }
       else {
         assert (isa<ObjCMessageExpr>(S));
@@ -2421,17 +2428,11 @@
   
   // Add the range by scanning the children of the statement for any bindings
   // to Sym.
-  
-  GRStateManager& VSM = cast<GRBugReporter>(BR).getStateManager();
-  
   for (Stmt::child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I)
     if (Expr* Exp = dyn_cast_or_null<Expr>(*I)) {
-      SVal X = VSM.GetSVal(CurrSt, Exp);
-      
+      SVal X = CurrSt.GetSVal(Exp);      
       if (loc::SymbolVal* SV = dyn_cast<loc::SymbolVal>(&X))
-        if (SV->getSymbol() == Sym) {
-          P->addRange(Exp->getSourceRange()); break;
-        }
+        if (SV->getSymbol() == Sym) P->addRange(Exp->getSourceRange()); break;
     }
   
   return P;





More information about the cfe-commits mailing list