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

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 26 13:08:41 PST 2024


Author: Benjamin Kramer
Date: 2024-01-26T22:08:36+01:00
New Revision: 3fa14233c4631ad1062553883835a5d5b36f2fe6

URL: https://github.com/llvm/llvm-project/commit/3fa14233c4631ad1062553883835a5d5b36f2fe6
DIFF: https://github.com/llvm/llvm-project/commit/3fa14233c4631ad1062553883835a5d5b36f2fe6.diff

LOG: [libc++] Annotate generic_category/system_category as const (#78052)

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

Added: 
    

Modified: 
    libcxx/include/__system_error/error_category.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__system_error/error_category.h b/libcxx/include/__system_error/error_category.h
index 11c920e32657c2..bfe7bc24a5d3dc 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;
+__attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
+__attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
 
 _LIBCPP_END_NAMESPACE_STD
 


        


More information about the libcxx-commits mailing list