[PATCH] D58643: [Support] Make raw_string_ostream unbuffered

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 25 12:51:09 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL354819: [Support] Make raw_string_ostream unbuffered (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58643?vs=188237&id=188243#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58643/new/

https://reviews.llvm.org/D58643

Files:
  llvm/trunk/include/llvm/Support/raw_ostream.h


Index: llvm/trunk/include/llvm/Support/raw_ostream.h
===================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h
+++ llvm/trunk/include/llvm/Support/raw_ostream.h
@@ -479,6 +479,9 @@
 
 /// A raw_ostream that writes to an std::string.  This is a simple adaptor
 /// class. This class does not encounter output errors.
+/// raw_string_ostream operates without a buffer, delegating all memory
+/// management to the std::string. Thus the std::string is always up-to-date,
+/// may be used directly and there is no need to call flush().
 class raw_string_ostream : public raw_ostream {
   std::string &OS;
 
@@ -490,13 +493,16 @@
   uint64_t current_pos() const override { return OS.size(); }
 
 public:
-  explicit raw_string_ostream(std::string &O) : OS(O) {}
+  explicit raw_string_ostream(std::string &O)
+      : raw_ostream(/*Unbuffered=*/true), OS(O) {}
+
   ~raw_string_ostream() override;
 
-  /// Flushes the stream contents to the target string and returns  the string's
-  /// reference.
+  // FIXME: uncomment and deal with the fallout.
+  // void flush() = delete;
+
+  /// Returns the string's reference.
   std::string& str() {
-    flush();
     return OS;
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58643.188243.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190225/1efa528b/attachment.bin>


More information about the llvm-commits mailing list