llvm.org GIT mirror llvm / 1132d0c
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/llvm/trunk@231763 91177308-0d34-0410-b5e6-96231b3b80d8 Yaron Keren 4 years ago
6 changed file(s) with 17 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
1313 #ifndef LLVM_SUPPORT_RAW_OSTREAM_H
1414 #define LLVM_SUPPORT_RAW_OSTREAM_H
1515
16 #include "llvm/ADT/SmallVector.h"
1617 #include "llvm/ADT/StringRef.h"
1718 #include "llvm/Support/Compiler.h"
1819 #include "llvm/Support/DataTypes.h"
182183 raw_ostream &operator<<(const std::string &Str) {
183184 // Avoid the fast path, it would only increase code size for a marginal win.
184185 return write(Str.data(), Str.length());
186 }
187
188 raw_ostream &operator<<(const llvm::SmallVectorImpl &Str) {
189 return write(Str.data(), Str.size());
185190 }
186191
187192 raw_ostream &operator<<(unsigned long N);
10091009 (StrVal[1] >= '0' && StrVal[1] <= '9'))) {
10101010 // Reparse stringized version!
10111011 if (APFloat(APFloat::IEEEdouble, StrVal).convertToDouble() == Val) {
1012 Out << StrVal.str();
1012 Out << StrVal;
10131013 return;
10141014 }
10151015 }
22902290 this->toStringUnsigned(U);
22912291 this->toStringSigned(S);
22922292 dbgs() << "APInt(" << BitWidth << "b, "
2293 << U.str() << "u " << S.str() << "s)";
2293 << U << "u " << S << "s)";
22942294 }
22952295
22962296 void APInt::print(raw_ostream &OS, bool isSigned) const {
974974 }
975975
976976 if (BD.writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, Safe)) {
977 errs() << "Error writing bitcode to `" << SafeModuleBC.str()
977 errs() << "Error writing bitcode to `" << SafeModuleBC
978978 << "'\nExiting.";
979979 exit(1);
980980 }
10491049 }
10501050
10511051 if (writeProgramToFile(TestModuleBC.str(), TestModuleFD, ToCodeGen)) {
1052 errs() << "Error writing bitcode to `" << TestModuleBC.str()
1052 errs() << "Error writing bitcode to `" << TestModuleBC
10531053 << "'\nExiting.";
10541054 exit(1);
10551055 }
10671067 }
10681068
10691069 if (writeProgramToFile(SafeModuleBC.str(), SafeModuleFD, ToNotCodeGen)) {
1070 errs() << "Error writing bitcode to `" << SafeModuleBC.str()
1070 errs() << "Error writing bitcode to `" << SafeModuleBC
10711071 << "'\nExiting.";
10721072 exit(1);
10731073 }
10781078
10791079 outs() << "You can reproduce the problem with the command line: \n";
10801080 if (isExecutingJIT()) {
1081 outs() << " lli -load " << SharedObject << " " << TestModuleBC.str();
1081 outs() << " lli -load " << SharedObject << " " << TestModuleBC;
10821082 } else {
1083 outs() << " llc " << TestModuleBC.str() << " -o " << TestModuleBC.str()
1083 outs() << " llc " << TestModuleBC << " -o " << TestModuleBC
10841084 << ".s\n";
10851085 outs() << " gcc " << SharedObject << " " << TestModuleBC.str()
1086 << ".s -o " << TestModuleBC.str() << ".exe";
1086 << ".s -o " << TestModuleBC << ".exe";
10871087 #if defined (HAVE_LINK_R)
10881088 outs() << " -Wl,-R.";
10891089 #endif
10901090 outs() << "\n";
1091 outs() << " " << TestModuleBC.str() << ".exe";
1091 outs() << " " << TestModuleBC << ".exe";
10921092 }
10931093 for (unsigned i = 0, e = InputArgv.size(); i != e; ++i)
10941094 outs() << " " << InputArgv[i];
726726 OS.flush();
727727
728728 // Emit the string.
729 O.indent(6) << "AsmString = \"" << OutString.str() << "\";\n";
729 O.indent(6) << "AsmString = \"" << OutString << "\";\n";
730730
731731 O.indent(6) << "break;\n";
732732 O.indent(4) << '}';
187187 << " children in Scope";
188188 }
189189
190 OS << '\n' << TmpBuf.str();
190 OS << '\n' << TmpBuf;
191191 CurrentIdx += ChildSize;
192192 }
193193
341341 if (!OmitComments)
342342 OS << "// ->" << CurrentIdx+ChildSize;
343343 OS << '\n';
344 OS << TmpBuf.str();
344 OS << TmpBuf;
345345 CurrentIdx += ChildSize;
346346 }
347347