]> granicus.if.org Git - clang/commitdiff
Remove uses of std::ostream from libAnalysis.
authorTed Kremenek <kremenek@apple.com>
Wed, 24 Jun 2009 23:06:47 +0000 (23:06 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 24 Jun 2009 23:06:47 +0000 (23:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74136 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
include/clang/Analysis/PathSensitive/ConstraintManager.h
include/clang/Analysis/PathSensitive/GRState.h
include/clang/Analysis/PathSensitive/SVals.h
include/clang/Analysis/PathSensitive/Store.h
include/clang/Analysis/PathSensitive/SymbolManager.h
lib/Analysis/BasicConstraintManager.cpp
lib/Analysis/BasicStore.cpp
lib/Analysis/CFRefCount.cpp
lib/Analysis/CheckObjCUnusedIVars.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/GRState.cpp
lib/Analysis/RangeConstraintManager.cpp
lib/Analysis/RegionStore.cpp
lib/Analysis/SVals.cpp
lib/Analysis/SymbolManager.cpp

index eb519e0e7431a8e44a207b34beeefe64cf272aa8..689bebb450f44bc5991b06ef220db62bb3575ff5 100644 (file)
@@ -45,7 +45,7 @@ public:
   virtual const GRState *RemoveDeadBindings(const GRState *state,
                                             SymbolReaper& SymReaper) = 0;
 
-  virtual void print(const GRState *state, std::ostream& Out, 
+  virtual void print(const GRState *state, llvm::raw_ostream& Out, 
                      const char* nl, const char *sep) = 0;
 
   virtual void EndPath(const GRState *state) {}
index 3278e0cffe590b3314915b36be6b26e54b19ee14..4fea4a18c9c9118aa1df56de2e2bffdc8d68aa2c 100644 (file)
@@ -34,7 +34,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/Streams.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include <functional>
 
@@ -326,17 +326,17 @@ public:
   class Printer {
   public:
     virtual ~Printer() {}
-    virtual void Print(std::ostream& Out, const GRState* state,
+    virtual void Print(llvm::raw_ostream& Out, const GRState* state,
                        const char* nl, const char* sep) = 0;
   };
   
   // Pretty-printing.
-  void print(std::ostream& Out, const char *nl = "\n",
+  void print(llvm::raw_ostream& Out, const char *nl = "\n",
              const char *sep = "") const;  
 
   void printStdErr() const; 
   
-  void printDOT(std::ostream& Out) const;  
+  void printDOT(llvm::raw_ostream& Out) const;  
   
   // Tags used for the Generic Data Map.
   struct NullDerefTag {
index de74dbdb17b06c89e46b73e4152dfc8b26243161..e553940470b91f0bd1ce486639c53e087f294485 100644 (file)
@@ -111,7 +111,6 @@ public:
   ///  return that expression.  Otherwise return NULL.
   const SymExpr *getAsSymbolicExpression() const;
   
-  void print(std::ostream& OS) const;
   void print(llvm::raw_ostream& OS) const;
   void printStdErr() const;
 
index 0c5df2e98e17baf28550770667f08571f58de6bf..cbe0b3c83591994d6d5301095075e859c288f6be 100644 (file)
@@ -21,7 +21,6 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include <iosfwd>
 
 namespace clang {
   
@@ -171,7 +170,7 @@ public:
     return state;
   }
 
-  virtual void print(Store store, std::ostream& Out,
+  virtual void print(Store store, llvm::raw_ostream& Out,
                      const char* nl, const char *sep) = 0;
       
   class BindingsHandler {
index d074e30333d4668574d871c995694d83fcaabc69..f32a7e3481dd22e211498c7d34f8bf4094b55b19 100644 (file)
@@ -328,9 +328,4 @@ namespace llvm {
   llvm::raw_ostream& operator<<(llvm::raw_ostream& Out,
                                 const clang::SymExpr *SE);
 }
-namespace std {
-  std::ostream& operator<<(std::ostream& Out,
-                           const clang::SymExpr *SE);
-}
-
 #endif
index ffa8a8625bdf41c204bf4b9256c58d5cf0aab270..cb89d30651079cb1e61a97bd6b9e05f31c124cfb 100644 (file)
@@ -83,7 +83,7 @@ public:
 
   const GRState* RemoveDeadBindings(const GRState* state, SymbolReaper& SymReaper);
 
-  void print(const GRState* state, std::ostream& Out, 
+  void print(const GRState* state, llvm::raw_ostream& Out, 
              const char* nl, const char *sep);
 };
 
@@ -280,7 +280,7 @@ BasicConstraintManager::RemoveDeadBindings(const GRState* state,
   return state->set<ConstNotEq>(CNE);
 }
 
-void BasicConstraintManager::print(const GRState* state, std::ostream& Out, 
+void BasicConstraintManager::print(const GRState* state, llvm::raw_ostream& Out, 
                                    const char* nl, const char *sep) {
   // Print equality constraints.
 
@@ -288,12 +288,8 @@ void BasicConstraintManager::print(const GRState* state, std::ostream& Out,
 
   if (!CE.isEmpty()) {
     Out << nl << sep << "'==' constraints:";
-
-    for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I) {
-      Out << nl << " $" << I.getKey();
-      llvm::raw_os_ostream OS(Out);
-      OS << " : "   << *I.getData();
-    }
+    for (ConstEqTy::iterator I = CE.begin(), E = CE.end(); I!=E; ++I)
+      Out << nl << " $" << I.getKey() << " : " << *I.getData();
   }
 
   // Print != constraints.
index e4ea260548775559aef69df3a591432b1a495253..8fbce528fa9a6f656417a2ca1fb2acd50abeb085 100644 (file)
@@ -112,7 +112,8 @@ public:
     return BindingsTy(static_cast<const BindingsTy::TreeTy*>(store));
   }
 
-  void print(Store store, std::ostream& Out, const char* nl, const char *sep);
+  void print(Store store, llvm::raw_ostream& Out, const char* nl,
+             const char *sep);
 
 private:
   ASTContext& getContext() { return StateMgr.getContext(); }
@@ -602,18 +603,19 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarDecl* VD,
   return store;
 }
 
-void BasicStoreManager::print(Store store, std::ostream& O,
+void BasicStoreManager::print(Store store, llvm::raw_ostream& Out,
                               const char* nl, const char *sep) {
       
-  llvm::raw_os_ostream Out(O);
   BindingsTy B = GetBindings(store);
   Out << "Variables:" << nl;
   
   bool isFirst = true;
   
   for (BindingsTy::iterator I=B.begin(), E=B.end(); I != E; ++I) {
-    if (isFirst) isFirst = false;
-    else Out << nl;
+    if (isFirst)
+      isFirst = false;
+    else
+      Out << nl;
     
     Out << ' ' << I.getKey() << " : ";
     I.getData().print(Out);
index d4d10cf5d15da0fa160557246b97d1b1f4ac90d4..5e542a3c48ad6adbd6dea3fb540fc4be2aa85741 100644 (file)
@@ -30,7 +30,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/ADT/STLExtras.h"
-#include <ostream>
 #include <stdarg.h>
 
 using namespace clang;
@@ -1674,10 +1673,10 @@ public:
     ID.Add(T);
   }
 
-  void print(std::ostream& Out) const;
+  void print(llvm::raw_ostream& Out) const;
 };
   
-void RefVal::print(std::ostream& Out) const {
+void RefVal::print(llvm::raw_ostream& Out) const {
   if (!T.isNull())
     Out << "Tracked Type:" << T.getAsString() << '\n';
     
@@ -1831,7 +1830,7 @@ class VISIBILITY_HIDDEN CFRefCount : public GRSimpleVals {
 public:
   class BindingsPrinter : public GRState::Printer {
   public:
-    virtual void Print(std::ostream& Out, const GRState* state,
+    virtual void Print(llvm::raw_ostream& Out, const GRState* state,
                        const char* nl, const char* sep);
   };
 
@@ -1959,7 +1958,8 @@ public:
 
 } // end anonymous namespace
 
-static void PrintPool(std::ostream &Out, SymbolRef Sym, const GRState *state) {
+static void PrintPool(llvm::raw_ostream &Out, SymbolRef Sym,
+                      const GRState *state) {
   Out << ' ';
   if (Sym)
     Out << Sym->getSymbolID();
@@ -1975,10 +1975,9 @@ static void PrintPool(std::ostream &Out, SymbolRef Sym, const GRState *state) {
   Out << '}';  
 }
 
-void CFRefCount::BindingsPrinter::Print(std::ostream& Out, const GRState* state,
+void CFRefCount::BindingsPrinter::Print(llvm::raw_ostream& Out,
+                                        const GRState* state,
                                         const char* nl, const char* sep) {
-  
-  
     
   RefBindings B = state->get<RefBindings>();
   
index 92c50e2a9185c7ab2642245c7a428c7b5f5f1252..21dc658dfa1a526d13ec78774292e8d1ca4e1c83 100644 (file)
@@ -20,7 +20,6 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/Basic/LangOptions.h"
-#include <sstream>
 
 using namespace clang;
 
@@ -97,8 +96,8 @@ void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) {
   // Find ivars that are unused.
   for (IvarUsageMap::iterator I = M.begin(), E = M.end(); I!=E; ++I)
     if (I->second == Unused) {
-      
-      std::ostringstream os;
+      std::string sbuf;
+      llvm::raw_string_ostream os(sbuf);
       os << "Instance variable '" << I->first->getNameAsString()
          << "' in class '" << ID->getNameAsString() 
          << "' is never used by the methods in its @implementation "
index 8266cdcbab75c285f6e686d9a2e9c301f57eadf7..d3df92df34f2ee5d394f53bfcebbac3c343daa3c 100644 (file)
@@ -3158,7 +3158,9 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
     
   static std::string getNodeLabel(const GRExprEngine::NodeTy* N, void*,
                                   bool ShortNames) {
-    std::ostringstream Out;
+    
+    std::string sbuf;
+    llvm::raw_string_ostream Out(sbuf);
 
     // Program Location.
     ProgramPoint Loc = N->getLocation();
@@ -3180,9 +3182,7 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
           SourceLocation SLoc = S->getLocStart();
 
           Out << S->getStmtClassName() << ' ' << (void*) S << ' ';        
-          llvm::raw_os_ostream OutS(Out);
-          S->printPretty(OutS);
-          OutS.flush();
+          S->printPretty(Out);
           
           if (SLoc.isFileID()) {        
             Out << "\\lline="
@@ -3236,10 +3236,7 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
           SourceLocation SLoc = T->getLocStart();
          
           Out << "\\|Terminator: ";
-          
-          llvm::raw_os_ostream OutS(Out);
-          E.getSrc()->printTerminator(OutS);
-          OutS.flush();
+          E.getSrc()->printTerminator(Out);
           
           if (SLoc.isFileID()) {
             Out << "\\lline="
@@ -3254,14 +3251,11 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> :
             if (Label) {                        
               if (CaseStmt* C = dyn_cast<CaseStmt>(Label)) {
                 Out << "\\lcase ";
-                llvm::raw_os_ostream OutS(Out);
-                C->getLHS()->printPretty(OutS);
-                OutS.flush();
+                C->getLHS()->printPretty(Out);
               
                 if (Stmt* RHS = C->getRHS()) {
                   Out << " .. ";
-                  RHS->printPretty(OutS);
-                  OutS.flush();
+                  RHS->printPretty(Out);
                 }
                 
                 Out << ":";
index 65db6a29c83d03ea5855c0e84e4d6964c1f4ec29..5ee4e6ff4b76c4c18c9d8d2fb12f3b9c90d5a046 100644 (file)
@@ -1,4 +1,4 @@
-//= GRState*cpp - Path-Sens. "State" for tracking valuues -----*- C++ -*--=//
+//= GRState.cpp - Path-Sensitive "State" for tracking values -----*- C++ -*--=//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines SymbolRef, ExprBindKey, and GRState*
+//  This file implements GRState and GRStateManager.
 //
 //===----------------------------------------------------------------------===//
 
@@ -20,6 +20,7 @@
 using namespace clang;
 
 // Give the vtable for ConstraintManager somewhere to live.
+// FIXME: Move this elsewhere.
 ConstraintManager::~ConstraintManager() {}
 
 GRStateManager::~GRStateManager() {
@@ -117,7 +118,8 @@ const GRState* GRState::makeWithStore(Store store) const {
 //  State pretty-printing.
 //===----------------------------------------------------------------------===//
 
-void GRState::print(std::ostream& Out, const char* nl, const char* sep) const {  
+void GRState::print(llvm::raw_ostream& Out, const char* nl,
+                    const char* sep) const {  
   // Print the store.
   Mgr->getStoreManager().print(getStore(), Out, nl, sep);
   
@@ -133,9 +135,7 @@ void GRState::print(std::ostream& Out, const char* nl, const char* sep) const {
     else { Out << nl; }
     
     Out << " (" << (void*) I.getKey() << ") ";
-    llvm::raw_os_ostream OutS(Out);
-    I.getKey()->printPretty(OutS);
-    OutS.flush();
+    I.getKey()->printPretty(Out);
     Out << " : ";
     I.getData().print(Out);
   }
@@ -152,9 +152,7 @@ void GRState::print(std::ostream& Out, const char* nl, const char* sep) const {
     else { Out << nl; }
     
     Out << " (" << (void*) I.getKey() << ") ";
-    llvm::raw_os_ostream OutS(Out);
-    I.getKey()->printPretty(OutS);
-    OutS.flush();
+    I.getKey()->printPretty(Out);
     Out << " : ";
     I.getData().print(Out);
   }
@@ -168,12 +166,12 @@ void GRState::print(std::ostream& Out, const char* nl, const char* sep) const {
   }
 }
 
-void GRState::printDOT(std::ostream& Out) const {
+void GRState::printDOT(llvm::raw_ostream& Out) const {
   print(Out, "\\l", "\\|");
 }
 
 void GRState::printStdErr() const {
-  print(*llvm::cerr);
+  print(llvm::errs());
 }
 
 //===----------------------------------------------------------------------===//
index 73c68bcaea033dc11826d1702eef670675b46244..079462e8d19f4e517bddf808751db4798abd4728 100644 (file)
@@ -200,7 +200,7 @@ public:
     return newRanges;
   }
 
-  void Print(std::ostream &os) const {
+  void print(llvm::raw_ostream &os) const {
     bool isFirst = true;
     os << "{ ";
     for (iterator i = begin(), e = end(); i != e; ++i) {
@@ -265,7 +265,7 @@ public:
 
   const GRState* RemoveDeadBindings(const GRState* St, SymbolReaper& SymReaper);
 
-  void print(const GRState* St, std::ostream& Out, 
+  void print(const GRState* St, llvm::raw_ostream& Out, 
              const char* nl, const char *sep);
 
 private:
@@ -341,7 +341,7 @@ AssumeX(GE)
 // Pretty-printing.
 //===------------------------------------------------------------------------===/
 
-void RangeConstraintManager::print(const GRState* St, std::ostream& Out, 
+void RangeConstraintManager::print(const GRState* St, llvm::raw_ostream& Out, 
                                    const char* nl, const char *sep) {
   
   ConstraintRangeTy Ranges = St->get<ConstraintRange>();
@@ -353,6 +353,6 @@ void RangeConstraintManager::print(const GRState* St, std::ostream& Out,
   
   for (ConstraintRangeTy::iterator I=Ranges.begin(), E=Ranges.end(); I!=E; ++I){
     Out << nl << ' ' << I.getKey() << " : ";
-    I.getData().Print(Out);
+    I.getData().print(Out);
   }
 }
index c9c923a5e33c389fedf13c350d3194d3e2ddc09c..65afe46bc094fa017842f591d8bb4f4c467362ba 100644 (file)
@@ -238,10 +238,8 @@ public:
   CastResult CastRegion(const GRState *state, const MemRegion* R,
                         QualType CastToTy);
 
-  SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,Loc L,NonLoc R);
-
-
-
+  SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op,Loc L,
+                 NonLoc R);
 
   Store getInitialStore() { return RBFactory.GetEmptyMap().getRoot(); }
   
@@ -260,8 +258,6 @@ public:
     
     return SelfRegion;
   }
-  
-
  
   //===-------------------------------------------------------------------===//
   // Binding values to regions.
@@ -352,7 +348,8 @@ public:
    return RegionBindingsTy(static_cast<const RegionBindingsTy::TreeTy*>(store));
   }
 
-  void print(Store store, std::ostream& Out, const char* nl, const char *sep);
+  void print(Store store, llvm::raw_ostream& Out, const char* nl,
+             const char *sep);
 
   void iterBindings(Store store, BindingsHandler& f) {
     // FIXME: Implement.
@@ -1423,9 +1420,8 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc,
 // Utility methods.
 //===----------------------------------------------------------------------===//
 
-void RegionStoreManager::print(Store store, std::ostream& Out, 
+void RegionStoreManager::print(Store store, llvm::raw_ostream& OS,
                                const char* nl, const char *sep) {
-  llvm::raw_os_ostream OS(Out);
   RegionBindingsTy B = GetRegionBindings(store);
   OS << "Store:" << nl;
   
index dd9490bebb9605a033f4769d250c160087967a48..a69b611cc3d810c1a26b92609849e9cbcf4b17c5 100644 (file)
@@ -242,11 +242,6 @@ SVal loc::ConcreteInt::EvalBinOp(BasicValueFactory& BasicVals,
 
 void SVal::printStdErr() const { print(llvm::errs()); }
 
-void SVal::print(std::ostream& Out) const {
-  llvm::raw_os_ostream out(Out);
-  print(out);
-}
-
 void SVal::print(llvm::raw_ostream& Out) const {
 
   switch (getBaseKind()) {
index 4e38a3492c79a7e83f4f103c329988a185774166..275f30a2963e0ea3bbf13b02b4026e5d8090edcd 100644 (file)
@@ -85,12 +85,6 @@ llvm::raw_ostream& llvm::operator<<(llvm::raw_ostream& os, const SymExpr *SE) {
   return os;
 }
 
-std::ostream& std::operator<<(std::ostream& os, const SymExpr *SE) {
-  llvm::raw_os_ostream O(os);
-  print(O, SE);
-  return os;
-}
-
 const SymbolRegionValue* 
 SymbolManager::getRegionValueSymbol(const MemRegion* R, QualType T) {
   llvm::FoldingSetNodeID profile;