Hooked up the dead-store checker to the BugReporter interface.  Now dead-store
warnings are emitted as part of the warnings registered by GRSimpleVals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49658 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRSimpleVals.cpp b/lib/Analysis/GRSimpleVals.cpp
index c350ab9..b37ccf5 100644
--- a/lib/Analysis/GRSimpleVals.cpp
+++ b/lib/Analysis/GRSimpleVals.cpp
@@ -44,8 +44,8 @@
                          ITER I, ITER E) {
   
   for (; I != E; ++I) {
-    BugReport R(D);    
-    BR.EmitPathWarning(R, GetNode(I));
+    BugReport R(D, GetNode(I));    
+    BR.EmitPathWarning(R);
   }
 }
 
@@ -159,20 +159,6 @@
   
   
 class VISIBILITY_HIDDEN BadArg : public BugType {
-protected:
-  
-  class Report : public BugReport {
-    const SourceRange R;
-  public:
-    Report(BugType& D, Expr* E) : BugReport(D), R(E->getSourceRange()) {}
-    virtual ~Report() {}
-
-    virtual void getRanges(const SourceRange*& B, const SourceRange*& E) const {
-      B = &R;
-      E = B+1;
-    }
-  };
-    
 public:
   
   virtual ~BadArg() {}
@@ -192,10 +178,11 @@
          E = Eng.undef_arg_end(); I!=E; ++I) {
       
       // Generate a report for this bug.
-      Report report(*this, I->second);
+      RangedBugReport report(*this, I->first);
+      report.addRange(I->second->getSourceRange());
 
       // Emit the warning.
-      BR.EmitPathWarning(report, I->first);
+      BR.EmitPathWarning(report);
     }
 
   }
@@ -218,35 +205,16 @@
          E = Eng.msg_expr_undef_arg_end(); I!=E; ++I) {
       
       // Generate a report for this bug.
-      Report report(*this, I->second);
+      RangedBugReport report(*this, I->first);
+      report.addRange(I->second->getSourceRange());
       
       // Emit the warning.
-      BR.EmitPathWarning(report, I->first);
-    }
-    
+      BR.EmitPathWarning(report);
+    }    
   }
 };
 
 class VISIBILITY_HIDDEN BadReceiver : public BugType {
-  
-  class Report : public BugReport {
-    SourceRange R;
-  public:
-    Report(BugType& D, ExplodedNode<ValueState> *N) : BugReport(D) {      
-      Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
-      Expr* E = cast<ObjCMessageExpr>(S)->getReceiver();
-      assert (E && "Receiver cannot be NULL");
-      R = E->getSourceRange();
-    }
-    
-    virtual ~Report() {}
-    
-    virtual void getRanges(const SourceRange*& B, const SourceRange*& E) const {
-      B = &R;
-      E = B+1;
-    }
-  };
-
 public:  
   virtual const char* getName() const {
     return "bad receiver";
@@ -263,10 +231,16 @@
          E = Eng.undef_receivers_end(); I!=E; ++I) {
           
       // Generate a report for this bug.
-      Report report(*this, *I);
+      RangedBugReport report(*this, *I);
+      
+      ExplodedNode<ValueState>* N = *I;
+      Stmt *S = cast<PostStmt>(N->getLocation()).getStmt();
+      Expr* E = cast<ObjCMessageExpr>(S)->getReceiver();
+      assert (E && "Receiver cannot be NULL");
+      report.addRange(E->getSourceRange());
       
       // Emit the warning.
-      BR.EmitPathWarning(report, *I);
+      BR.EmitPathWarning(report);
     }    
   }
 };
@@ -291,6 +265,8 @@
 } // end anonymous namespace
 
 void GRSimpleVals::RegisterChecks(GRExprEngine& Eng) {
+  
+  // Path-sensitive checks.
   Eng.Register(new NullDeref());
   Eng.Register(new UndefDeref());
   Eng.Register(new UndefBranch());
@@ -302,6 +278,9 @@
   Eng.Register(new BadMsgExprArg());
   Eng.Register(new BadReceiver());
   
+  // Flow-sensitive checks.
+  Eng.Register(MakeDeadStoresChecker());  
+  
   // Add extra checkers.
 
   GRSimpleAPICheck* FoundationCheck =