[libc-commits] [libc] [libc] Use __attribute__((__nothrow__)) for __NOEXCEPT in C (PR #114653)
via libc-commits
libc-commits at lists.llvm.org
Sat Nov 2 02:34:45 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Roland McGrath (frobtech)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/114653.diff
1 Files Affected:
- (modified) libc/include/__llvm-libc-common.h (+7)
``````````diff
diff --git a/libc/include/__llvm-libc-common.h b/libc/include/__llvm-libc-common.h
index 3af0b08e9e8668..22dc78e6966e14 100644
--- a/libc/include/__llvm-libc-common.h
+++ b/libc/include/__llvm-libc-common.h
@@ -47,7 +47,14 @@
#define __restrict restrict // C99 and above support the restrict keyword.
#undef __NOEXCEPT
+#if defined(__has_attribute)
+#if __has_attribute(__nothrow__)
+#define __NOEXCEPT __attribute__((__nothrow__))
+#endif // __has_attribute(__nothrow__)
+#endif // defined(__has_attribute)
+#ifndef __NOEXCEPT
#define __NOEXCEPT
+#endif
#endif // __cplusplus
``````````
</details>
https://github.com/llvm/llvm-project/pull/114653
More information about the libc-commits
mailing list