diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/CFG.cpp | 28 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 13 | ||||
-rw-r--r-- | lib/AST/StmtViz.cpp | 3 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 6 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 18 | ||||
-rw-r--r-- | lib/Analysis/GRState.cpp | 8 | ||||
-rw-r--r-- | lib/Driver/HTMLDiagnostics.cpp | 20 | ||||
-rw-r--r-- | lib/Rewrite/HTMLRewrite.cpp | 8 | ||||
-rw-r--r-- | lib/Rewrite/Rewriter.cpp | 5 |
9 files changed, 68 insertions, 41 deletions
diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp index 84bf1e72a4..78c8dca423 100644 --- a/lib/AST/CFG.cpp +++ b/lib/AST/CFG.cpp @@ -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 @@ public: 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 @@ public: 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 @@ public: }; -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 @@ void print_stmt(std::ostream&OS, StmtPrinterHelper* Helper, Stmt* Terminator) { 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 @@ void print_block(std::ostream& OS, const CFG* cfg, const CFGBlock& B, if (print_edges) OS << " "; - OS << std::setw(3) << j << ": "; + OS << llvm::format("%3d", j) << ": "; if (Helper) Helper->setStmtID(j); @@ -1546,10 +1547,10 @@ void print_block(std::ostream& OS, const CFG* cfg, const CFGBlock& B, } // 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 @@ void CFG::print(std::ostream& OS) const { } /// 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 @@ struct DOTGraphTraits<const CFG*> : public DefaultDOTGraphTraits { 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()); diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 3c3e207a02..566ab717ea 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -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 @@ using namespace clang; 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 @@ namespace { 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 @@ void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) { 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 StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) { //===----------------------------------------------------------------------===// 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; diff --git a/lib/AST/StmtViz.cpp b/lib/AST/StmtViz.cpp index 51d514b20a..6790efbd56 100644 --- a/lib/AST/StmtViz.cpp +++ b/lib/AST/StmtViz.cpp @@ -33,7 +33,8 @@ struct DOTGraphTraits<const Stmt*> : public DefaultDOTGraphTraits { 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(); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 2ecc357d95..f836e5b995 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -910,7 +910,8 @@ void VariableArrayType::getAsStringInternal(std::string &S) const { 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 ExtVectorType::getAsStringInternal(std::string &S) const { 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; } diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 8af5a74f19..d8c0320d66 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -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 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> : 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 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> : 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 @@ struct VISIBILITY_HIDDEN DOTGraphTraits<GRExprEngine::NodeTy*> : 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 << ":"; diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp index 72eeda97b1..4bef72c6c5 100644 --- a/lib/Analysis/GRState.cpp +++ b/lib/Analysis/GRState.cpp @@ -154,7 +154,9 @@ void GRState::print(std::ostream& Out, StoreManager& StoreMgr, 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 @@ void GRState::print(std::ostream& Out, StoreManager& StoreMgr, 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); } diff --git a/lib/Driver/HTMLDiagnostics.cpp b/lib/Driver/HTMLDiagnostics.cpp index e691882098..5025e87e59 100644 --- a/lib/Driver/HTMLDiagnostics.cpp +++ b/lib/Driver/HTMLDiagnostics.cpp @@ -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 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { // 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 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { 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 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, unsigned BugFileID, // 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=\""; diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp index 43c04793f0..b411e568f6 100644 --- a/lib/Rewrite/HTMLRewrite.cpp +++ b/lib/Rewrite/HTMLRewrite.cpp @@ -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 @@ std::string html::EscapeText(const std::string& s, bool EscapeSpaces, 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 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID, 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"; diff --git a/lib/Rewrite/Rewriter.cpp b/lib/Rewrite/Rewriter.cpp index e1a6651a9a..f414e1c5f2 100644 --- a/lib/Rewrite/Rewriter.cpp +++ b/lib/Rewrite/Rewriter.cpp @@ -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 @@ bool Rewriter::ReplaceStmt(Stmt *From, Stmt *To) { 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(); |