[libcxx-commits] [libcxx] [libc++] Annotate generic_category/system_category as const (PR #78052)

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 13 09:26:57 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Benjamin Kramer (d0k)

<details>
<summary>Changes</summary>

This lets the compiler eliminate unused/duplicate calls to it.

---
Full diff: https://github.com/llvm/llvm-project/pull/78052.diff


1 Files Affected:

- (modified) libcxx/include/__system_error/error_category.h (+2-2) 


``````````diff
diff --git a/libcxx/include/__system_error/error_category.h b/libcxx/include/__system_error/error_category.h
index 11c920e32657c2..7233e221104471 100644
--- a/libcxx/include/__system_error/error_category.h
+++ b/libcxx/include/__system_error/error_category.h
@@ -67,8 +67,8 @@ class _LIBCPP_HIDDEN __do_message : public error_category {
   string message(int __ev) const override;
 };
 
-_LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
-_LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
+[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
+[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
 
 _LIBCPP_END_NAMESPACE_STD
 

``````````

</details>


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


More information about the libcxx-commits mailing list