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

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


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

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

>From f01fc83c5be6c6199c15b24edbc625247f4faaf4 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..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
 



More information about the libcxx-commits mailing list