[libc-commits] [libc] 0b91d77 - [libc] Use __attribute__((__nothrow__)) for __NOEXCEPT in C (#114653)

via libc-commits libc-commits at lists.llvm.org
Tue Dec 17 12:18:41 PST 2024


Author: Roland McGrath
Date: 2024-12-17T12:18:37-08:00
New Revision: 0b91d77bf4e4ff65ebeed90acd141018d9889e0f

URL: https://github.com/llvm/llvm-project/commit/0b91d77bf4e4ff65ebeed90acd141018d9889e0f
DIFF: https://github.com/llvm/llvm-project/commit/0b91d77bf4e4ff65ebeed90acd141018d9889e0f.diff

LOG: [libc] Use __attribute__((__nothrow__)) for __NOEXCEPT in C (#114653)

Consistent with glibc headers, where `noexcept` is used in C++
(or `throw()` in older C++ which llvm-libc doesn't support) in
the public function declarations, `__attribute__((__nothrow__))` is
used in C for compilers that support it.

Added: 
    

Modified: 
    libc/include/__llvm-libc-common.h

Removed: 
    


################################################################################
diff  --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index e0e29bbbd5f87c..d54ee7b9f91f32 100644
--- a/libc/include/__llvm-libc-common.h
+++ b/libc/include/__llvm-libc-common.h
@@ -53,7 +53,11 @@
 #define __restrict restrict // C99 and above support the restrict keyword.
 
 #undef __NOEXCEPT
+#ifdef __GNUC__
+#define __NOEXCEPT __attribute__((__nothrow__))
+#else
 #define __NOEXCEPT
+#endif
 
 #endif // __cplusplus
 


        


More information about the libc-commits mailing list