From: Yaron Keren Date: Tue, 10 Mar 2015 07:33:23 +0000 (+0000) Subject: Teach raw_ostream to accept SmallString. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1acd90385d61d72b7ea25f193f77a9700414b637;p=clang Teach raw_ostream to accept SmallString. Saves adding .str() call to any raw_ostream << SmallString usage and a small step towards making .str() consistent in the ADTs by removing one of the SmallString::str() use cases, discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141013/240026.html I'll update the Phabricator patch http://reviews.llvm.org/D6372 for review of the Twine SmallString support, it's more complex than this one. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231763 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index b2a1b24a5f..140cdd8b15 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -1034,7 +1034,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, Str += llvm::utostr(AnonStructId); Out << Str.size(); - Out << Str.str(); + Out << Str; break; } diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 80ec3c45ce..d45143945f 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -1314,7 +1314,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { if (PLoc.isValid()) { FN += PLoc.getFilename(); Lexer::Stringify(FN); - OS << '"' << FN.str() << '"'; + OS << '"' << FN << '"'; } Tok.setKind(tok::string_literal); } else if (II == Ident__DATE__) { diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 6812b11912..621718e2d6 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -735,7 +735,7 @@ static std::unique_ptr CreateUbiViz() { SmallString<128> P; int FD; llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P); - llvm::errs() << "Writing '" << P.str() << "'.\n"; + llvm::errs() << "Writing '" << P << "'.\n"; auto Stream = llvm::make_unique(FD, true); diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index d9f3f42e32..efe20e27d8 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -7268,7 +7268,7 @@ cxindex::Logger::~Logger() { llvm::TimeRecord TR = llvm::TimeRecord::getCurrentTime(); OS << llvm::format("%7.4f] ", TR.getWallTime() - sBeginTR.getWallTime()); - OS << Msg.str() << '\n'; + OS << Msg << '\n'; if (Trace) { llvm::sys::PrintStackTrace(OS); diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 83629ec360..6369c342ce 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -1162,7 +1162,7 @@ writePrettyPrintFunction(Record &R, OS << " case " << I << " : {\n" - " OS << \"" + Prefix.str() + Spelling.str(); + " OS << \"" << Prefix << Spelling; if (Variety == "Pragma") { OS << " \";\n"; @@ -1190,7 +1190,7 @@ writePrettyPrintFunction(Record &R, if (!Args.empty()) OS << ")"; - OS << Suffix.str() + "\";\n"; + OS << Suffix + "\";\n"; OS << " break;\n"