summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-26 22:52:05 +0000
committerAlp Toker <alp@nuanti.com>2014-06-26 22:52:05 +0000
commit8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d (patch)
tree7da91c52380a71a92a895b0c172ae28b83fb6011 /lib
parenteca517deaa890b1658ed0452704f398ce80e47b8 (diff)
downloadllvm-8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d.tar.gz
llvm-8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d.tar.bz2
llvm-8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d.tar.xz
Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/Analysis.cpp9
-rw-r--r--lib/Analysis/BlockFrequencyInfo.cpp7
-rw-r--r--lib/Analysis/Lint.cpp7
-rw-r--r--lib/AsmParser/LLParser.cpp7
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp3
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp12
-rw-r--r--lib/CodeGen/MachineBlockFrequencyInfo.cpp7
-rw-r--r--lib/CodeGen/MachineBlockPlacement.cpp12
-rw-r--r--lib/CodeGen/MachineFunction.cpp5
-rw-r--r--lib/CodeGen/MachineScheduler.cpp3
-rw-r--r--lib/CodeGen/ScheduleDAGInstrs.cpp3
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp3
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp3
-rw-r--r--lib/CodeGen/TargetSchedule.cpp9
-rw-r--r--lib/DebugInfo/DWARFDebugFrame.cpp7
-rw-r--r--lib/IR/Core.cpp37
-rw-r--r--lib/IR/DataLayout.cpp3
-rw-r--r--lib/IR/LLVMContext.cpp15
-rw-r--r--lib/IRReader/IRReader.cpp9
-rw-r--r--lib/LTO/LTOCodeGenerator.cpp11
-rw-r--r--lib/MC/MCAsmStreamer.cpp7
-rw-r--r--lib/MC/MCContext.cpp14
-rw-r--r--lib/MC/MCDisassembler/Disassembler.cpp8
-rw-r--r--lib/MC/MCDwarf.cpp6
-rw-r--r--lib/MC/MCParser/AsmParser.cpp6
-rw-r--r--lib/Object/MachOObjectFile.cpp7
-rw-r--r--lib/Option/Arg.cpp6
-rw-r--r--lib/Support/CommandLine.cpp34
-rw-r--r--lib/Support/raw_ostream.cpp4
-rw-r--r--lib/TableGen/SetTheory.cpp11
-rw-r--r--lib/TableGen/TGParser.cpp3
-rw-r--r--lib/Target/NVPTX/NVPTXAsmPrinter.cpp3
-rw-r--r--lib/Target/TargetMachineC.cpp12
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp3
-rw-r--r--lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp3
-rw-r--r--lib/Target/X86/X86AsmPrinter.cpp6
-rw-r--r--lib/Target/XCore/XCoreAsmPrinter.cpp3
-rw-r--r--lib/Transforms/Instrumentation/DebugIR.cpp10
-rw-r--r--lib/Transforms/Instrumentation/GCOVProfiling.cpp15
-rw-r--r--lib/Transforms/Instrumentation/MemorySanitizer.cpp3
-rw-r--r--lib/Transforms/ObjCARC/ObjCARCOpts.cpp9
-rw-r--r--lib/Transforms/Utils/ASanStackFrameLayout.cpp3
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp36
43 files changed, 225 insertions, 159 deletions
diff --git a/lib/Analysis/Analysis.cpp b/lib/Analysis/Analysis.cpp
index 907203c571..ade940a7d3 100644
--- a/lib/Analysis/Analysis.cpp
+++ b/lib/Analysis/Analysis.cpp
@@ -75,7 +75,8 @@ void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
char **OutMessages) {
raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
- string_ostream MsgsOS;
+ std::string Messages;
+ raw_string_ostream MsgsOS(Messages);
LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
@@ -86,10 +87,8 @@ LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
if (Action == LLVMAbortProcessAction && Result)
report_fatal_error("Broken module found, compilation aborted!");
- if (OutMessages) {
- MsgsOS << '\0';
- *OutMessages = strdup(MsgsOS.str().data());
- }
+ if (OutMessages)
+ *OutMessages = strdup(MsgsOS.str().c_str());
return Result;
}
diff --git a/lib/Analysis/BlockFrequencyInfo.cpp b/lib/Analysis/BlockFrequencyInfo.cpp
index 7e702c3143..8ed8e3e4c2 100644
--- a/lib/Analysis/BlockFrequencyInfo.cpp
+++ b/lib/Analysis/BlockFrequencyInfo.cpp
@@ -82,9 +82,10 @@ struct DOTGraphTraits<BlockFrequencyInfo*> : public DefaultDOTGraphTraits {
std::string getNodeLabel(const BasicBlock *Node,
const BlockFrequencyInfo *Graph) {
- string_ostream OS;
+ std::string Result;
+ raw_string_ostream OS(Result);
- OS << Node->getName() << ":";
+ OS << Node->getName().str() << ":";
switch (ViewBlockFreqPropagationDAG) {
case GVDT_Fraction:
Graph->printBlockFreq(OS, Node);
@@ -97,7 +98,7 @@ struct DOTGraphTraits<BlockFrequencyInfo*> : public DefaultDOTGraphTraits {
"never reach this point.");
}
- return OS.str();
+ return Result;
}
};
diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp
index 806a1fdee5..b14f3292e9 100644
--- a/lib/Analysis/Lint.cpp
+++ b/lib/Analysis/Lint.cpp
@@ -105,10 +105,11 @@ namespace {
const DataLayout *DL;
TargetLibraryInfo *TLI;
- string_ostream MessagesStr;
+ std::string Messages;
+ raw_string_ostream MessagesStr;
static char ID; // Pass identification, replacement for typeid
- Lint() : FunctionPass(ID) {
+ Lint() : FunctionPass(ID), MessagesStr(Messages) {
initializeLintPass(*PassRegistry::getPassRegistry());
}
@@ -180,7 +181,7 @@ bool Lint::runOnFunction(Function &F) {
TLI = &getAnalysis<TargetLibraryInfo>();
visit(F);
dbgs() << MessagesStr.str();
- MessagesStr.clear();
+ Messages.clear();
return false;
}
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 840f764d3a..f444206852 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -28,9 +28,10 @@
using namespace llvm;
static std::string getTypeString(Type *T) {
- string_ostream Result;
- Result << *T;
- return Result.str();
+ std::string Result;
+ raw_string_ostream Tmp(Result);
+ Tmp << *T;
+ return Tmp.str();
}
/// Run: module ::= toplevelentity*
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index ebb49c34a7..799ee92d3a 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1585,7 +1585,8 @@ static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP) {
// Otherwise report the problem to the user.
{
- string_ostream OS;
+ std::string S;
+ raw_string_ostream OS(S);
OS << "Unsupported expression in static initializer: ";
CE->printAsOperand(OS, /*PrintType=*/false,
!AP.MF ? nullptr : AP.MF->getFunction()->getParent());
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 01f26d0c4c..46ee0c856b 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -241,7 +241,8 @@ static void EmitMSInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
}
}
if (Error) {
- string_ostream Msg;
+ std::string msg;
+ raw_string_ostream Msg(msg);
Msg << "invalid operand in inline asm: '" << AsmStr << "'";
MMI->getModule()->getContext().emitError(LocCookie, Msg.str());
}
@@ -412,7 +413,8 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
}
}
if (Error) {
- string_ostream Msg;
+ std::string msg;
+ raw_string_ostream Msg(msg);
Msg << "invalid operand in inline asm: '" << AsmStr << "'";
MMI->getModule()->getContext().emitError(LocCookie, Msg.str());
}
@@ -469,7 +471,8 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const {
// Emit the inline asm to a temporary string so we can emit it through
// EmitInlineAsm.
- small_string_ostream<256> OS;
+ SmallString<256> StringData;
+ raw_svector_ostream OS(StringData);
// The variant of the current asmprinter.
int AsmPrinterVariant = MAI->getAssemblerDialect();
@@ -514,7 +517,8 @@ void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
}
OS << Counter;
} else {
- string_ostream Msg;
+ std::string msg;
+ raw_string_ostream Msg(msg);
Msg << "Unknown special formatter '" << Code
<< "' for machine instr: " << *MI;
report_fatal_error(Msg.str());
diff --git a/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/lib/CodeGen/MachineBlockFrequencyInfo.cpp
index 35e4a56cec..9151d99089 100644
--- a/lib/CodeGen/MachineBlockFrequencyInfo.cpp
+++ b/lib/CodeGen/MachineBlockFrequencyInfo.cpp
@@ -89,9 +89,10 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo*> :
std::string getNodeLabel(const MachineBasicBlock *Node,
const MachineBlockFrequencyInfo *Graph) {
- string_ostream OS;
+ std::string Result;
+ raw_string_ostream OS(Result);
- OS << Node->getName() << ":";
+ OS << Node->getName().str() << ":";
switch (ViewMachineBlockFreqPropagationDAG) {
case GVDT_Fraction:
Graph->printBlockFreq(OS, Node);
@@ -104,7 +105,7 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo*> :
"never reach this point.");
}
- return OS.str();
+ return Result;
}
};
diff --git a/lib/CodeGen/MachineBlockPlacement.cpp b/lib/CodeGen/MachineBlockPlacement.cpp
index 891f605e2a..74af1e2d64 100644
--- a/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/lib/CodeGen/MachineBlockPlacement.cpp
@@ -264,19 +264,23 @@ INITIALIZE_PASS_END(MachineBlockPlacement, "block-placement2",
///
/// Only used by debug logging.
static std::string getBlockName(MachineBasicBlock *BB) {
- string_ostream OS;
+ std::string Result;
+ raw_string_ostream OS(Result);
OS << "BB#" << BB->getNumber()
<< " (derived from LLVM BB '" << BB->getName() << "')";
- return OS.str();
+ OS.flush();
+ return Result;
}
/// \brief Helper to print the number of a MBB.
///
/// Only used by debug logging.
static std::string getBlockNum(MachineBasicBlock *BB) {
- string_ostream OS;
+ std::string Result;
+ raw_string_ostream OS(Result);
OS << "BB#" << BB->getNumber();
- return OS.str();
+ OS.flush();
+ return Result;
}
#endif
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 20210adf30..6138aef4ad 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -465,8 +465,9 @@ MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
const char *Prefix = isLinkerPrivate ? DL->getLinkerPrivateGlobalPrefix() :
DL->getPrivateGlobalPrefix();
- small_string_ostream<60> Name;
- Name << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
+ SmallString<60> Name;
+ raw_svector_ostream(Name)
+ << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
return Ctx.GetOrCreateSymbol(Name.str());
}
diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp
index f7459bbf6f..0baf2a6c1c 100644
--- a/lib/CodeGen/MachineScheduler.cpp
+++ b/lib/CodeGen/MachineScheduler.cpp
@@ -3235,7 +3235,8 @@ struct DOTGraphTraits<ScheduleDAGMI*> : public DefaultDOTGraphTraits {
}
static std::string getNodeLabel(const SUnit *SU, const ScheduleDAG *G) {
- string_ostream SS;
+ std::string Str;
+ raw_string_ostream SS(Str);
const ScheduleDAGMI *DAG = static_cast<const ScheduleDAGMI*>(G);
const SchedDFSResult *DFS = DAG->hasVRegLiveness() ?
static_cast<const ScheduleDAGMILive*>(G)->getDFSResult() : nullptr;
diff --git a/lib/CodeGen/ScheduleDAGInstrs.cpp b/lib/CodeGen/ScheduleDAGInstrs.cpp
index baf4af6aba..92a9a30f24 100644
--- a/lib/CodeGen/ScheduleDAGInstrs.cpp
+++ b/lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -1197,7 +1197,8 @@ void ScheduleDAGInstrs::dumpNode(const SUnit *SU) const {
}
std::string ScheduleDAGInstrs::getGraphNodeLabel(const SUnit *SU) const {
- string_ostream oss;
+ std::string s;
+ raw_string_ostream oss(s);
if (SU == &EntrySU)
oss << "<entry>";
else if (SU == &ExitSU)
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index a2cc290816..57e22e21c3 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3245,7 +3245,8 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
void SelectionDAGISel::CannotYetSelect(SDNode *N) {
- string_ostream Msg;
+ std::string msg;
+ raw_string_ostream Msg(msg);
Msg << "Cannot select: ";
if (N->getOpcode() != ISD::INTRINSIC_W_CHAIN &&
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
index 680a7ec5dd..4df5ede388 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
@@ -268,7 +268,8 @@ void SelectionDAG::setSubgraphColor(SDNode *N, const char *Color) {
}
std::string ScheduleDAGSDNodes::getGraphNodeLabel(const SUnit *SU) const {
- string_ostream O;
+ std::string s;
+ raw_string_ostream O(s);
O << "SU(" << SU->NodeNum << "): ";
if (SU->getNode()) {
SmallVector<SDNode *, 4> GluedNodes;
diff --git a/lib/CodeGen/TargetSchedule.cpp b/lib/CodeGen/TargetSchedule.cpp
index d18a514a85..b0f2ca6888 100644
--- a/lib/CodeGen/TargetSchedule.cpp
+++ b/lib/CodeGen/TargetSchedule.cpp
@@ -212,10 +212,11 @@ unsigned TargetSchedModel::computeOperandLatency(
if (SCDesc->isValid() && !DefMI->getOperand(DefOperIdx).isImplicit()
&& !DefMI->getDesc().OpInfo[DefOperIdx].isOptionalDef()
&& SchedModel.isComplete()) {
- string_ostream Err;
- Err << "DefIdx " << DefIdx << " exceeds machine model writes for "
- << *DefMI;
- report_fatal_error(Err.str());
+ std::string Err;
+ raw_string_ostream ss(Err);
+ ss << "DefIdx " << DefIdx << " exceeds machine model writes for "
+ << *DefMI;
+ report_fatal_error(ss.str());
}
#endif
// FIXME: Automatically giving all implicit defs defaultDefLatency is
diff --git a/lib/DebugInfo/DWARFDebugFrame.cpp b/lib/DebugInfo/DWARFDebugFrame.cpp
index 2227260bb0..a33548e95b 100644
--- a/lib/DebugInfo/DWARFDebugFrame.cpp
+++ b/lib/DebugInfo/DWARFDebugFrame.cpp
@@ -353,9 +353,10 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
Entries.back()->parseInstructions(Data, &Offset, EndStructureOffset);
if (Offset != EndStructureOffset) {
- string_ostream Str;
- Str << format("Parsing entry instructions at %lx failed", StartOffset);
- report_fatal_error(Str.str());
+ std::string Str;
+ raw_string_ostream OS(Str);
+ OS << format("Parsing entry instructions at %lx failed", StartOffset);
+ report_fatal_error(Str);
}
}
}
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index 779d891304..2c49d5b949 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -62,11 +62,6 @@ void LLVMShutdown() {
/*===-- Error handling ----------------------------------------------------===*/
-static char *LLVMCreateMessage(string_ostream &OS) {
- OS << '\0';
- return strdup(OS.str().data());
-}
-
char *LLVMCreateMessage(const char *Message) {
return strdup(Message);
}
@@ -115,10 +110,14 @@ unsigned LLVMGetMDKindID(const char* Name, unsigned SLen) {
}
char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI) {
- string_ostream Msg;
- DiagnosticPrinterRawOStream DP(Msg);
+ std::string MsgStorage;
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
+
unwrap(DI)->print(DP);
- return LLVMCreateMessage(Msg);
+ Stream.flush();
+
+ return LLVMCreateMessage(MsgStorage.c_str());
}
LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI){
@@ -202,9 +201,13 @@ LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
}
char *LLVMPrintModuleToString(LLVMModuleRef M) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
+
unwrap(M)->print(os, nullptr);
- return LLVMCreateMessage(os);
+ os.flush();
+
+ return strdup(buf.c_str());
}
/*--.. Operations on inline assembler ......................................--*/
@@ -275,14 +278,17 @@ void LLVMDumpType(LLVMTypeRef Ty) {
}
char *LLVMPrintTypeToString(LLVMTypeRef Ty) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
if (unwrap(Ty))
unwrap(Ty)->print(os);
else
os << "Printing <null> Type";
- return LLVMCreateMessage(os);
+ os.flush();
+
+ return strdup(buf.c_str());
}
/*--.. Operations on integer types .........................................--*/
@@ -526,14 +532,17 @@ void LLVMDumpValue(LLVMValueRef Val) {
}
char* LLVMPrintValueToString(LLVMValueRef Val) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
if (unwrap(Val))
unwrap(Val)->print(os);
else
os << "Printing <null> Value";
- return LLVMCreateMessage(os);
+ os.flush();
+
+ return strdup(buf.c_str());
}
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp
index 3aa775097d..dea05fbef4 100644
--- a/lib/IR/DataLayout.cpp
+++ b/lib/IR/DataLayout.cpp
@@ -519,7 +519,8 @@ const StructLayout *DataLayout::getStructLayout(StructType *Ty) const {
}
std::string DataLayout::getStringRepresentation() const {
- string_ostream OS;
+ std::string Result;
+ raw_string_ostream OS(Result);
OS << (LittleEndian ? "e" : "E");
diff --git a/lib/IR/LLVMContext.cpp b/lib/IR/LLVMContext.cpp
index 201b278285..de825f00b2 100644
--- a/lib/IR/LLVMContext.cpp
+++ b/lib/IR/LLVMContext.cpp
@@ -164,22 +164,23 @@ void LLVMContext::diagnose(const DiagnosticInfo &DI) {
}
// Otherwise, print the message with a prefix based on the severity.
- string_ostream Msg;
- DiagnosticPrinterRawOStream DP(Msg);
+ std::string MsgStorage;
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
DI.print(DP);
-
+ Stream.flush();
switch (DI.getSeverity()) {
case DS_Error:
- errs() << "error: " << Msg.str() << "\n";
+ errs() << "error: " << MsgStorage << "\n";
exit(1);
case DS_Warning:
- errs() << "warning: " << Msg.str() << "\n";
+ errs() << "warning: " << MsgStorage << "\n";
break;
case DS_Remark:
- errs() << "remark: " << Msg.str() << "\n";
+ errs() << "remark: " << MsgStorage << "\n";
break;
case DS_Note:
- errs() << "note: " << Msg.str() << "\n";
+ errs() << "note: " << MsgStorage << "\n";
break;
}
}
diff --git a/lib/IRReader/IRReader.cpp b/lib/IRReader/IRReader.cpp
index e72990751b..01aa074aba 100644
--- a/lib/IRReader/IRReader.cpp
+++ b/lib/IRReader/IRReader.cpp
@@ -108,10 +108,13 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
if(!*OutM) {
if (OutMessage) {
- string_ostream os;
+ std::string buf;
+ raw_string_ostream os(buf);
+
Diag.print(nullptr, os, false);
- os << '\0';
- *OutMessage = strdup(os.str().data());
+ os.flush();
+
+ *OutMessage = strdup(buf.c_str());
}
return 1;
}
diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp
index d87299b5c7..a1709f60ff 100644
--- a/lib/LTO/LTOCodeGenerator.cpp
+++ b/lib/LTO/LTOCodeGenerator.cpp
@@ -549,17 +549,16 @@ void LTOCodeGenerator::DiagnosticHandler2(const DiagnosticInfo &DI) {
break;
}
// Create the string that will be reported to the external diagnostic handler.
- string_ostream Msg;
- DiagnosticPrinterRawOStream DP(Msg);
+ std::string MsgStorage;
+ raw_string_ostream Stream(MsgStorage);
+ DiagnosticPrinterRawOStream DP(Stream);
DI.print(DP);
-
- // Null-terminate the C string.
- Msg << '\0';
+ Stream.flush();
// If this method has been called it means someone has set up an external
// diagnostic handler. Assert on that.
assert(DiagHandler && "Invalid diagnostic handler");
- (*DiagHandler)(Severity, Msg.str().data(), DiagContext);
+ (*DiagHandler)(Severity, MsgStorage.c_str(), DiagContext);
}
void
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index a3a81a6bc7..da235ec1d3 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -1175,10 +1175,9 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
raw_ostream &OS = GetCommentOS();
SmallString<256> Code;
SmallVector<MCFixup, 4> Fixups;
- {
- raw_svector_ostream VecOS(Code);
- Emitter->EncodeInstruction(Inst, VecOS, Fixups, STI);
- }
+ raw_svector_ostream VecOS(Code);
+ Emitter->EncodeInstruction(Inst, VecOS, Fixups, STI);
+ VecOS.flush();
// If we are showing fixups, create symbolic markers in the encoded
// representation. We do this by making a per-bit map to the fixup item index,
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index 3a8cfaa947..bd2c4e960a 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -140,15 +140,17 @@ MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
}
MCSymbol *MCContext::CreateLinkerPrivateTempSymbol() {
- small_string_ostream<128> NameSV;
- NameSV << MAI->getLinkerPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
- return CreateSymbol(NameSV.str());
+ SmallString<128> NameSV;
+ raw_svector_ostream(NameSV)
+ << MAI->getLinkerPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
+ return CreateSymbol(NameSV);
}
MCSymbol *MCContext::CreateTempSymbol() {
- small_string_ostream<128> NameSV;
- NameSV << MAI->getPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
- return CreateSymbol(NameSV.str());
+ SmallString<128> NameSV;
+ raw_svector_ostream(NameSV)
+ << MAI->getPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
+ return CreateSymbol(NameSV);
}
unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp
index e3ec4eb30d..0530c26369 100644
--- a/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/lib/MC/MCDisassembler/Disassembler.cpp
@@ -270,7 +270,8 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
const MCDisassembler *DisAsm = DC->getDisAsm();
MCInstPrinter *IP = DC->getIP();
MCDisassembler::DecodeStatus S;
- small_string_ostream<64> Annotations;
+ SmallVector<char, 64> InsnStr;
+ raw_svector_ostream Annotations(InsnStr);
S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC,
/*REMOVE*/ nulls(), Annotations);
switch (S) {
@@ -280,10 +281,13 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes,
return 0;
case MCDisassembler::Success: {
+ Annotations.flush();
+ StringRef AnnotationsStr = Annotations.str();
+
SmallVector<char, 64> InsnStr;
raw_svector_ostream OS(InsnStr);
formatted_raw_ostream FormattedOS(OS);
- IP->printInst(&Inst, FormattedOS, Annotations.str());
+ IP->printInst(&Inst, FormattedOS, AnnotationsStr);
if (DC->getOptions() & LLVMDisassembler_Option_PrintLatency)
emitLatency(DC, Inst);
diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp
index eab4d88f25..bddbf578d8 100644
--- a/lib/MC/MCDwarf.cpp
+++ b/lib/MC/MCDwarf.cpp
@@ -420,7 +420,8 @@ unsigned MCDwarfLineTableHeader::getFile(StringRef &Directory,
void MCDwarfLineAddr::Emit(MCStreamer *MCOS, int64_t LineDelta,
uint64_t AddrDelta) {
MCContext &Context = MCOS->getContext();
- small_string_ostream<256> OS;
+ SmallString<256> Tmp;
+ raw_svector_ostream OS(Tmp);
MCDwarfLineAddr::Encode(Context, LineDelta, AddrDelta, OS);
MCOS->EmitBytes(OS.str());
}
@@ -1646,7 +1647,8 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
void MCDwarfFrameEmitter::EmitAdvanceLoc(MCObjectStreamer &Streamer,
uint64_t AddrDelta) {
MCContext &Context = Streamer.getContext();
- small_string_ostream<256> OS;
+ SmallString<256> Tmp;
+ raw_svector_ostream OS(Tmp);
MCDwarfFrameEmitter::EncodeAdvanceLoc(Context, AddrDelta, OS);
Streamer.EmitBytes(OS.str());
}
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index 7bfbbf4932..fa5dfdc9fe 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -4580,7 +4580,8 @@ bool AsmParser::parseMSInlineAsm(
}
// Build the IR assembly string.
- string_ostream OS;
+ std::string AsmStringIR;
+ raw_string_ostream OS(AsmStringIR);
const char *AsmStart = SrcMgr.getMemoryBuffer(0)->getBufferStart();
const char *AsmEnd = SrcMgr.getMemoryBuffer(0)->getBufferEnd();
array_pod_sort(AsmStrRewrites.begin(), AsmStrRewrites.end(), rewritesSort);
@@ -4645,7 +4646,8 @@ bool AsmParser::parseMSInlineAsm(
}
case AOK_DotOperator:
// Insert the dot if the user omitted it.
- if (OS.str().back() != '.')
+ OS.flush();
+ if (AsmStringIR.back() != '.')
OS << '.';
OS << AR.Val;
break;
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index 2511a4a3fa..dbfc07270a 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -301,7 +301,7 @@ static unsigned getCPUType(const MachOObjectFile *O) {
static void printRelocationTargetName(const MachOObjectFile *O,
const MachO::any_relocation_info &RE,
- raw_ostream &fmt) {
+ raw_string_ostream &fmt) {
bool IsScattered = O->isRelocationScattered(RE);
// Target of a scattered relocation is an address. In the interest of
@@ -1010,7 +1010,8 @@ MachOObjectFile::getRelocationValueString(DataRefImpl Rel,
unsigned Arch = this->getArch();
- string_ostream fmt;
+ std::string fmtbuf;
+ raw_string_ostream fmt(fmtbuf);
unsigned Type = this->getAnyRelocationType(RE);
bool IsPCRel = this->getAnyRelocationPCRel(RE);
@@ -1173,7 +1174,7 @@ MachOObjectFile::getRelocationValueString(DataRefImpl Rel,
} else
printRelocationTargetName(this, RE, fmt);
- StringRef fmtbuf = fmt.str();
+ fmt.flush();
Result.append(fmtbuf.begin(), fmtbuf.end());
return object_error::success;
}
diff --git a/lib/Option/Arg.cpp b/lib/Option/Arg.cpp
index 30a6922973..4c8da58f53 100644
--- a/lib/Option/Arg.cpp
+++ b/lib/Option/Arg.cpp
@@ -62,7 +62,8 @@ void Arg::dump() const {
}
std::string Arg::getAsString(const ArgList &Args) const {
- small_string_ostream<256> OS;
+ SmallString<256> Res;
+ llvm::raw_svector_ostream OS(Res);
ArgStringList ASL;
render(Args, ASL);
@@ -94,7 +95,8 @@ void Arg::render(const ArgList &Args, ArgStringList &Output) const {
break;
case Option::RenderCommaJoinedStyle: {
- small_string_ostream<256> OS;
+ SmallString<256> Res;
+ llvm::raw_svector_ostream OS(Res);
OS << getSpelling();
for (unsigned i = 0, e = getNumValues(); i != e; ++i) {
if (i) OS << ',';
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index e28e1d1763..c2b739fa73 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -1342,21 +1342,25 @@ printGenericOptionDiff(const Option &O, const GenericOptionValue &Value,
// printOptionDiff - Specializations for printing basic value types.
//
-#define PRINT_OPT_DIFF(T) \
- void parser<T>::printOptionDiff(const Option &O, T V, OptionValue<T> D, \
- size_t GlobalWidth) const { \
- printOptionName(O, GlobalWidth); \
- string_ostream SS; \
- SS << V; \
- outs() << "= " << SS.str(); \
- size_t NumSpaces = MaxOptWidth > SS.tell() ? MaxOptWidth - SS.tell() : 0; \
- outs().indent(NumSpaces) << " (default: "; \
- if (D.hasValue()) \
- outs() << D.getValue(); \
- else \
- outs() << "*no default*"; \
- outs() << ")\n"; \
- }
+#define PRINT_OPT_DIFF(T) \
+ void parser<T>:: \
+ printOptionDiff(const Option &O, T V, OptionValue<T> D, \
+ size_t GlobalWidth) const { \
+ printOptionName(O, GlobalWidth); \
+ std::string Str; \
+ { \
+ raw_string_ostream SS(Str); \
+ SS << V; \
+ } \
+ outs() << "= " << Str; \
+ size_t NumSpaces = MaxOptWidth > Str.size() ? MaxOptWidth - Str.size() : 0;\
+ outs().indent(NumSpaces) << " (default: "; \
+ if (D.hasValue()) \
+ outs() << D.getValue(); \
+ else \
+ outs() << "*no default*"; \
+ outs() << ")\n"; \
+ } \
PRINT_OPT_DIFF(bool)
PRINT_OPT_DIFF(boolOrDefault)
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index b3f3056ba6..f7c213ac2b 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -704,10 +704,6 @@ void raw_string_ostream::write_impl(const char *Ptr, size_t Size) {
// and we only need to set the vector size when the data is flushed.
raw_svector_ostream::raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {
- init();
-}
-
-void raw_svector_ostream::init() {
// Set up the initial external buffer. We make sure that the buffer has at
// least 128 bytes free; raw_ostream itself only requires 64, but we want to
// make sure that we don't grow the buffer unnecessarily on destruction (when
diff --git a/lib/TableGen/SetTheory.cpp b/lib/TableGen/SetTheory.cpp
index 594d4d9a94..c99c2bab45 100644
--- a/lib/TableGen/SetTheory.cpp
+++ b/lib/TableGen/SetTheory.cpp
@@ -209,12 +209,13 @@ struct SequenceOp : public SetTheory::Operator {
break;
else if (Step < 0 && From < To)
break;
- string_ostream Name;
- Name << format(Format.c_str(), unsigned(From));
- Record *Rec = Records.getDef(Name.str());
+ std::string Name;
+ raw_string_ostream OS(Name);
+ OS << format(Format.c_str(), unsigned(From));
+ Record *Rec = Records.getDef(OS.str());
if (!Rec)
- PrintFatalError(Loc, "No def named '" + Name.str() + "': " +
- Expr->getAsString());
+ PrintFatalError(Loc, "No def named '" + Name + "': " +
+ Expr->getAsString());
// Try to reevaluate Rec in case it is a set.
if (const RecVec *Result = ST.expand(Rec))
Elts.insert(Result->begin(), Result->end());
diff --git a/lib/TableGen/TGParser.cpp b/lib/TableGen/TGParser.cpp
index 76ef696c68..0550692ebc 100644
--- a/lib/TableGen/TGParser.cpp
+++ b/lib/TableGen/TGParser.cpp
@@ -1307,7 +1307,8 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType,
if (ItemType) {
ListRecTy *ListType = dyn_cast<ListRecTy>(ItemType);
if (!ListType) {
- string_ostream ss;
+ std::string s;
+ raw_string_ostream ss(s);
ss << "Type mismatch for list, expected list type, got "
<< ItemType->getAsString();
TokError(ss.str());
diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index eee2f9264f..195b3c0fe9 100644
--- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -146,7 +146,8 @@ const MCExpr *nvptx::LowerConstant(const Constant *CV, AsmPrinter &AP) {
// Otherwise report the problem to the user.
{
- string_ostream OS;
+ std::string S;
+ raw_string_ostream OS(S);
OS << "Unsupported expression in static initializer: ";
CE->printAsOperand(OS, /*PrintType=*/ false,
!AP.MF ? nullptr : AP.MF->getFunction()->getParent());
diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp
index 0b0a09a0ad..20923c97ec 100644
--- a/lib/Target/TargetMachineC.cpp
+++ b/lib/Target/TargetMachineC.cpp
@@ -237,13 +237,15 @@ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T,
LLVMModuleRef M, LLVMCodeGenFileType codegen, char** ErrorMessage,
LLVMMemoryBufferRef *OutMemBuf) {
- string_ostream Code;
- formatted_raw_ostream Out(Code);
+ std::string CodeString;
+ raw_string_ostream OStream(CodeString);
+ formatted_raw_ostream Out(OStream);
bool Result = LLVMTargetMachineEmit(T, M, Out, codegen, ErrorMessage);
+ OStream.flush();
- StringRef Buffer = Code.str();
- *OutMemBuf = LLVMCreateMemoryBufferWithMemoryRangeCopy(Buffer.data(),
- Buffer.size(), "");
+ std::string &Data = OStream.str();
+ *OutMemBuf = LLVMCreateMemoryBufferWithMemoryRangeCopy(Data.c_str(),
+ Data.length(), "");
return Result;
}
diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 7e04608d99..3e57914f9e 100644
--- a/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -2412,7 +2412,8 @@ bool X86AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
if (Match3 == Match_Success) MatchChars[NumMatches++] = Suffixes[2];
if (Match4 == Match_Success) MatchChars[NumMatches++] = Suffixes[3];
- small_string_ostream<128> OS;
+ SmallString<126> Msg;
+ raw_svector_ostream OS(Msg);
OS << "ambiguous instructions require an explicit suffix (could be ";
for (unsigned i = 0; i != NumMatches; ++i) {
if (i != 0)
diff --git a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 3f9eb07d83..78403424da 100644
--- a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -281,7 +281,8 @@ void X86AsmBackend::relaxInstruction(const MCInst &Inst, MCInst &Res) const {
unsigned RelaxedOp = getRelaxedOpcode(Inst.getOpcode());
if (RelaxedOp == Inst.getOpcode()) {
- small_string_ostream<256> OS;
+ SmallString<256> Tmp;
+ raw_svector_ostream OS(Tmp);
Inst.dump_pretty(OS);
OS << "\n";
report_fatal_error("unexpected instruction to relax: " + OS.str());
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp
index cdfff82143..1dca5689ad 100644
--- a/lib/Target/X86/X86AsmPrinter.cpp
+++ b/lib/Target/X86/X86AsmPrinter.cpp
@@ -550,7 +550,8 @@ emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel,
}
void X86AsmPrinter::GenerateExportDirective(const MCSymbol *Sym, bool IsData) {
- small_string_ostream<128> OS;
+ SmallString<128> Directive;
+ raw_svector_ostream OS(Directive);
StringRef Name = Sym->getName();
if (Subtarget->isTargetKnownWindowsMSVC())
@@ -571,7 +572,8 @@ void X86AsmPrinter::GenerateExportDirective(const MCSymbol *Sym, bool IsData) {
OS << ",data";
}
- OutStreamer.EmitBytes(OS.str());
+ OS.flush();
+ OutStreamer.EmitBytes(Directive);
}
void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp
index 7b5da33496..e98d4f933d 100644
--- a/lib/Target/XCore/XCoreAsmPrinter.cpp
+++ b/lib/Target/XCore/XCoreAsmPrinter.cpp
@@ -267,7 +267,8 @@ PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
}
void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) {
- small_string_ostream<128> O;
+ SmallString<128> Str;
+ raw_svector_ostream O(Str);
switch (MI->getOpcode()) {
case XCore::DBG_VALUE:
diff --git a/lib/Transforms/Instrumentation/DebugIR.cpp b/lib/Transforms/Instrumentation/DebugIR.cpp
index 56e60e6984..f2f1738808 100644
--- a/lib/Transforms/Instrumentation/DebugIR.cpp
+++ b/lib/Transforms/Instrumentation/DebugIR.cpp
@@ -352,12 +352,14 @@ private:
}
std::string getTypeName(Type *T) {
- string_ostream OS;
+ std::string TypeName;
+ raw_string_ostream TypeStream(TypeName);
if (T)
- T->print(OS);
+ T->print(TypeStream);
else
- OS << "Printing <null> Type";
- return OS.str();
+ TypeStream << "Printing <null> Type";
+ TypeStream.flush();
+ return TypeName;
}
/// Returns the MDNode that represents type T if it is already created, or 0
diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index 5af938beae..cfeb62eb1f 100644
--- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -316,9 +316,11 @@ namespace {
}
ReturnBlock = new GCOVBlock(i++, os);
- string_ostream FnNameLine;
- FnNameLine << getFunctionName(SP) << SP.getLineNumber();
- FuncChecksum = hash_value(FnNameLine.str());
+ std::string FunctionNameAndLine;
+ raw_string_ostream FNLOS(FunctionNameAndLine);
+ FNLOS << getFunctionName(SP) << SP.getLineNumber();
+ FNLOS.flush();
+ FuncChecksum = hash_value(FunctionNameAndLine);
}
~GCOVFunction() {
@@ -335,14 +337,15 @@ namespace {
}
std::string getEdgeDestinations() {
- string_ostream EdgeDestinations;
+ std::string EdgeDestinations;
+ raw_string_ostream EDOS(EdgeDestinations);
Function *F = Blocks.begin()->first->getParent();
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
GCOVBlock &Block = *Blocks[I];
for (int i = 0, e = Block.OutEdges.size(); i != e; ++i)
- EdgeDestinations << Block.OutEdges[i]->Number;
+ EDOS << Block.OutEdges[i]->Number;
}
- return EdgeDestinations.str();
+ return EdgeDestinations;
}
uint32_t getFuncChecksum() {
diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index bb88bc00ba..4ca0323807 100644
--- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2424,7 +2424,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
if (PoisonStack && MS.TrackOrigins) {
setOrigin(&I, getCleanOrigin());
- small_string_ostream<2048> StackDescription;
+ SmallString<2048> StackDescriptionStorage;
+ raw_svector_ostream StackDescription(StackDescriptionStorage);
// We create a string with a description of the stack allocation and
// pass it into __msan_set_alloca_origin.
// It will be printed by the run-time if stack-originated UMR is found.
diff --git a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index 744fb24048..dd4dd50f0b 100644
--- a/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ b/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
@@ -835,7 +835,8 @@ static MDString *AppendMDNodeToSourcePtr(unsigned NodeId,
// of line at the module level and to provide a very simple format
// encoding the information herein. Both of these makes it simpler to
// parse the annotations by a simple external program.
- string_ostream os;
+ std::string Str;
+ raw_string_ostream os(Str);
os << "(" << Inst->getParent()->getParent()->getName() << ",%"
<< Inst->getName() << ")";
@@ -848,7 +849,8 @@ static MDString *AppendMDNodeToSourcePtr(unsigned NodeId,
Hash = cast<MDString>(Node->getOperand(0));
}
} else if (Argument *Arg = dyn_cast<Argument>(Ptr)) {
- string_ostream os;
+ std::string str;
+ raw_string_ostream os(str);
os << "(" << Arg->getParent()->getName() << ",%" << Arg->getName()
<< ")";
Hash = MDString::get(Arg->getContext(), os.str());
@@ -858,7 +860,8 @@ static MDString *AppendMDNodeToSourcePtr(unsigned NodeId,
}
static std::string SequenceToString(Sequence A) {
- string_ostream os;
+ std::string str;
+ raw_string_ostream os(str);
os << A;
return os.str();
}
diff --git a/lib/Transforms/Utils/ASanStackFrameLayout.cpp b/lib/Transforms/Utils/ASanStackFrameLayout.cpp
index 42fd398d5f..cce016aafd 100644
--- a/lib/Transforms/Utils/ASanStackFrameLayout.cpp
+++ b/lib/Transforms/Utils/ASanStackFrameLayout.cpp
@@ -65,7 +65,8 @@ ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars,
Vars[i].Alignment = std::max(Vars[i].Alignment, kMinAlignment);
std::stable_sort(Vars.begin(), Vars.end(), CompareVars);
- small_string_ostream<2048> StackDescription;
+ SmallString<2048> StackDescriptionStorage;
+ raw_svector_ostream StackDescription(StackDescriptionStorage);
StackDescription << NumVars;
Layout->FrameAlignment = std::max(Granularity, Vars[0].Alignment);
SmallVector<uint8_t, 64> &SB(Layout->ShadowBytes);
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index 2338d296cc..cb8a41dbea 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -212,23 +212,24 @@ class LoopVectorizationCostModel;
/// Optimization analysis message produced during vectorization. Messages inform
/// the user why vectorization did not occur.
class Report {
- string_ostream Message;
+ std::string Message;
+ raw_string_ostream Out;
Instruction *Instr;
public:
- Report(Instruction *I = nullptr) : Instr(I) {
- Message << "loop not vectorized: ";
+ Report(Instruction *I = nullptr) : Out(Message), Instr(I) {
+ Out << "loop not vectorized: ";
}
template <typename A> Report &operator<<(const A &Value) {
- Message << Value;
+ Out << Value;
return *this;
}
Instruction *getInstr() { return Instr; }
- StringRef str() { return Message.str(); }
- operator Twine() { return Message.str(); }
+ std::string &str() { return Out.str(); }
+ operator Twine() { return Out.str(); }
};
/// InnerLoopVectorizer vectorizes loops which contain only one basic
@@ -502,17 +503,18 @@ static void setDebugLocFromInst(IRBuilder<> &B, const Value *Ptr) {
#ifndef NDEBUG
/// \return string containing a file name and a line # for the given loop.
static std::string getDebugLocString(const Loop *L) {
- if (!L)
- return std::string();
-
- string_ostream OS;
- const DebugLoc LoopDbgLoc = L->getStartLoc();
- if (!LoopDbgLoc.isUnknown())
- LoopDbgLoc.print(L->getHeader()->getContext(), OS);
- else
- // Just print the module name.
- OS << L->getHeader()->getParent()->getParent()->getModuleIdentifier();
- return OS.str();
+ std::string Result;
+ if (L) {
+ raw_string_ostream OS(Result);
+ const DebugLoc LoopDbgLoc = L->getStartLoc();
+ if (!LoopDbgLoc.isUnknown())
+ LoopDbgLoc.print(L->getHeader()->getContext(), OS);
+ else
+ // Just print the module name.
+ OS << L->getHeader()->getParent()->getParent()->getModuleIdentifier();
+ OS.flush();
+ }
+ return Result;
}
#endif