[libc-commits] [libc] [libc] newheadergen: added assert.yaml (PR #98826)
via libc-commits
libc-commits at lists.llvm.org
Sun Jul 14 11:11:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (aaryanshukla)
<details>
<summary>Changes</summary>
- removed assert macro definitions in api.td
- included macro definitions in assert.h.def
- added assert.yaml
---
Full diff: https://github.com/llvm/llvm-project/pull/98826.diff
5 Files Affected:
- (modified) libc/config/baremetal/api.td (-35)
- (modified) libc/config/gpu/api.td (-29)
- (modified) libc/config/linux/api.td (-36)
- (modified) libc/include/assert.h.def (+20)
- (added) libc/newhdrgen/yaml/assert.yaml (+16)
``````````diff
diff --git a/libc/config/baremetal/api.td b/libc/config/baremetal/api.td
index a6547d843c85e..7421d86fabeb0 100644
--- a/libc/config/baremetal/api.td
+++ b/libc/config/baremetal/api.td
@@ -5,41 +5,6 @@ include "spec/stdc_ext.td"
include "spec/bsd_ext.td"
include "spec/llvm_libc_stdfix_ext.td"
-def AssertMacro : MacroDef<"assert"> {
- let Defn = [{
- #undef assert
-
- #ifdef NDEBUG
- #define assert(e) (void)0
- #else
-
- #ifdef __cplusplus
- extern "C"
- #endif
- _Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
-
- #define assert(e) \
- ((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
-
- #endif
- }];
-}
-
-def StaticAssertMacro : MacroDef<"static_assert"> {
- let Defn = [{
- #ifndef __cplusplus
- #undef static_assert
- #define static_assert _Static_assert
- #endif
- }];
-}
-
-def AssertAPI : PublicAPI<"assert.h"> {
- let Macros = [
- AssertMacro,
- StaticAssertMacro,
- ];
-}
def CTypeAPI : PublicAPI<"ctype.h"> {
}
diff --git a/libc/config/gpu/api.td b/libc/config/gpu/api.td
index 21ddbb95b70c9..995ff31c4ac9e 100644
--- a/libc/config/gpu/api.td
+++ b/libc/config/gpu/api.td
@@ -7,35 +7,6 @@ include "spec/gnu_ext.td"
include "spec/stdc_ext.td"
include "spec/llvm_libc_ext.td"
-def AssertMacro : MacroDef<"assert"> {
- let Defn = [{
- #undef assert
-
- #ifdef NDEBUG
- #define assert(e) (void)0
- #else
-
- #define assert(e) \
- ((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
- #endif
- }];
-}
-
-def StaticAssertMacro : MacroDef<"static_assert"> {
- let Defn = [{
- #ifndef __cplusplus
- #undef static_assert
- #define static_assert _Static_assert
- #endif
- }];
-}
-
-def AssertAPI : PublicAPI<"assert.h"> {
- let Macros = [
- AssertMacro,
- StaticAssertMacro,
- ];
-}
def StringAPI : PublicAPI<"string.h"> {
let Types = ["size_t"];
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index 60e9b70f0d8a4..a10dec06e2452 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -9,42 +9,6 @@ include "spec/stdc_ext.td"
include "spec/llvm_libc_ext.td"
include "spec/llvm_libc_stdfix_ext.td"
-def AssertMacro : MacroDef<"assert"> {
- let Defn = [{
- #undef assert
-
- #ifdef NDEBUG
- #define assert(e) (void)0
- #else
-
- #ifdef __cplusplus
- extern "C"
- #endif
- _Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
-
- #define assert(e) \
- ((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
-
- #endif
- }];
-}
-
-def StaticAssertMacro : MacroDef<"static_assert"> {
- let Defn = [{
- #ifndef __cplusplus
- #undef static_assert
- #define static_assert _Static_assert
- #endif
- }];
-}
-
-def AssertAPI : PublicAPI<"assert.h"> {
- let Macros = [
- AssertMacro,
- StaticAssertMacro,
- ];
-}
-
def CTypeAPI : PublicAPI<"ctype.h"> {
}
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index 15077e53e2ca4..9c924c7f58545 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -12,4 +12,24 @@
// This file may be usefully included multiple times to change assert()'s
// definition based on NDEBUG.
+
+#undef assert
+#ifdef NDEBUG
+#define assert(e) (void)0
+#else
+
+#ifndef __cplusplus
+#undef static_assert
+#define static_assert _Static_assert
+#endif
+
+#ifdef __cplusplus
+extern "C"
+#endif
+_Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
+
+#define assert(e) \
+ ((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#endif
+
%%public_api()
diff --git a/libc/newhdrgen/yaml/assert.yaml b/libc/newhdrgen/yaml/assert.yaml
new file mode 100644
index 0000000000000..9ad0f0628274e
--- /dev/null
+++ b/libc/newhdrgen/yaml/assert.yaml
@@ -0,0 +1,16 @@
+header: assert.h
+macros: []
+types: []
+enums: []
+objects: []
+functions:
+ - name: __assert_fail
+ standards:
+ - llvm_libc_ext
+ return_type: _Noreturn void
+ arguments:
+ - type: const char *
+ - type: const char *
+ - type: unsigned
+ - type: const char *
+ guard: __cplusplus
``````````
</details>
https://github.com/llvm/llvm-project/pull/98826
More information about the libc-commits
mailing list