[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:25:43 PST 2024


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

>From 9ffa852f502fc6d098b3cd657768de1381865e84 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 11c920e32657c2b..7c32665c624f373 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