[cfe-commits] r104388 - /cfe/trunk/lib/Checker/CFRefCount.cpp

Ted Kremenek kremenek at apple.com
Fri May 21 14:56:53 PDT 2010


Author: kremenek
Date: Fri May 21 16:56:53 2010
New Revision: 104388

URL: http://llvm.org/viewvc/llvm-project?rev=104388&view=rev
Log:
Pass around an error SourceRange instead of an Expr* when reporting errors
in the Objective-C memory checker.

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

Modified: cfe/trunk/lib/Checker/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CFRefCount.cpp?rev=104388&r1=104387&r2=104388&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Checker/CFRefCount.cpp Fri May 21 16:56:53 2010
@@ -1374,7 +1374,7 @@
   //  we just use the 'ID' from the message expression.
   SVal receiverV;
 
-  if (const Expr *Receiver = ME->getInstanceReceiver()) {
+  if (Receiver) {
     receiverV = state->getSValAsScalarOrLoc(Receiver);
   
     // FIXME: Eventually replace the use of state->get<RefBindings> with
@@ -1724,7 +1724,7 @@
 
   void ProcessNonLeakError(ExplodedNodeSet& Dst,
                            GRStmtNodeBuilder& Builder,
-                           Expr* NodeExpr, Expr* ErrorExpr,
+                           Expr* NodeExpr, SourceRange ErrorRange,
                            ExplodedNode* Pred,
                            const GRState* St,
                            RefVal::Kind hasErr, SymbolRef Sym);
@@ -2572,7 +2572,7 @@
   // Evaluate the effect of the arguments.
   RefVal::Kind hasErr = (RefVal::Kind) 0;
   unsigned idx = 0;
-  Expr* ErrorExpr = NULL;
+  SourceRange ErrorRange;
   SymbolRef ErrorSym = 0;
 
   llvm::SmallVector<const MemRegion*, 10> RegionsToInvalidate;
@@ -2585,7 +2585,7 @@
       if (RefBindings::data_type* T = state->get<RefBindings>(Sym)) {
         state = Update(state, Sym, *T, Summ.getArg(idx), hasErr);
         if (hasErr) {
-          ErrorExpr = *I;
+          ErrorRange = (*I)->getSourceRange();
           ErrorSym = Sym;
           break;
         }
@@ -2678,13 +2678,13 @@
   }
 
   // Evaluate the effect on the message receiver.
-  if (!ErrorExpr && Receiver) {
+  if (!ErrorRange.isValid() && Receiver) {
     SymbolRef Sym = state->getSValAsScalarOrLoc(Receiver).getAsLocSymbol();
     if (Sym) {
       if (const RefVal* T = state->get<RefBindings>(Sym)) {
         state = Update(state, Sym, *T, Summ.getReceiverEffect(), hasErr);
         if (hasErr) {
-          ErrorExpr = Receiver;
+          ErrorRange = Receiver->getSourceRange();
           ErrorSym = Sym;
         }
       }
@@ -2693,7 +2693,7 @@
 
   // Process any errors.
   if (hasErr) {
-    ProcessNonLeakError(Dst, Builder, Ex, ErrorExpr, Pred, state,
+    ProcessNonLeakError(Dst, Builder, Ex, ErrorRange, Pred, state,
                         hasErr, ErrorSym);
     return;
   }
@@ -2760,7 +2760,7 @@
     }
 
     case RetEffect::ReceiverAlias: {
-      assert (Receiver);
+      assert(Receiver);
       SVal V = state->getSValAsScalarOrLoc(Receiver);
       state = state->BindExpr(Ex, V, false);
       break;
@@ -3409,7 +3409,7 @@
 
 void CFRefCount::ProcessNonLeakError(ExplodedNodeSet& Dst,
                                      GRStmtNodeBuilder& Builder,
-                                     Expr* NodeExpr, Expr* ErrorExpr,
+                                     Expr* NodeExpr, SourceRange ErrorRange,
                                      ExplodedNode* Pred,
                                      const GRState* St,
                                      RefVal::Kind hasErr, SymbolRef Sym) {
@@ -3440,7 +3440,7 @@
   }
 
   CFRefReport *report = new CFRefReport(*BT, *this, N, Sym);
-  report->addRange(ErrorExpr->getSourceRange());
+  report->addRange(ErrorRange);
   BR->EmitReport(report);
 }
 





More information about the cfe-commits mailing list