[cfe-commits] r56185 - in /cfe/trunk: Driver/ASTConsumers.cpp Driver/ASTConsumers.h Driver/RewriteMacros.cpp Driver/RewriteObjC.cpp Driver/SerializationTest.cpp include/clang/AST/CFG.h include/clang/AST/PrettyPrinter.h include/clang/AST/Stmt.h lib/AST/CFG.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtViz.cpp lib/AST/Type.cpp lib/Analysis/GRExprEngine.cpp lib/Analysis/GRState.cpp lib/Driver/HTMLDiagnostics.cpp lib/Rewrite/HTMLRewrite.cpp lib/Rewrite/Rewriter.cpp

Ted Kremenek kremenek at apple.com
Fri Sep 12 22:17:59 PDT 2008


My comment was slightly incorrect: this patch clearly touches  
libAnalysis.

On Sep 12, 2008, at 10:16 PM, Ted Kremenek wrote:

> Author: kremenek
> Date: Sat Sep 13 00:16:45 2008
> New Revision: 56185
>
> URL: http://llvm.org/viewvc/llvm-project?rev=56185&view=rev
> Log:
> Patch by Csaba Hruska!
>
> "Here is a patch what replaces std::ostream with llvm::raw_ostream.  
> This patch
> covers the AST library, but ignores Analysis lib."
>
> Modified:
>    cfe/trunk/Driver/ASTConsumers.cpp
>    cfe/trunk/Driver/ASTConsumers.h
>    cfe/trunk/Driver/RewriteMacros.cpp
>    cfe/trunk/Driver/RewriteObjC.cpp
>    cfe/trunk/Driver/SerializationTest.cpp
>    cfe/trunk/include/clang/AST/CFG.h
>    cfe/trunk/include/clang/AST/PrettyPrinter.h
>    cfe/trunk/include/clang/AST/Stmt.h
>    cfe/trunk/lib/AST/CFG.cpp
>    cfe/trunk/lib/AST/StmtPrinter.cpp
>    cfe/trunk/lib/AST/StmtViz.cpp
>    cfe/trunk/lib/AST/Type.cpp
>    cfe/trunk/lib/Analysis/GRExprEngine.cpp
>    cfe/trunk/lib/Analysis/GRState.cpp
>    cfe/trunk/lib/Driver/HTMLDiagnostics.cpp
>    cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
>    cfe/trunk/lib/Rewrite/Rewriter.cpp
>
> Modified: cfe/trunk/Driver/ASTConsumers.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/Driver/ASTConsumers.cpp (original)
> +++ cfe/trunk/Driver/ASTConsumers.cpp Sat Sep 13 00:16:45 2008
> @@ -24,6 +24,7 @@
> #include "llvm/Bitcode/ReaderWriter.h"
> #include "llvm/Support/Streams.h"
> #include "llvm/Support/Timer.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "llvm/ADT/OwningPtr.h"
> #include <fstream>
>
> @@ -35,10 +36,11 @@
> namespace {
>   class DeclPrinter {
>   public:
> -    std::ostream& Out;
> +    llvm::raw_ostream& Out;
>
> -    DeclPrinter(std::ostream* out) : Out(out ? *out :  
> *llvm::cerr.stream()) {}
> -    DeclPrinter() : Out(*llvm::cerr.stream()) {}
> +    DeclPrinter(llvm::raw_ostream* out) : Out(out ? *out :  
> llvm::errs()) {}
> +    DeclPrinter() : Out(llvm::errs()) {}
> +    virtual ~DeclPrinter();
>
>     void PrintDecl(Decl *D);
>     void PrintFunctionDeclStart(FunctionDecl *FD);
> @@ -56,6 +58,10 @@
>   };
> } // end anonymous namespace
>
> +DeclPrinter::~DeclPrinter() {
> +  Out.flush();
> +}
> +
> void DeclPrinter:: PrintDecl(Decl *D) {
>   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
>     PrintFunctionDeclStart(FD);
> @@ -422,7 +428,7 @@
> namespace {
>   class ASTPrinter : public ASTConsumer, public DeclPrinter {
>   public:
> -    ASTPrinter(std::ostream* o = NULL) : DeclPrinter(o) {}
> +    ASTPrinter(llvm::raw_ostream* o = NULL) : DeclPrinter(o) {}
>
>     virtual void HandleTopLevelDecl(Decl *D) {
>       PrintDecl(D);
> @@ -430,7 +436,7 @@
>   };
> }
>
> -ASTConsumer *clang::CreateASTPrinter(std::ostream* out) {
> +ASTConsumer *clang::CreateASTPrinter(llvm::raw_ostream* out) {
>   return new ASTPrinter(out);
> }
>
>
> Modified: cfe/trunk/Driver/ASTConsumers.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/Driver/ASTConsumers.h (original)
> +++ cfe/trunk/Driver/ASTConsumers.h Sat Sep 13 00:16:45 2008
> @@ -14,6 +14,7 @@
> #ifndef DRIVER_ASTCONSUMERS_H
> #define DRIVER_ASTCONSUMERS_H
>
> +#include "llvm/Support/raw_ostream.h"
> #include <string>
> #include <iosfwd>
>
> @@ -30,7 +31,7 @@
> class Preprocessor;
> class PreprocessorFactory;
>
> -ASTConsumer *CreateASTPrinter(std::ostream* OS = NULL);
> +ASTConsumer *CreateASTPrinter(llvm::raw_ostream* OS = NULL);
>
> ASTConsumer *CreateASTDumper();
>
>
> Modified: cfe/trunk/Driver/RewriteMacros.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteMacros.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/Driver/RewriteMacros.cpp (original)
> +++ cfe/trunk/Driver/RewriteMacros.cpp Sat Sep 13 00:16:45 2008
> @@ -17,8 +17,9 @@
> #include "clang/Lex/Preprocessor.h"
> #include "clang/Basic/SourceManager.h"
> #include "llvm/Support/Streams.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "llvm/System/Path.h"
> -#include <fstream>
> +#include "llvm/ADT/OwningPtr.h"
> using namespace clang;
>
> /// isSameToken - Return true if the two specified tokens start have  
> the same
> @@ -205,20 +206,23 @@
>   }
>
>   // Create the output file.
> -  std::ostream *OutFile;
> +  llvm::OwningPtr<llvm::raw_ostream> OwnedStream;
> +  llvm::raw_ostream *OutFile;
>   if (OutFileName == "-") {
> -    OutFile = llvm::cout.stream();
> +    OutFile = &llvm::outs();
>   } else if (!OutFileName.empty()) {
> -    OutFile = new std::ofstream(OutFileName.c_str(),
> -                                std::ios_base::binary| 
> std::ios_base::out);
> +    std::string Err;
> +    OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), Err);
> +    OwnedStream.reset(OutFile);
>   } else if (InFileName == "-") {
> -    OutFile = llvm::cout.stream();
> +    OutFile = &llvm::outs();
>   } else {
>     llvm::sys::Path Path(InFileName);
>     Path.eraseSuffix();
>     Path.appendSuffix("cpp");
> -    OutFile = new std::ofstream(Path.toString().c_str(),
> -                                std::ios_base::binary| 
> std::ios_base::out);
> +    std::string Err;
> +    OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), Err);
> +    OwnedStream.reset(OutFile);
>   }
>
>   // Get the buffer corresponding to MainFileID.  If we haven't  
> changed it, then
> @@ -230,4 +234,5 @@
>   } else {
>     fprintf(stderr, "No changes\n");
>   }
> +  OutFile->flush();
> }
>
> Modified: cfe/trunk/Driver/RewriteObjC.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/Driver/RewriteObjC.cpp (original)
> +++ cfe/trunk/Driver/RewriteObjC.cpp Sat Sep 13 00:16:45 2008
> @@ -22,12 +22,12 @@
> #include "clang/Lex/Lexer.h"
> #include "llvm/ADT/StringExtras.h"
> #include "llvm/ADT/SmallPtrSet.h"
> +#include "llvm/ADT/OwningPtr.h"
> #include "llvm/Support/MemoryBuffer.h"
> #include "llvm/Support/CommandLine.h"
> #include "llvm/Support/Streams.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "llvm/System/Path.h"
> -#include <sstream>
> -#include <fstream>
> using namespace clang;
> using llvm::utostr;
>
> @@ -453,20 +453,23 @@
>
>   // Create the output file.
>
> -  std::ostream *OutFile;
> +  llvm::OwningPtr<llvm::raw_ostream> OwnedStream;
> +  llvm::raw_ostream *OutFile;
>   if (OutFileName == "-") {
> -    OutFile = llvm::cout.stream();
> +    OutFile = &llvm::outs();
>   } else if (!OutFileName.empty()) {
> -    OutFile = new std::ofstream(OutFileName.c_str(),
> -                                std::ios_base::binary| 
> std::ios_base::out);
> +    std::string Err;
> +    OutFile = new llvm::raw_fd_ostream(OutFileName.c_str(), Err);
> +    OwnedStream.reset(OutFile);
>   } else if (InFileName == "-") {
> -    OutFile = llvm::cout.stream();
> +    OutFile = &llvm::outs();
>   } else {
>     llvm::sys::Path Path(InFileName);
>     Path.eraseSuffix();
>     Path.appendSuffix("cpp");
> -    OutFile = new std::ofstream(Path.toString().c_str(),
> -                                std::ios_base::binary| 
> std::ios_base::out);
> +    std::string Err;
> +    OutFile = new llvm::raw_fd_ostream(Path.toString().c_str(), Err);
> +    OwnedStream.reset(OutFile);
>   }
>
>   RewriteInclude();
> @@ -489,6 +492,7 @@
>   }
>   // Emit metadata.
>   *OutFile << ResultStr;
> +  OutFile->flush();
> }
>
> // 
> = 
> = 
> = 
> ----------------------------------------------------------------------= 
> ==//
> @@ -1040,7 +1044,8 @@
>   if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
>     CastExpr *Replacement = new CastExpr(ICE->getType(), ICE- 
> >getSubExpr(), SourceLocation());
>     // Get the new text.
> -    std::ostringstream Buf;
> +    std::string SStr;
> +    llvm::raw_string_ostream Buf(SStr);
>     Replacement->printPretty(Buf);
>     const std::string &Str = Buf.str();
>
> @@ -1333,7 +1338,8 @@
>   buf += "  objc_sync_exit(";
>   Expr *syncExpr = new ExplicitCastExpr(Context->getObjCIdType(),
>                                         S->getSynchExpr(),  
> SourceLocation());
> -  std::ostringstream syncExprBuf;
> +  std::string syncExprBufS;
> +  llvm::raw_string_ostream syncExprBuf(syncExprBufS);
>   syncExpr->printPretty(syncExprBuf);
>   buf += syncExprBuf.str();
>   buf += ");\n";
> @@ -1942,7 +1948,8 @@
>   Preamble += " __attribute__ ((section (\"__DATA, __cfstring\"))) =  
> {__CFConstantStringClassReference,";
>   Preamble += "0x000007c8,"; // utf8_str
>   // The pretty printer for StringLiteral handles escape characters  
> properly.
> -  std::ostringstream prettyBuf;
> +  std::string prettyBufS;
> +  llvm::raw_string_ostream prettyBuf(prettyBufS);
>   Exp->getString()->printPretty(prettyBuf);
>   Preamble += prettyBuf.str();
>   Preamble += ",";
>
> Modified: cfe/trunk/Driver/SerializationTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/SerializationTest.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/Driver/SerializationTest.cpp (original)
> +++ cfe/trunk/Driver/SerializationTest.cpp Sat Sep 13 00:16:45 2008
> @@ -64,8 +64,9 @@
>                                   TranslationUnit& TU) {
>   {
>     // Pretty-print the decls to a temp file.
> -    std::ofstream DeclPP(FNameDeclPrint.c_str());
> -    assert (DeclPP && "Could not open file for printing out decls.");
> +    std::string Err;
> +    llvm::raw_fd_ostream DeclPP(FNameDeclPrint.c_str(), Err);
> +    assert (Err.empty() && "Could not open file for printing out  
> decls.");
>     llvm::OwningPtr<ASTConsumer>  
> FilePrinter(CreateASTPrinter(&DeclPP));
>
>     for (TranslationUnit::iterator I=TU.begin(), E=TU.end(); I!=E; + 
> +I)
> @@ -87,8 +88,9 @@
>
>   {
>     // Pretty-print the deserialized decls to a temp file.
> -    std::ofstream DeclPP(FNameDeclPrint.c_str());
> -    assert (DeclPP && "Could not open file for printing out decls.");
> +    std::string Err;
> +    llvm::raw_fd_ostream DeclPP(FNameDeclPrint.c_str(), Err);
> +    assert (Err.empty() && "Could not open file for printing out  
> decls.");
>     llvm::OwningPtr<ASTConsumer>  
> FilePrinter(CreateASTPrinter(&DeclPP));
>
>     for (TranslationUnit::iterator I=NewTU->begin(), E=NewTU->end();  
> I!=E; ++I)
>
> Modified: cfe/trunk/include/clang/AST/CFG.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CFG.h?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/AST/CFG.h (original)
> +++ cfe/trunk/include/clang/AST/CFG.h Sat Sep 13 00:16:45 2008
> @@ -17,9 +17,9 @@
>
> #include "llvm/ADT/GraphTraits.h"
> #include "llvm/Support/Allocator.h"
> +#include "llvm/Support/raw_ostream.h"
> #include <list>
> #include <vector>
> -#include <iosfwd>
> #include <cassert>
>
> namespace clang {
> @@ -174,8 +174,8 @@
>   unsigned getBlockID() const { return BlockID; }
>
>   void dump(const CFG* cfg) const;
> -  void print(std::ostream& OS, const CFG* cfg) const;
> -  void printTerminator(std::ostream& OS) const;
> +  void print(llvm::raw_ostream& OS, const CFG* cfg) const;
> +  void printTerminator(llvm::raw_ostream& OS) const;
> };
>
>
> @@ -276,7 +276,7 @@
>   // 
> = 
> = 
> =-------------------------------------------------------------------- 
> ===//
>
>   void viewCFG() const;
> -  void print(std::ostream& OS) const;
> +  void print(llvm::raw_ostream& OS) const;
>   void dump() const;
>
>   // 
> = 
> = 
> =-------------------------------------------------------------------- 
> ===//
>
> Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
> +++ cfe/trunk/include/clang/AST/PrettyPrinter.h Sat Sep 13 00:16:45  
> 2008
> @@ -14,7 +14,7 @@
> #ifndef LLVM_CLANG_AST_PRETTY_PRINTER_H
> #define LLVM_CLANG_AST_PRETTY_PRINTER_H
>
> -#include <iosfwd>
> +#include "llvm/Support/raw_ostream.h"
>
> namespace clang {
>
> @@ -23,7 +23,7 @@
> class PrinterHelper {
> public:
>   virtual ~PrinterHelper();
> -  virtual bool handledStmt(Stmt* E, std::ostream& OS) = 0;
> +  virtual bool handledStmt(Stmt* E, llvm::raw_ostream& OS) = 0;
> };
>
> } // end namespace clang
>
> Modified: cfe/trunk/include/clang/AST/Stmt.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/include/clang/AST/Stmt.h (original)
> +++ cfe/trunk/include/clang/AST/Stmt.h Sat Sep 13 00:16:45 2008
> @@ -15,12 +15,12 @@
> #define LLVM_CLANG_AST_STMT_H
>
> #include "llvm/Support/Casting.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "clang/Basic/SourceLocation.h"
> #include "clang/AST/StmtIterator.h"
> #include "llvm/ADT/SmallVector.h"
> #include "llvm/ADT/iterator.h"
> #include "llvm/Bitcode/SerializationFwd.h"
> -#include <iosfwd>
> #include <string>
>
> using llvm::dyn_cast_or_null;
> @@ -92,7 +92,7 @@
>   /// dumpPretty/printPretty - These two methods do a "pretty print"  
> of the AST
>   /// back to its original source language syntax.
>   void dumpPretty() const;
> -  void printPretty(std::ostream &OS, PrinterHelper* = NULL) const;
> +  void printPretty(llvm::raw_ostream &OS, PrinterHelper* = NULL)  
> const;
>
>   /// viewAST - Visualize an AST rooted at this Stmt* using  
> GraphViz.  Only
>   ///   works on systems with GraphViz (Mac OS X) or dot+gv installed.
>
> Modified: cfe/trunk/lib/AST/CFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CFG.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/AST/CFG.cpp (original)
> +++ cfe/trunk/lib/AST/CFG.cpp Sat Sep 13 00:16:45 2008
> @@ -21,6 +21,7 @@
> #include "llvm/Support/Streams.h"
> #include "llvm/Support/Compiler.h"
> #include <llvm/Support/Allocator.h>
> +#include <llvm/Support/Format.h>
> #include <iomanip>
> #include <algorithm>
> #include <sstream>
> @@ -1306,7 +1307,7 @@
>   void setBlockID(signed i) { CurrentBlock = i; }
>   void setStmtID(unsigned i) { CurrentStmt = i; }
>
> -  virtual bool handledStmt(Stmt* Terminator, std::ostream& OS) {
> +  virtual bool handledStmt(Stmt* Terminator, llvm::raw_ostream& OS) {
>
>     StmtMapTy::iterator I = StmtMap.find(Terminator);
>
> @@ -1325,10 +1326,10 @@
> class VISIBILITY_HIDDEN CFGBlockTerminatorPrint
>   : public StmtVisitor<CFGBlockTerminatorPrint,void> {
>
> -  std::ostream& OS;
> +  llvm::raw_ostream& OS;
>   StmtPrinterHelper* Helper;
> public:
> -  CFGBlockTerminatorPrint(std::ostream& os, StmtPrinterHelper*  
> helper)
> +  CFGBlockTerminatorPrint(llvm::raw_ostream& os, StmtPrinterHelper*  
> helper)
>     : OS(os), Helper(helper) {}
>
>   void VisitIfStmt(IfStmt* I) {
> @@ -1406,7 +1407,7 @@
> };
>
>
> -void print_stmt(std::ostream&OS, StmtPrinterHelper* Helper, Stmt*  
> Terminator) {
> +void print_stmt(llvm::raw_ostream&OS, StmtPrinterHelper* Helper,  
> Stmt* Terminator) {
>   if (Helper) {
>     // special printing for statement-expressions.
>     if (StmtExpr* SE = dyn_cast<StmtExpr>(Terminator)) {
> @@ -1437,7 +1438,7 @@
>   if (isa<Expr>(Terminator)) OS << '\n';
> }
>
> -void print_block(std::ostream& OS, const CFG* cfg, const CFGBlock& B,
> +void print_block(llvm::raw_ostream& OS, const CFG* cfg, const  
> CFGBlock& B,
>                  StmtPrinterHelper* Helper, bool print_edges) {
>
>   if (Helper) Helper->setBlockID(B.getBlockID());
> @@ -1488,7 +1489,7 @@
>     if (print_edges)
>       OS << "    ";
>
> -    OS << std::setw(3) << j << ": ";
> +    OS << llvm::format("%3d", j) << ": ";
>
>     if (Helper)
>       Helper->setStmtID(j);
> @@ -1546,10 +1547,10 @@
> } // end anonymous namespace
>
> /// dump - A simple pretty printer of a CFG that outputs to stderr.
> -void CFG::dump() const { print(*llvm::cerr.stream()); }
> +void CFG::dump() const { print(llvm::errs()); }
>
> /// print - A simple pretty printer of a CFG that outputs to an  
> ostream.
> -void CFG::print(std::ostream& OS) const {
> +void CFG::print(llvm::raw_ostream& OS) const {
>
>   StmtPrinterHelper Helper(this);
>
> @@ -1570,17 +1571,17 @@
> }
>
> /// dump - A simply pretty printer of a CFGBlock that outputs to  
> stderr.
> -void CFGBlock::dump(const CFG* cfg) const  
> { print(*llvm::cerr.stream(), cfg); }
> +void CFGBlock::dump(const CFG* cfg) const { print(llvm::errs(),  
> cfg); }
>
> /// print - A simple pretty printer of a CFGBlock that outputs to an  
> ostream.
> ///   Generally this will only be called from CFG::print.
> -void CFGBlock::print(std::ostream& OS, const CFG* cfg) const {
> +void CFGBlock::print(llvm::raw_ostream& OS, const CFG* cfg) const {
>   StmtPrinterHelper Helper(cfg);
>   print_block(OS, cfg, *this, &Helper, true);
> }
>
> /// printTerminator - A simple pretty printer of the terminator of a  
> CFGBlock.
> -void CFGBlock::printTerminator(std::ostream& OS) const {
> +void CFGBlock::printTerminator(llvm::raw_ostream& OS) const {
>   CFGBlockTerminatorPrint TPrinter(OS,NULL);
>   TPrinter.Visit(const_cast<Stmt*>(getTerminator()));
> }
> @@ -1685,9 +1686,10 @@
>   static std::string getNodeLabel(const CFGBlock* Node, const CFG*  
> Graph) {
>
> #ifndef NDEBUG
> -    std::ostringstream Out;
> +    std::string OutSStr;
> +    llvm::raw_string_ostream Out(OutSStr);
>     print_block(Out,Graph, *Node, GraphHelper, false);
> -    std::string OutStr = Out.str();
> +    std::string& OutStr = Out.str();
>
>     if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
>
>
> Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
> +++ cfe/trunk/lib/AST/StmtPrinter.cpp Sat Sep 13 00:16:45 2008
> @@ -17,6 +17,7 @@
> #include "clang/AST/PrettyPrinter.h"
> #include "llvm/Support/Compiler.h"
> #include "llvm/Support/Streams.h"
> +#include "llvm/Support/Format.h"
> using namespace clang;
>
> // 
> = 
> = 
> = 
> ----------------------------------------------------------------------= 
> ==//
> @@ -25,11 +26,11 @@
>
> namespace  {
>   class VISIBILITY_HIDDEN StmtPrinter : public  
> StmtVisitor<StmtPrinter> {
> -    std::ostream &OS;
> +    llvm::raw_ostream &OS;
>     unsigned IndentLevel;
>     clang::PrinterHelper* Helper;
>   public:
> -    StmtPrinter(std::ostream &os, PrinterHelper* helper) :
> +    StmtPrinter(llvm::raw_ostream &os, PrinterHelper* helper) :
>       OS(os), IndentLevel(0), Helper(helper) {}
>
>     void PrintStmt(Stmt *S, int SubIndent = 1) {
> @@ -58,7 +59,7 @@
>         OS << "<null expr>";
>     }
>
> -    std::ostream &Indent(int Delta = 0) const {
> +    llvm::raw_ostream &Indent(int Delta = 0) const {
>       for (int i = 0, e = IndentLevel+Delta; i < e; ++i)
>         OS << "  ";
>       return OS;
> @@ -547,7 +548,7 @@
>     if (value < 256 && isprint(value)) {
>       OS << "'" << (char)value << "'";
>     } else if (value < 256) {
> -      OS << "'\\x" << std::hex << value << std::dec << "'";
> +      OS << "'\\x" << llvm::format("%x", value) << "'";
>     } else {
>       // FIXME what to really do here?
>       OS << value;
> @@ -924,10 +925,10 @@
> // 
> = 
> = 
> = 
> ----------------------------------------------------------------------= 
> ==//
>
> void Stmt::dumpPretty() const {
> -  printPretty(*llvm::cerr.stream());
> +  printPretty(llvm::errs());
> }
>
> -void Stmt::printPretty(std::ostream &OS, PrinterHelper* Helper)  
> const {
> +void Stmt::printPretty(llvm::raw_ostream &OS, PrinterHelper*  
> Helper) const {
>   if (this == 0) {
>     OS << "<NULL>";
>     return;
>
> Modified: cfe/trunk/lib/AST/StmtViz.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtViz.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/AST/StmtViz.cpp (original)
> +++ cfe/trunk/lib/AST/StmtViz.cpp Sat Sep 13 00:16:45 2008
> @@ -33,7 +33,8 @@
>   static std::string getNodeLabel(const Stmt* Node, const Stmt*  
> Graph) {
>
> #ifndef NDEBUG
> -    std::ostringstream Out;
> +    std::string OutSStr;
> +    llvm::raw_string_ostream Out(OutSStr);
>
>     if (Node)
>       Out << Node->getStmtClassName();
>
> Modified: cfe/trunk/lib/AST/Type.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/AST/Type.cpp (original)
> +++ cfe/trunk/lib/AST/Type.cpp Sat Sep 13 00:16:45 2008
> @@ -910,7 +910,8 @@
>     S += '*';
>
>   if (getSizeExpr()) {
> -    std::ostringstream s;
> +    std::string SStr;
> +    llvm::raw_string_ostream s(SStr);
>     getSizeExpr()->printPretty(s);
>     S += s.str();
>   }
> @@ -937,7 +938,8 @@
> void TypeOfExpr::getAsStringInternal(std::string &InnerString) const {
>   if (!InnerString.empty())    // Prefix the basic type, e.g.  
> 'typeof(e) X'.
>     InnerString = ' ' + InnerString;
> -  std::ostringstream s;
> +  std::string Str;
> +  llvm::raw_string_ostream s(Str);
>   getUnderlyingExpr()->printPretty(s);
>   InnerString = "typeof(" + s.str() + ")" + InnerString;
> }
>
> Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
> +++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Sat Sep 13 00:16:45 2008
> @@ -19,6 +19,7 @@
> #include "llvm/Support/Streams.h"
> #include "llvm/ADT/ImmutableList.h"
> #include "llvm/Support/Compiler.h"
> +#include "llvm/Support/raw_ostream.h"
>
> #ifndef NDEBUG
> #include "llvm/Support/GraphWriter.h"
> @@ -2194,7 +2195,9 @@
>         SourceLocation SLoc = S->getLocStart();
>
>         Out << S->getStmtClassName() << ' ' << (void*) S << ' ';
> -        S->printPretty(Out);
> +        llvm::raw_os_ostream OutS(Out);
> +        S->printPretty(OutS);
> +        OutS.flush();
>
>         if (SLoc.isFileID()) {
>           Out << "\\lline="
> @@ -2237,7 +2240,9 @@
>
>           Out << "\\|Terminator: ";
>
> -          E.getSrc()->printTerminator(Out);
> +          llvm::raw_os_ostream OutS(Out);
> +          E.getSrc()->printTerminator(OutS);
> +          OutS.flush();
>
>           if (SLoc.isFileID()) {
>             Out << "\\lline="
> @@ -2251,11 +2256,14 @@
>             if (Label) {
>               if (CaseStmt* C = dyn_cast<CaseStmt>(Label)) {
>                 Out << "\\lcase ";
> -                C->getLHS()->printPretty(Out);
> -
> +                llvm::raw_os_ostream OutS(Out);
> +                C->getLHS()->printPretty(OutS);
> +                OutS.flush();
> +
>                 if (Stmt* RHS = C->getRHS()) {
>                   Out << " .. ";
> -                  RHS->printPretty(Out);
> +                  RHS->printPretty(OutS);
> +                  OutS.flush();
>                 }
>
>                 Out << ":";
>
> Modified: cfe/trunk/lib/Analysis/GRState.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRState.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Analysis/GRState.cpp (original)
> +++ cfe/trunk/lib/Analysis/GRState.cpp Sat Sep 13 00:16:45 2008
> @@ -154,7 +154,9 @@
>     else { Out << nl; }
>
>     Out << " (" << (void*) I.getKey() << ") ";
> -    I.getKey()->printPretty(Out);
> +    llvm::raw_os_ostream OutS(Out);
> +    I.getKey()->printPretty(OutS);
> +    OutS.flush();
>     Out << " : ";
>     I.getData().print(Out);
>   }
> @@ -171,7 +173,9 @@
>     else { Out << nl; }
>
>     Out << " (" << (void*) I.getKey() << ") ";
> -    I.getKey()->printPretty(Out);
> +    llvm::raw_os_ostream OutS(Out);
> +    I.getKey()->printPretty(OutS);
> +    OutS.flush();
>     Out << " : ";
>     I.getData().print(Out);
>   }
>
> Modified: cfe/trunk/lib/Driver/HTMLDiagnostics.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HTMLDiagnostics.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Driver/HTMLDiagnostics.cpp (original)
> +++ cfe/trunk/lib/Driver/HTMLDiagnostics.cpp Sat Sep 13 00:16:45 2008
> @@ -23,9 +23,9 @@
> #include "llvm/Support/Compiler.h"
> #include "llvm/Support/MemoryBuffer.h"
> #include "llvm/Support/Streams.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "llvm/System/Path.h"
> #include <fstream>
> -#include <sstream>
>
> using namespace clang;
>
> @@ -220,7 +220,8 @@
>   // Add the name of the file as an <h1> tag.
>
>   {
> -    std::ostringstream os;
> +    std::string s;
> +    llvm::raw_string_ostream os(s);
>
>     os << "<h3>Bug Summary</h3>\n<table class=\"simpletable\">\n"
>           "<tr><td class=\"rowname\">File:</td><td>"
> @@ -252,26 +253,30 @@
>   const std::string& BugDesc = D.getDescription();
>
>   if (!BugDesc.empty()) {
> -    std::ostringstream os;
> +    std::string s;
> +    llvm::raw_string_ostream os(s);
>     os << "\n<!-- BUGDESC " << BugDesc << " -->\n";
>     R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0),  
> os.str());
>   }
>
>   {
> -    std::ostringstream os;
> +    std::string s;
> +    llvm::raw_string_ostream os(s);
>     os << "\n<!-- BUGFILE " << DirName << Entry->getName() << " --> 
> \n";
>     R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0),  
> os.str());
>   }
>
>   {
> -    std::ostringstream os;
> +    std::string s;
> +    llvm::raw_string_ostream os(s);
>     os << "\n<!-- BUGLINE " << D.back()- 
> >getLocation().getLogicalLineNumber()
>        << " -->\n";
>     R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0),  
> os.str());
>   }
>
>   {
> -    std::ostringstream os;
> +    std::string s;
> +    llvm::raw_string_ostream os(s);
>     os << "\n<!-- BUGPATHLENGTH " << D.size() << " -->\n";
>     R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0),  
> os.str());
>   }
> @@ -365,7 +370,8 @@
>
>   // Create the html for the message.
>
> -  std::ostringstream os;
> +  std::string s;
> +  llvm::raw_string_ostream os(s);
>
>   os << "\n<tr><td class=\"num\"></td><td class=\"line\">"
>      << "<div id=\"";
>
> Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
> +++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Sat Sep 13 00:16:45 2008
> @@ -20,7 +20,7 @@
> #include "llvm/ADT/SmallString.h"
> #include "llvm/ADT/OwningPtr.h"
> #include "llvm/Support/MemoryBuffer.h"
> -#include <sstream>
> +#include "llvm/Support/raw_ostream.h"
> using namespace clang;
>
>
> @@ -161,7 +161,8 @@
>                              bool ReplaceTabs) {
>
>   unsigned len = s.size();
> -  std::ostringstream os;
> +  std::string Str;
> +  llvm::raw_string_ostream os(Str);
>
>   for (unsigned i = 0 ; i < len; ++i) {
>
> @@ -272,7 +273,8 @@
>   SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0);
>   SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd- 
> FileStart);
>
> -  std::ostringstream os;
> +  std::string s;
> +  llvm::raw_string_ostream os(s);
>   os << "<!doctype html>\n" // Use HTML 5 doctype
>         "<html>\n<head>\n";
>
>
> Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=56185&r1=56184&r2=56185&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)
> +++ cfe/trunk/lib/Rewrite/Rewriter.cpp Sat Sep 13 00:16:45 2008
> @@ -16,7 +16,7 @@
> #include "clang/AST/Stmt.h"
> #include "clang/Lex/Lexer.h"
> #include "clang/Basic/SourceManager.h"
> -#include <sstream>
> +#include "llvm/Support/raw_ostream.h"
> using namespace clang;
>
> void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size) {
> @@ -166,7 +166,8 @@
>     return true;
>
>   // Get the new text.
> -  std::ostringstream S;
> +  std::string SStr;
> +  llvm::raw_string_ostream S(SStr);
>   To->printPretty(S);
>   const std::string &Str = S.str();
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list