[libcxx-commits] [libcxx] [libc++] Fixes istream::sync. (PR #76467)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 27 11:39:29 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 8cf6bcf5a30673dd8a234ae3ef4ab4c1e63786b1 a717b7ede0d2d4cce8479d4e532165b4fbde2ae8 -- libcxx/include/istream libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
index 8209cfd310..7c2f1f8100 100644
--- a/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
+++ b/libcxx/test/std/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
@@ -49,17 +49,14 @@ protected:
 };
 
 template <class CharT>
-struct testbuf_pubsync_error
-    : public std::basic_streambuf<CharT>
-{
+struct testbuf_pubsync_error : public std::basic_streambuf<CharT> {
 public:
+  testbuf_pubsync_error() {}
 
-    testbuf_pubsync_error() {}
 protected:
-    virtual int sync() { return -1; }
+  virtual int sync() { return -1; }
 };
 
-
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct testbuf_exception { };
 
@@ -97,10 +94,10 @@ protected:
 
 int main(int, char**)
 {
-    {
-        std::istream is(nullptr);
-        assert(is.sync() == -1);
-    }
+  {
+    std::istream is(nullptr);
+    assert(is.sync() == -1);
+  }
     {
         testbuf<char> sb(" 123456789");
         std::istream is(&sb);
@@ -108,18 +105,18 @@ int main(int, char**)
         assert(sync_called == 1);
     }
     {
-        testbuf_pubsync_error<char> sb;
-        std::istream is(&sb);
-        is.exceptions(std::ios_base::failbit | std::ios_base::eofbit);
-        assert(is.sync() == -1);
-        assert( is.bad());
-        assert(!is.eof());
-        assert( is.fail());
+      testbuf_pubsync_error<char> sb;
+      std::istream is(&sb);
+      is.exceptions(std::ios_base::failbit | std::ios_base::eofbit);
+      assert(is.sync() == -1);
+      assert(is.bad());
+      assert(!is.eof());
+      assert(is.fail());
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     {
-        std::wistream is(nullptr);
-        assert(is.sync() == -1);
+      std::wistream is(nullptr);
+      assert(is.sync() == -1);
     }
     {
         testbuf<wchar_t> sb(L" 123456789");
@@ -128,30 +125,30 @@ int main(int, char**)
         assert(sync_called == 2);
     }
     {
-        testbuf_pubsync_error<wchar_t> sb;
-        std::wistream is(&sb);
-        is.exceptions(std::ios_base::failbit | std::ios_base::eofbit);
-        assert(is.sync() == -1);
-        assert( is.bad());
-        assert(!is.eof());
-        assert( is.fail());
+      testbuf_pubsync_error<wchar_t> sb;
+      std::wistream is(&sb);
+      is.exceptions(std::ios_base::failbit | std::ios_base::eofbit);
+      assert(is.sync() == -1);
+      assert(is.bad());
+      assert(!is.eof());
+      assert(is.fail());
     }
 #endif
 #ifndef TEST_HAS_NO_EXCEPTIONS
     {
-        testbuf_pubsync_error<char> sb;
-        std::istream is(&sb);
-        is.exceptions(std::ios_base::badbit);
-        bool threw = false;
-        try {
-            is.sync();
-        } catch (std::ios_base::failure const&) {
-            threw = true;
-        }
-        assert( is.bad());
-        assert(!is.eof());
-        assert( is.fail());
-        assert(threw);
+      testbuf_pubsync_error<char> sb;
+      std::istream is(&sb);
+      is.exceptions(std::ios_base::badbit);
+      bool threw = false;
+      try {
+        is.sync();
+      } catch (std::ios_base::failure const&) {
+        threw = true;
+      }
+      assert(is.bad());
+      assert(!is.eof());
+      assert(is.fail());
+      assert(threw);
     }
     {
         throwing_testbuf<char> sb(" 123456789");
@@ -170,19 +167,19 @@ int main(int, char**)
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     {
-        testbuf_pubsync_error<wchar_t> sb;
-        std::wistream is(&sb);
-        is.exceptions(std::ios_base::badbit);
-        bool threw = false;
-        try {
-            is.sync();
-        } catch (std::ios_base::failure const&) {
-            threw = true;
-        }
-        assert( is.bad());
-        assert(!is.eof());
-        assert( is.fail());
-        assert(threw);
+      testbuf_pubsync_error<wchar_t> sb;
+      std::wistream is(&sb);
+      is.exceptions(std::ios_base::badbit);
+      bool threw = false;
+      try {
+        is.sync();
+      } catch (std::ios_base::failure const&) {
+        threw = true;
+      }
+      assert(is.bad());
+      assert(!is.eof());
+      assert(is.fail());
+      assert(threw);
     }
     {
         throwing_testbuf<wchar_t> sb(L" 123456789");
@@ -199,7 +196,7 @@ int main(int, char**)
         assert( is.fail());
         assert(threw);
     }
-#endif // TEST_HAS_NO_WIDE_CHARACTERS
+#  endif // TEST_HAS_NO_WIDE_CHARACTERS
 #endif // TEST_HAS_NO_EXCEPTIONS
 
     return 0;

``````````

</details>


https://github.com/llvm/llvm-project/pull/76467


More information about the libcxx-commits mailing list