[llvm] 6b8cf73 - Revert "[Support] Add raw_ostream_iterator: ostream_iterator for raw_ostream"

Nicolas Guillemot via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 4 12:47:01 PST 2021


Author: Nicolas Guillemot
Date: 2021-03-04T12:46:58-08:00
New Revision: 6b8cf7356c5a01ee487a610168c146994ff6cff8

URL: https://github.com/llvm/llvm-project/commit/6b8cf7356c5a01ee487a610168c146994ff6cff8
DIFF: https://github.com/llvm/llvm-project/commit/6b8cf7356c5a01ee487a610168c146994ff6cff8.diff

LOG: Revert "[Support] Add raw_ostream_iterator: ostream_iterator for raw_ostream"

This reverts commit 7479a2e00bc41f399942e5106fbdf9b4b0c11506.

This commit causes compile errors on clang-x64-windows-msvc, so I'm
reverting the patch for now.

For reference, the error in question is:

```
error C2280: 'llvm::raw_ostream_iterator<char,char>
&llvm::raw_ostream_iterator<char,char>::operator =(const
llvm::raw_ostream_iterator<char,char> &)': attempting to reference a deleted
function

note: compiler has generated 'llvm::raw_ostream_iterator<char,char>::operator ='
here

note: 'llvm::raw_ostream_iterator<char,char>
&llvm::raw_ostream_iterator<char,char>::operator =(const
llvm::raw_ostream_iterator<char,char> &)': function was implicitly deleted
because 'llvm::raw_ostream_iterator<char,char>' has a data member
'llvm::raw_ostream_iterator<char,char>::OutStream' of reference type
```

Added: 
    

Modified: 
    llvm/include/llvm/Support/raw_ostream.h
    llvm/unittests/Support/raw_ostream_test.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index ef235482a673..201a4a857964 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -21,7 +21,6 @@
 #include <cstddef>
 #include <cstdint>
 #include <cstring>
-#include <iterator>
 #include <string>
 #include <system_error>
 #include <type_traits>
@@ -715,66 +714,6 @@ class buffer_unique_ostream : public raw_svector_ostream {
   ~buffer_unique_ostream() override { *OS << str(); }
 };
 
-/// Wrapper to make a raw_ostream look like an output iterator.
-/// Designed to match the API of std::ostream_iterator.
-/// Enables reusing STL algorithms with raw_ostream. For example:
-///
-/// \code{.cpp}
-///
-/// std::vector<int> V = { 1, 2, 3 };
-/// std::copy(V.begin(), V.end(), raw_ostream_iterator<int>(outs(), ", "));
-///
-/// \endcode
-///
-/// The code above outputs: "1, 2, 3, "
-template <class T, class CharT = char> class raw_ostream_iterator {
-  raw_ostream &OutStream;
-  const CharT *Delim;
-
-public:
-  using iterator_category = std::output_iterator_tag;
-  using value_type = void;
-  using 
diff erence_type = void;
-  using pointer = void;
-  using reference = void;
-  using char_type = CharT;
-
-  /// Constructs the iterator with \p Stream as the associated stream and \p
-  /// Delim as the delimiter.
-  ///
-  /// \param Stream The output stream to be accessed by this iterator.
-  ///
-  /// \param Delim The null-terminated character string to be inserted into the
-  /// stream after each output.
-  raw_ostream_iterator(raw_ostream &Stream, const CharT *Delim)
-      : OutStream(Stream), Delim(Delim) {}
-
-  /// Constructs the iterator with \p Stream as the associated stream and a null
-  /// pointer as the delimiter.
-  ///
-  /// \param Stream The output stream to be accessed by this iterator.
-  raw_ostream_iterator(raw_ostream &Stream)
-      : OutStream(Stream), Delim(nullptr) {}
-
-  /// Inserts \p Value into the associated stream, then inserts the delimiter,
-  /// if one was specified at construction time.
-  ///
-  /// \param value The object to insert.
-  raw_ostream_iterator &operator=(const T &Value) {
-    OutStream << Value;
-    if (Delim != 0)
-      OutStream << Delim;
-    return *this;
-  }
-
-  /// No-op. Provided to satisfy the requirements of LegacyOutputIterator.
-  ///@{
-  raw_ostream_iterator &operator*() { return *this; }
-  raw_ostream_iterator &operator++() { return *this; }
-  raw_ostream_iterator &operator++(int) { return *this; }
-  ///@}
-};
-
 } // end namespace llvm
 
 #endif // LLVM_SUPPORT_RAW_OSTREAM_H

diff  --git a/llvm/unittests/Support/raw_ostream_test.cpp b/llvm/unittests/Support/raw_ostream_test.cpp
index 2c0d37bbcabb..78fdb04bcdaa 100644
--- a/llvm/unittests/Support/raw_ostream_test.cpp
+++ b/llvm/unittests/Support/raw_ostream_test.cpp
@@ -377,114 +377,6 @@ TEST(raw_fd_ostreamTest, multiple_raw_fd_ostream_to_stdout) {
   { raw_fd_ostream("-", EC, sys::fs::OpenFlags::OF_None); }
 }
 
-// Basic functionality tests for raw_ostream_iterator.
-TEST(raw_ostream_iteratorTest, raw_ostream_iterator_basic) {
-  std::string S;
-
-  // Expect no output if nothing is written to the iterator.
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<char> It(Str);
-  }
-  EXPECT_EQ(S, "");
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<char> It(Str, ",");
-  }
-  EXPECT_EQ(S, "");
-
-  // Output one char.
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<char> It(Str);
-    *It = 'x';
-  }
-  EXPECT_EQ(S, "x");
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<char> It(Str, ",");
-    *It = 'x';
-  }
-  EXPECT_EQ(S, "x,");
-
-  // Output one int.
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<int> It(Str);
-    *It = 5;
-  }
-  EXPECT_EQ(S, "5");
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<int> It(Str, ",");
-    *It = 5;
-  }
-  EXPECT_EQ(S, "5,");
-
-  // Output a few ints.
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<int> It(Str);
-    *It = 5;
-    *It = 3;
-    *It = 2;
-  }
-  EXPECT_EQ(S, "532");
-  {
-    S = "";
-    raw_string_ostream Str(S);
-    raw_ostream_iterator<int> It(Str, ",");
-    *It = 5;
-    *It = 3;
-    *It = 2;
-  }
-  EXPECT_EQ(S, "5,3,2,");
-}
-
-template <class T, class InputIt>
-std::string iterator_str(InputIt First, InputIt Last) {
-  std::string S;
-  {
-    raw_string_ostream Str(S);
-    std::copy(First, Last, raw_ostream_iterator<T>(Str));
-  }
-  return S;
-}
-
-template <class T, class InputIt>
-std::string iterator_str(InputIt First, InputIt Last, const char *Delim) {
-  std::string S;
-  {
-    raw_string_ostream Str(S);
-    std::copy(First, Last, raw_ostream_iterator<T>(Str, Delim));
-  }
-  return S;
-}
-
-// Test using raw_ostream_iterator as an output iterator with a std algorithm.
-TEST(raw_ostream_iteratorTest, raw_ostream_iterator_std_copy) {
-  // Test the empty case.
-  std::vector<char> Empty = {};
-  EXPECT_EQ("", iterator_str<char>(Empty.begin(), Empty.end()));
-  EXPECT_EQ("", iterator_str<char>(Empty.begin(), Empty.end(), ", "));
-
-  // Test without a delimiter.
-  std::vector<char> V1 = {'a', 'b', 'c'};
-  EXPECT_EQ("abc", iterator_str<char>(V1.begin(), V1.end()));
-
-  // Test with a delimiter.
-  std::vector<int> V2 = {1, 2, 3};
-  EXPECT_EQ("1, 2, 3, ", iterator_str<int>(V2.begin(), V2.end(), ", "));
-}
-
-
 TEST(raw_ostreamTest, flush_tied_to_stream_on_write) {
   std::string TiedToBuffer;
   raw_string_ostream TiedTo(TiedToBuffer);


        


More information about the llvm-commits mailing list