forked from OSchip/llvm-project
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. llvm-svn: 231763
This commit is contained in:
parent
62b63b197d
commit
09fb7c6e7a
|
@ -1034,7 +1034,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
|
||||||
Str += llvm::utostr(AnonStructId);
|
Str += llvm::utostr(AnonStructId);
|
||||||
|
|
||||||
Out << Str.size();
|
Out << Str.size();
|
||||||
Out << Str.str();
|
Out << Str;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1314,7 +1314,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
|
||||||
if (PLoc.isValid()) {
|
if (PLoc.isValid()) {
|
||||||
FN += PLoc.getFilename();
|
FN += PLoc.getFilename();
|
||||||
Lexer::Stringify(FN);
|
Lexer::Stringify(FN);
|
||||||
OS << '"' << FN.str() << '"';
|
OS << '"' << FN << '"';
|
||||||
}
|
}
|
||||||
Tok.setKind(tok::string_literal);
|
Tok.setKind(tok::string_literal);
|
||||||
} else if (II == Ident__DATE__) {
|
} else if (II == Ident__DATE__) {
|
||||||
|
|
|
@ -735,7 +735,7 @@ static std::unique_ptr<ExplodedNode::Auditor> CreateUbiViz() {
|
||||||
SmallString<128> P;
|
SmallString<128> P;
|
||||||
int FD;
|
int FD;
|
||||||
llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P);
|
llvm::sys::fs::createTemporaryFile("llvm_ubi", "", FD, P);
|
||||||
llvm::errs() << "Writing '" << P.str() << "'.\n";
|
llvm::errs() << "Writing '" << P << "'.\n";
|
||||||
|
|
||||||
auto Stream = llvm::make_unique<llvm::raw_fd_ostream>(FD, true);
|
auto Stream = llvm::make_unique<llvm::raw_fd_ostream>(FD, true);
|
||||||
|
|
||||||
|
|
|
@ -7268,7 +7268,7 @@ cxindex::Logger::~Logger() {
|
||||||
|
|
||||||
llvm::TimeRecord TR = llvm::TimeRecord::getCurrentTime();
|
llvm::TimeRecord TR = llvm::TimeRecord::getCurrentTime();
|
||||||
OS << llvm::format("%7.4f] ", TR.getWallTime() - sBeginTR.getWallTime());
|
OS << llvm::format("%7.4f] ", TR.getWallTime() - sBeginTR.getWallTime());
|
||||||
OS << Msg.str() << '\n';
|
OS << Msg << '\n';
|
||||||
|
|
||||||
if (Trace) {
|
if (Trace) {
|
||||||
llvm::sys::PrintStackTrace(OS);
|
llvm::sys::PrintStackTrace(OS);
|
||||||
|
|
|
@ -1162,7 +1162,7 @@ writePrettyPrintFunction(Record &R,
|
||||||
|
|
||||||
OS <<
|
OS <<
|
||||||
" case " << I << " : {\n"
|
" case " << I << " : {\n"
|
||||||
" OS << \"" + Prefix.str() + Spelling.str();
|
" OS << \"" << Prefix << Spelling;
|
||||||
|
|
||||||
if (Variety == "Pragma") {
|
if (Variety == "Pragma") {
|
||||||
OS << " \";\n";
|
OS << " \";\n";
|
||||||
|
@ -1190,7 +1190,7 @@ writePrettyPrintFunction(Record &R,
|
||||||
|
|
||||||
if (!Args.empty())
|
if (!Args.empty())
|
||||||
OS << ")";
|
OS << ")";
|
||||||
OS << Suffix.str() + "\";\n";
|
OS << Suffix + "\";\n";
|
||||||
|
|
||||||
OS <<
|
OS <<
|
||||||
" break;\n"
|
" break;\n"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#ifndef LLVM_SUPPORT_RAW_OSTREAM_H
|
#ifndef LLVM_SUPPORT_RAW_OSTREAM_H
|
||||||
#define LLVM_SUPPORT_RAW_OSTREAM_H
|
#define LLVM_SUPPORT_RAW_OSTREAM_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
|
@ -185,6 +186,10 @@ public:
|
||||||
return write(Str.data(), Str.length());
|
return write(Str.data(), Str.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw_ostream &operator<<(const llvm::SmallVectorImpl<char> &Str) {
|
||||||
|
return write(Str.data(), Str.size());
|
||||||
|
}
|
||||||
|
|
||||||
raw_ostream &operator<<(unsigned long N);
|
raw_ostream &operator<<(unsigned long N);
|
||||||
raw_ostream &operator<<(long N);
|
raw_ostream &operator<<(long N);
|
||||||
raw_ostream &operator<<(unsigned long long N);
|
raw_ostream &operator<<(unsigned long long N);
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
|
||||||
(StrVal[1] >= '0' && StrVal[1] <= '9'))) {
|
(StrVal[1] >= '0' && StrVal[1] <= '9'))) {
|
||||||
// Reparse stringized version!
|
// Reparse stringized version!
|
||||||
if (APFloat(APFloat::IEEEdouble, StrVal).convertToDouble() == Val) {
|
if (APFloat(APFloat::IEEEdouble, StrVal).convertToDouble() == Val) {
|
||||||
Out << StrVal.str();
|
Out << StrVal;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2291,7 +2291,7 @@ void APInt::dump() const {
|
||||||
this->toStringUnsigned(U);
|
this->toStringUnsigned(U);
|
||||||
this->toStringSigned(S);
|
this->toStringSigned(S);
|
||||||
dbgs() << "APInt(" << BitWidth << "b, "
|
dbgs() << "APInt(" << BitWidth << "b, "
|
||||||
<< U.str() << "u " << S.str() << "s)";
|
<< U << "u " << S << "s)";
|
||||||
}
|
}
|
||||||
|
|
||||||
void APInt::print(raw_ostream &OS, bool isSigned) const {
|
void APInt::print(raw_ostream &OS, bool isSigned) const {
|
||||||
|
|
|
@ -975,7 +975,7 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BD.writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, Safe)) {
|
if (BD.writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, Safe)) {
|
||||||
errs() << "Error writing bitcode to `" << SafeModuleBC.str()
|
errs() << "Error writing bitcode to `" << SafeModuleBC
|
||||||
<< "'\nExiting.";
|
<< "'\nExiting.";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1050,7 @@ bool BugDriver::debugCodeGenerator(std::string *Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writeProgramToFile(TestModuleBC.str(), TestModuleFD, ToCodeGen)) {
|
if (writeProgramToFile(TestModuleBC.str(), TestModuleFD, ToCodeGen)) {
|
||||||
errs() << "Error writing bitcode to `" << TestModuleBC.str()
|
errs() << "Error writing bitcode to `" << TestModuleBC
|
||||||
<< "'\nExiting.";
|
<< "'\nExiting.";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1068,7 @@ bool BugDriver::debugCodeGenerator(std::string *Error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, ToNotCodeGen)) {
|
if (writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, ToNotCodeGen)) {
|
||||||
errs() << "Error writing bitcode to `" << SafeModuleBC.str()
|
errs() << "Error writing bitcode to `" << SafeModuleBC
|
||||||
<< "'\nExiting.";
|
<< "'\nExiting.";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1079,17 +1079,17 @@ bool BugDriver::debugCodeGenerator(std::string *Error) {
|
||||||
|
|
||||||
outs() << "You can reproduce the problem with the command line: \n";
|
outs() << "You can reproduce the problem with the command line: \n";
|
||||||
if (isExecutingJIT()) {
|
if (isExecutingJIT()) {
|
||||||
outs() << " lli -load " << SharedObject << " " << TestModuleBC.str();
|
outs() << " lli -load " << SharedObject << " " << TestModuleBC;
|
||||||
} else {
|
} else {
|
||||||
outs() << " llc " << TestModuleBC.str() << " -o " << TestModuleBC.str()
|
outs() << " llc " << TestModuleBC << " -o " << TestModuleBC
|
||||||
<< ".s\n";
|
<< ".s\n";
|
||||||
outs() << " gcc " << SharedObject << " " << TestModuleBC.str()
|
outs() << " gcc " << SharedObject << " " << TestModuleBC.str()
|
||||||
<< ".s -o " << TestModuleBC.str() << ".exe";
|
<< ".s -o " << TestModuleBC << ".exe";
|
||||||
#if defined (HAVE_LINK_R)
|
#if defined (HAVE_LINK_R)
|
||||||
outs() << " -Wl,-R.";
|
outs() << " -Wl,-R.";
|
||||||
#endif
|
#endif
|
||||||
outs() << "\n";
|
outs() << "\n";
|
||||||
outs() << " " << TestModuleBC.str() << ".exe";
|
outs() << " " << TestModuleBC << ".exe";
|
||||||
}
|
}
|
||||||
for (unsigned i = 0, e = InputArgv.size(); i != e; ++i)
|
for (unsigned i = 0, e = InputArgv.size(); i != e; ++i)
|
||||||
outs() << " " << InputArgv[i];
|
outs() << " " << InputArgv[i];
|
||||||
|
|
|
@ -727,7 +727,7 @@ public:
|
||||||
OS.flush();
|
OS.flush();
|
||||||
|
|
||||||
// Emit the string.
|
// Emit the string.
|
||||||
O.indent(6) << "AsmString = \"" << OutString.str() << "\";\n";
|
O.indent(6) << "AsmString = \"" << OutString << "\";\n";
|
||||||
|
|
||||||
O.indent(6) << "break;\n";
|
O.indent(6) << "break;\n";
|
||||||
O.indent(4) << '}';
|
O.indent(4) << '}';
|
||||||
|
|
|
@ -188,7 +188,7 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
|
||||||
<< " children in Scope";
|
<< " children in Scope";
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << '\n' << TmpBuf.str();
|
OS << '\n' << TmpBuf;
|
||||||
CurrentIdx += ChildSize;
|
CurrentIdx += ChildSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
|
||||||
if (!OmitComments)
|
if (!OmitComments)
|
||||||
OS << "// ->" << CurrentIdx+ChildSize;
|
OS << "// ->" << CurrentIdx+ChildSize;
|
||||||
OS << '\n';
|
OS << '\n';
|
||||||
OS << TmpBuf.str();
|
OS << TmpBuf;
|
||||||
CurrentIdx += ChildSize;
|
CurrentIdx += ChildSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue