[libcxx-commits] [libcxx] [libc++] Applied `[[nodiscard]]` to `<fstream>`, `<sstream>`, `<strstream>`, `<synchstream>` (PR #173842)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 29 01:03:43 PST 2025


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 origin/main HEAD --extensions ,cpp -- libcxx/test/libcxx/input.output/file.streams/fstreams/nodiscard.verify.cpp libcxx/test/libcxx/input.output/string.streams/nodiscard.verify.cpp libcxx/test/libcxx/input.output/synchstream/nodiscard.verify.cpp libcxx/include/fstream libcxx/include/sstream libcxx/include/strstream libcxx/include/syncstream --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index a0ff33023..3f81d4217 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -269,7 +269,7 @@ public:
   _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode);
   basic_filebuf* close();
 #    if _LIBCPP_STD_VER >= 26
-  [[nodiscard]]_LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept {
     _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened");
 #      if defined(_LIBCPP_WIN32API)
     return std::__filebuf_windows_native_handle(__file_);
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 78962a6e5..a42e8fbc9 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -968,7 +968,9 @@ public:
     return __sb_.str(__sa);
   }
 
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept {
+    return __sb_.view();
+  }
 #    endif // _LIBCPP_STD_VER >= 20
 
   _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
@@ -1106,7 +1108,9 @@ public:
     return __sb_.str(__sa);
   }
 
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept {
+    return __sb_.view();
+  }
 #    endif // _LIBCPP_STD_VER >= 20
 
   _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }

``````````

</details>


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


More information about the libcxx-commits mailing list