From 8dd8d5c2b2ad0f9dd1ca01c0a7d8ebac57b8537d Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Thu, 26 Jun 2014 22:52:05 +0000 Subject: 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 --- include/llvm/Analysis/CFGPrinter.h | 10 +++++++--- include/llvm/ExecutionEngine/ObjectBuffer.h | 11 ++++++++--- include/llvm/Support/GraphWriter.h | 3 ++- include/llvm/Support/YAMLTraits.h | 3 ++- include/llvm/Support/raw_ostream.h | 30 ++--------------------------- include/llvm/TableGen/StringToOffsetTable.h | 4 ++-- 6 files changed, 23 insertions(+), 38 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h index 759afcaee1..e6d2ed1a68 100644 --- a/include/llvm/Analysis/CFGPrinter.h +++ b/include/llvm/Analysis/CFGPrinter.h @@ -36,7 +36,9 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (!Node->getName().empty()) return Node->getName().str(); - string_ostream OS; + std::string Str; + raw_string_ostream OS(Str); + Node->printAsOperand(OS, false); return OS.str(); } @@ -44,7 +46,8 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { static std::string getCompleteNodeLabel(const BasicBlock *Node, const Function *) { enum { MaxColumns = 80 }; - string_ostream OS; + std::string Str; + raw_string_ostream OS(Str); if (Node->getName().empty()) { Node->printAsOperand(OS, false); @@ -106,7 +109,8 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (SuccNo == 0) return "def"; - string_ostream OS; + std::string Str; + raw_string_ostream OS(Str); SwitchInst::ConstCaseIt Case = SwitchInst::ConstCaseIt::fromSuccessorIndex(SI, SuccNo); OS << Case.getCaseValue()->getValue(); diff --git a/include/llvm/ExecutionEngine/ObjectBuffer.h b/include/llvm/ExecutionEngine/ObjectBuffer.h index 81dc88dcd0..071a42b6b7 100644 --- a/include/llvm/ExecutionEngine/ObjectBuffer.h +++ b/include/llvm/ExecutionEngine/ObjectBuffer.h @@ -58,18 +58,23 @@ protected: class ObjectBufferStream : public ObjectBuffer { void anchor() override; public: - ObjectBufferStream() {} + ObjectBufferStream() : OS(SV) {} virtual ~ObjectBufferStream() {} raw_ostream &getOStream() { return OS; } void flush() { + OS.flush(); + // Make the data accessible via the ObjectBuffer::Buffer - Buffer.reset(MemoryBuffer::getMemBuffer(OS.str(), "", false)); + Buffer.reset(MemoryBuffer::getMemBuffer(StringRef(SV.data(), SV.size()), + "", + false)); } protected: - small_string_ostream<4096> OS; // Working buffer into which we JIT. + SmallVector SV; // Working buffer into which we JIT. + raw_svector_ostream OS; // streaming wrapper }; } // namespace llvm diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index a6bd1afa16..2f02aa7a1c 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -184,7 +184,8 @@ public: O << "|" << DOT::EscapeString(NodeDesc); } - string_ostream EdgeSourceLabels; + std::string edgeSourceLabels; + raw_string_ostream EdgeSourceLabels(edgeSourceLabels); bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node); if (hasEdgeSourceLabels) { diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 14ca2db932..a23faf65bb 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -612,7 +612,8 @@ template typename std::enable_if::value,void>::type yamlize(IO &io, T &Val, bool) { if ( io.outputting() ) { - llvm::string_ostream Buffer; + std::string Storage; + llvm::raw_string_ostream Buffer(Storage); ScalarTraits::output(Val, io.getContext(), Buffer); StringRef Str = Buffer.str(); io.scalarString(Str, ScalarTraits::mustQuote(Str)); diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index ceabf88a57..34fbe082cd 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -15,12 +15,13 @@ #define LLVM_SUPPORT_RAW_OSTREAM_H #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" namespace llvm { class format_object_base; + template + class SmallVectorImpl; namespace sys { namespace fs { @@ -460,14 +461,6 @@ class raw_svector_ostream : public raw_ostream { /// current_pos - Return the current position within the stream, not /// counting the bytes currently in the buffer. uint64_t current_pos() const override; - -protected: - // This constructor is specified not to access \p O provided for storage as it - // may not yet be initialized at construction time. - explicit raw_svector_ostream(SmallVectorImpl &O, std::nullptr_t) - : OS(O){}; - void init(); - public: /// Construct a new raw_svector_ostream. /// @@ -500,25 +493,6 @@ public: ~raw_null_ostream(); }; -/// string_ostream - A raw_ostream that builds a string. This is a -/// raw_svector_ostream with storage. -template -class small_string_ostream : public raw_svector_ostream { - SmallVector Buffer; - // There's no need to flush explicitly. - using raw_svector_ostream::flush; - -public: - small_string_ostream() : raw_svector_ostream(Buffer, nullptr) { init(); } - - void clear() { - flush(); - Buffer.clear(); - } -}; - -typedef small_string_ostream<128> string_ostream; - } // end llvm namespace #endif diff --git a/include/llvm/TableGen/StringToOffsetTable.h b/include/llvm/TableGen/StringToOffsetTable.h index 01829a10b2..c924bd8ec5 100644 --- a/include/llvm/TableGen/StringToOffsetTable.h +++ b/include/llvm/TableGen/StringToOffsetTable.h @@ -42,8 +42,8 @@ public: void EmitString(raw_ostream &O) { // Escape the string. - small_string_ostream<256> Str; - Str.write_escaped(AggregateString); + SmallString<256> Str; + raw_svector_ostream(Str).write_escaped(AggregateString); AggregateString = Str.str(); O << " \""; -- cgit v1.2.3