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

Benjamin Kramer via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 23 07:34:11 PST 2024


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

>From bd05c8de0f8693f8ae3445a3f263c69e3e8430d6 Mon Sep 17 00:00:00 2001
From: Benjamin Kramer <benny.kra at googlemail.com>
Date: Sat, 13 Jan 2024 18:23:05 +0100
Subject: [PATCH] [libc++] Annotate generic_category/system_category as const

This lets the compiler eliminate unused/duplicate calls to it.
---
 libcxx/include/__system_error/error_category.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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