Skip to content

Commit e69170a

Browse files
committed
Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754. llvm-svn: 211814
1 parent 11c6f61 commit e69170a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+288
-226
lines changed

llvm/include/llvm/Analysis/CFGPrinter.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
3636
if (!Node->getName().empty())
3737
return Node->getName().str();
3838

39-
string_ostream OS;
39+
std::string Str;
40+
raw_string_ostream OS(Str);
41+
4042
Node->printAsOperand(OS, false);
4143
return OS.str();
4244
}
4345

4446
static std::string getCompleteNodeLabel(const BasicBlock *Node,
4547
const Function *) {
4648
enum { MaxColumns = 80 };
47-
string_ostream OS;
49+
std::string Str;
50+
raw_string_ostream OS(Str);
4851

4952
if (Node->getName().empty()) {
5053
Node->printAsOperand(OS, false);
@@ -106,7 +109,8 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
106109

107110
if (SuccNo == 0) return "def";
108111

109-
string_ostream OS;
112+
std::string Str;
113+
raw_string_ostream OS(Str);
110114
SwitchInst::ConstCaseIt Case =
111115
SwitchInst::ConstCaseIt::fromSuccessorIndex(SI, SuccNo);
112116
OS << Case.getCaseValue()->getValue();

llvm/include/llvm/ExecutionEngine/ObjectBuffer.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,23 @@ class ObjectBuffer {
5858
class ObjectBufferStream : public ObjectBuffer {
5959
void anchor() override;
6060
public:
61-
ObjectBufferStream() {}
61+
ObjectBufferStream() : OS(SV) {}
6262
virtual ~ObjectBufferStream() {}
6363

6464
raw_ostream &getOStream() { return OS; }
6565
void flush()
6666
{
67+
OS.flush();
68+
6769
// Make the data accessible via the ObjectBuffer::Buffer
68-
Buffer.reset(MemoryBuffer::getMemBuffer(OS.str(), "", false));
70+
Buffer.reset(MemoryBuffer::getMemBuffer(StringRef(SV.data(), SV.size()),
71+
"",
72+
false));
6973
}
7074

7175
protected:
72-
small_string_ostream<4096> OS; // Working buffer into which we JIT.
76+
SmallVector<char, 4096> SV; // Working buffer into which we JIT.
77+
raw_svector_ostream OS; // streaming wrapper
7378
};
7479

7580
} // namespace llvm

llvm/include/llvm/Support/GraphWriter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ class GraphWriter {
184184
O << "|" << DOT::EscapeString(NodeDesc);
185185
}
186186

187-
string_ostream EdgeSourceLabels;
187+
std::string edgeSourceLabels;
188+
raw_string_ostream EdgeSourceLabels(edgeSourceLabels);
188189
bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node);
189190

190191
if (hasEdgeSourceLabels) {

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ template<typename T>
612612
typename std::enable_if<has_ScalarTraits<T>::value,void>::type
613613
yamlize(IO &io, T &Val, bool) {
614614
if ( io.outputting() ) {
615-
llvm::string_ostream Buffer;
615+
std::string Storage;
616+
llvm::raw_string_ostream Buffer(Storage);
616617
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
617618
StringRef Str = Buffer.str();
618619
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));

llvm/include/llvm/Support/raw_ostream.h

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
#define LLVM_SUPPORT_RAW_OSTREAM_H
1616

1717
#include "llvm/ADT/StringRef.h"
18-
#include "llvm/ADT/SmallVector.h"
1918
#include "llvm/Support/Compiler.h"
2019
#include "llvm/Support/DataTypes.h"
2120

2221
namespace llvm {
2322
class format_object_base;
23+
template <typename T>
24+
class SmallVectorImpl;
2425

2526
namespace sys {
2627
namespace fs {
@@ -460,14 +461,6 @@ class raw_svector_ostream : public raw_ostream {
460461
/// current_pos - Return the current position within the stream, not
461462
/// counting the bytes currently in the buffer.
462463
uint64_t current_pos() const override;
463-
464-
protected:
465-
// This constructor is specified not to access \p O provided for storage as it
466-
// may not yet be initialized at construction time.
467-
explicit raw_svector_ostream(SmallVectorImpl<char> &O, std::nullptr_t)
468-
: OS(O){};
469-
void init();
470-
471464
public:
472465
/// Construct a new raw_svector_ostream.
473466
///
@@ -500,25 +493,6 @@ class raw_null_ostream : public raw_ostream {
500493
~raw_null_ostream();
501494
};
502495

503-
/// string_ostream - A raw_ostream that builds a string. This is a
504-
/// raw_svector_ostream with storage.
505-
template <unsigned InternalLen>
506-
class small_string_ostream : public raw_svector_ostream {
507-
SmallVector<char, InternalLen> Buffer;
508-
// There's no need to flush explicitly.
509-
using raw_svector_ostream::flush;
510-
511-
public:
512-
small_string_ostream() : raw_svector_ostream(Buffer, nullptr) { init(); }
513-
514-
void clear() {
515-
flush();
516-
Buffer.clear();
517-
}
518-
};
519-
520-
typedef small_string_ostream<128> string_ostream;
521-
522496
} // end llvm namespace
523497

524498
#endif

llvm/include/llvm/TableGen/StringToOffsetTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class StringToOffsetTable {
4242

4343
void EmitString(raw_ostream &O) {
4444
// Escape the string.
45-
small_string_ostream<256> Str;
46-
Str.write_escaped(AggregateString);
45+
SmallString<256> Str;
46+
raw_svector_ostream(Str).write_escaped(AggregateString);
4747
AggregateString = Str.str();
4848

4949
O << " \"";

llvm/lib/Analysis/Analysis.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
7575
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
7676
char **OutMessages) {
7777
raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
78-
string_ostream MsgsOS;
78+
std::string Messages;
79+
raw_string_ostream MsgsOS(Messages);
7980

8081
LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
8182

@@ -86,10 +87,8 @@ LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
8687
if (Action == LLVMAbortProcessAction && Result)
8788
report_fatal_error("Broken module found, compilation aborted!");
8889

89-
if (OutMessages) {
90-
MsgsOS << '\0';
91-
*OutMessages = strdup(MsgsOS.str().data());
92-
}
90+
if (OutMessages)
91+
*OutMessages = strdup(MsgsOS.str().c_str());
9392

9493
return Result;
9594
}

llvm/lib/Analysis/BlockFrequencyInfo.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ struct DOTGraphTraits<BlockFrequencyInfo*> : public DefaultDOTGraphTraits {
8282

8383
std::string getNodeLabel(const BasicBlock *Node,
8484
const BlockFrequencyInfo *Graph) {
85-
string_ostream OS;
85+
std::string Result;
86+
raw_string_ostream OS(Result);
8687

87-
OS << Node->getName() << ":";
88+
OS << Node->getName().str() << ":";
8889
switch (ViewBlockFreqPropagationDAG) {
8990
case GVDT_Fraction:
9091
Graph->printBlockFreq(OS, Node);
@@ -97,7 +98,7 @@ struct DOTGraphTraits<BlockFrequencyInfo*> : public DefaultDOTGraphTraits {
9798
"never reach this point.");
9899
}
99100

100-
return OS.str();
101+
return Result;
101102
}
102103
};
103104

llvm/lib/Analysis/Lint.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ namespace {
105105
const DataLayout *DL;
106106
TargetLibraryInfo *TLI;
107107

108-
string_ostream MessagesStr;
108+
std::string Messages;
109+
raw_string_ostream MessagesStr;
109110

110111
static char ID; // Pass identification, replacement for typeid
111-
Lint() : FunctionPass(ID) {
112+
Lint() : FunctionPass(ID), MessagesStr(Messages) {
112113
initializeLintPass(*PassRegistry::getPassRegistry());
113114
}
114115

@@ -180,7 +181,7 @@ bool Lint::runOnFunction(Function &F) {
180181
TLI = &getAnalysis<TargetLibraryInfo>();
181182
visit(F);
182183
dbgs() << MessagesStr.str();
183-
MessagesStr.clear();
184+
Messages.clear();
184185
return false;
185186
}
186187

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
using namespace llvm;
2929

3030
static std::string getTypeString(Type *T) {
31-
string_ostream Result;
32-
Result << *T;
33-
return Result.str();
31+
std::string Result;
32+
raw_string_ostream Tmp(Result);
33+
Tmp << *T;
34+
return Tmp.str();
3435
}
3536

3637
/// Run: module ::= toplevelentity*

0 commit comments

Comments
 (0)