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

Ted Kremenek kremenek at apple.com
Tue Feb 10 15:56:07 PST 2009


Author: kremenek
Date: Tue Feb 10 17:56:07 2009
New Revision: 64259

URL: http://llvm.org/viewvc/llvm-project?rev=64259&view=rev
Log:
BugReporter: Use llvm::raw_string_stream instead of std::ostringstream.

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=64259&r1=64258&r2=64259&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Tue Feb 10 17:56:07 2009
@@ -24,7 +24,6 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
-#include <sstream>
 
 using namespace clang;
 
@@ -75,27 +74,26 @@
   return isa<BlockEntrance>(ProgP) ? GetLastStmt(N) : GetStmt(ProgP);
 }
 
-static void ExecutionContinues(std::ostringstream& os, SourceManager& SMgr,
-                               const Stmt* S) {
-  
+static void ExecutionContinues(llvm::raw_string_ostream& os,
+                               SourceManager& SMgr,
+                               const Stmt* S) {  
   if (!S)
     return;
   
   // Slow, but probably doesn't matter.
-  if (os.str().empty())
-    os << ' ';
+  if (os.str().empty()) os << ' ';
   
   os << "Execution continues on line "
-  << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.';
+     << SMgr.getInstantiationLineNumber(S->getLocStart()) << '.';
 }
 
-static inline void ExecutionContinues(std::ostringstream& os,
+static inline void ExecutionContinues(llvm::raw_string_ostream& os,
                                       SourceManager& SMgr,
                                       const ExplodedNode<GRState>* N) {
   ExecutionContinues(os, SMgr, GetStmt(N->getLocation()));
 }
 
-static inline void ExecutionContinues(std::ostringstream& os,
+static inline void ExecutionContinues(llvm::raw_string_ostream& os,
                                       SourceManager& SMgr,
                                       const CFGBlock* B) {  
   ExecutionContinues(os, SMgr, GetStmt(B));
@@ -603,7 +601,8 @@
           if (!S)
             continue;
           
-          std::ostringstream os;
+          std::string sbuf;
+          llvm::raw_string_ostream os(sbuf);
           
           os << "Control jumps to line "
              << SMgr.getInstantiationLineNumber(S->getLocStart()) << ".\n";
@@ -612,11 +611,10 @@
           break;
         }
           
-        case Stmt::SwitchStmtClass: {
-          
+        case Stmt::SwitchStmtClass: {          
           // Figure out what case arm we took.
-
-          std::ostringstream os;
+          std::string sbuf;
+          llvm::raw_string_ostream os(sbuf);
 
           if (Stmt* S = Dst->getLabel())
             switch (S->getStmtClass()) {
@@ -663,9 +661,8 @@
                   continue;
                 }
                 
-                llvm::raw_os_ostream OS(os);
-                OS << V;
-              }              
+                os << V;
+              }       
               
               os << ":'  at line " 
                  << SMgr.getInstantiationLineNumber(S->getLocStart()) << ".\n";
@@ -684,15 +681,16 @@
           
         case Stmt::BreakStmtClass:
         case Stmt::ContinueStmtClass: {
-          std::ostringstream os;
+          std::string sbuf;
+          llvm::raw_string_ostream os(sbuf);
           ExecutionContinues(os, SMgr, LastNode);
           PD.push_front(new PathDiagnosticPiece(L, os.str()));
           break;
         }
 
         case Stmt::ConditionalOperatorClass: {
-          
-          std::ostringstream os;
+          std::string sbuf;
+          llvm::raw_string_ostream os(sbuf);
           os << "'?' condition evaluates to ";
 
           if (*(Src->succ_begin()+1) == Dst)
@@ -700,16 +698,15 @@
           else
             os << "true.";
           
-          PD.push_front(new PathDiagnosticPiece(L, os.str()));
-          
+          PD.push_front(new PathDiagnosticPiece(L, os.str()));          
           break;
         }
           
         case Stmt::DoStmtClass:  {
           
           if (*(Src->succ_begin()) == Dst) {
-            
-            std::ostringstream os;          
+            std::string sbuf;
+            llvm::raw_string_ostream os(sbuf);
             
             os << "Loop condition is true. ";
             ExecutionContinues(os, SMgr, Dst);
@@ -727,12 +724,12 @@
         case Stmt::ForStmtClass: {
           
           if (*(Src->succ_begin()+1) == Dst) {
-            
-            std::ostringstream os;          
+            std::string sbuf;
+            llvm::raw_string_ostream os(sbuf);
 
             os << "Loop condition is false. ";
             ExecutionContinues(os, SMgr, Dst);
-          
+
             PD.push_front(new PathDiagnosticPiece(L, os.str()));
           }
           else
@@ -742,8 +739,7 @@
           break;
         }
           
-        case Stmt::IfStmtClass: {
-          
+        case Stmt::IfStmtClass: {          
           if (*(Src->succ_begin()+1) == Dst)
             PD.push_front(new PathDiagnosticPiece(L, "Taking false branch."));
           else 





More information about the cfe-commits mailing list