[cfe-commits] r65346 - /cfe/trunk/lib/Analysis/BugReporter.cpp

Ted Kremenek kremenek at apple.com
Mon Feb 23 15:13:51 PST 2009


Author: kremenek
Date: Mon Feb 23 17:13:51 2009
New Revision: 65346

URL: http://llvm.org/viewvc/llvm-project?rev=65346&view=rev
Log:
Tidy up 'ExecutionContinues' to distinguish between jumping to the end of a 'method' or 'funciton'.

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

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

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Mon Feb 23 17:13:51 2009
@@ -83,25 +83,22 @@
 //===----------------------------------------------------------------------===//
 // Diagnostics for 'execution continues on line XXX'.
 //===----------------------------------------------------------------------===//
-        
-static void ExecutionContinues(llvm::raw_string_ostream& os,
-                               SourceManager& SMgr,
-                               const Stmt* S) {  
+
+static inline void ExecutionContinues(llvm::raw_string_ostream& os,
+                                      SourceManager& SMgr,
+                                      const ExplodedNode<GRState>* N,
+                                      const Decl& D) {
+  
   // Slow, but probably doesn't matter.
   if (os.str().empty())
     os << ' ';
   
-  if (S)
+  if (Stmt *S = GetNextStmt(N))
     os << "Execution continues on line "
-       << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.';
+    << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.';
   else
-    os << "Execution jumps to the end of the function.";
-}
-
-static inline void ExecutionContinues(llvm::raw_string_ostream& os,
-                                      SourceManager& SMgr,
-                                      const ExplodedNode<GRState>* N) {
-  ExecutionContinues(os, SMgr, GetNextStmt(N));
+    os << "Execution jumps to the end of the "
+       << (isa<ObjCMethodDecl>(D) ? "method" : "function") << '.';
 }
 
 //===----------------------------------------------------------------------===//
@@ -704,7 +701,7 @@
           }
           else {
             os << "'Default' branch taken. ";
-            ExecutionContinues(os, SMgr, N);
+            ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl());
           }
           
           PD.push_front(new PathDiagnosticPiece(L, os.str()));
@@ -715,7 +712,7 @@
         case Stmt::ContinueStmtClass: {
           std::string sbuf;
           llvm::raw_string_ostream os(sbuf);
-          ExecutionContinues(os, SMgr, N);
+          ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl());
           PD.push_front(new PathDiagnosticPiece(L, os.str()));
           break;
         }
@@ -741,7 +738,7 @@
             llvm::raw_string_ostream os(sbuf);
             
             os << "Loop condition is true. ";
-            ExecutionContinues(os, SMgr, N);
+            ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl());
             
             PD.push_front(new PathDiagnosticPiece(L, os.str()));
           }
@@ -760,7 +757,7 @@
             llvm::raw_string_ostream os(sbuf);
 
             os << "Loop condition is false. ";
-            ExecutionContinues(os, SMgr, N);
+            ExecutionContinues(os, SMgr, N, getStateManager().getCodeDecl());
 
             PD.push_front(new PathDiagnosticPiece(L, os.str()));
           }





More information about the cfe-commits mailing list