[libc-commits] [PATCH] D141095: [libc] add noexcept to external function headers

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jan 6 11:43:54 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b8a64b88dbc: [libc] add noexcept to external function headers (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141095/new/

https://reviews.llvm.org/D141095

Files:
  libc/config/linux/api.td
  libc/include/__llvm-libc-common.h
  libc/test/src/time/gmtime_test.cpp
  libc/test/src/time/mktime_test.cpp
  libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
  libc/utils/HdrGen/PublicAPICommand.cpp


Index: libc/utils/HdrGen/PublicAPICommand.cpp
===================================================================
--- libc/utils/HdrGen/PublicAPICommand.cpp
+++ libc/utils/HdrGen/PublicAPICommand.cpp
@@ -112,7 +112,7 @@
         OS << ", ";
     }
 
-    OS << ");\n\n";
+    OS << ") __NOEXCEPT;\n\n";
   }
 
   // Make another pass over entrypoints to emit object declarations.
Index: libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
===================================================================
--- libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
+++ libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp
@@ -81,7 +81,7 @@
       if (i < size - 1)
         OS << ", ";
     }
-    OS << "), decltype(" << entrypoint << ")>, ";
+    OS << ") __NOEXCEPT, decltype(" << entrypoint << ")>, ";
     OS << '"' << entrypoint
        << " prototype in TableGen does not match public header" << '"';
     OS << ");\n";
@@ -93,9 +93,9 @@
 
   // We provide dummy malloc and free implementations to support the case
   // when LLVM libc does to include them.
-  OS << "void *malloc(size_t) { return nullptr; }\n";
-  OS << "void *realloc(void *, size_t) { return nullptr; }\n";
-  OS << "void free(void *) {}\n";
+  OS << "void *malloc(size_t) __NOEXCEPT { return nullptr; }\n";
+  OS << "void *realloc(void *, size_t) __NOEXCEPT { return nullptr; }\n";
+  OS << "void free(void *) __NOEXCEPT {}\n";
 
   return false;
 }
Index: libc/test/src/time/mktime_test.cpp
===================================================================
--- libc/test/src/time/mktime_test.cpp
+++ libc/test/src/time/mktime_test.cpp
@@ -15,7 +15,6 @@
 
 #include <errno.h>
 #include <limits.h>
-#include <string.h>
 
 using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
 using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
Index: libc/test/src/time/gmtime_test.cpp
===================================================================
--- libc/test/src/time/gmtime_test.cpp
+++ libc/test/src/time/gmtime_test.cpp
@@ -14,7 +14,6 @@
 
 #include <errno.h>
 #include <limits.h>
-#include <string.h>
 
 using __llvm_libc::testing::ErrnoSetterMatcher::Fails;
 using __llvm_libc::testing::ErrnoSetterMatcher::Succeeds;
Index: libc/include/__llvm-libc-common.h
===================================================================
--- libc/include/__llvm-libc-common.h
+++ libc/include/__llvm-libc-common.h
@@ -32,6 +32,9 @@
 #undef _Thread_local
 #define _Thread_local thread_local
 
+#undef __NOEXCEPT
+#define __NOEXCEPT noexcept
+
 #else // not __cplusplus
 
 #undef __BEGIN_C_DECLS
@@ -43,6 +46,9 @@
 #undef __restrict
 #define __restrict restrict // C99 and above support the restrict keyword.
 
+#undef __NOEXCEPT
+#define __NOEXCEPT
+
 #endif // __cplusplus
 
 #endif // LLVM_LIBC___COMMON_H
Index: libc/config/linux/api.td
===================================================================
--- libc/config/linux/api.td
+++ libc/config/linux/api.td
@@ -18,7 +18,7 @@
     #ifdef __cplusplus
     extern "C"
     #endif
-    _Noreturn void __assert_fail(const char *, const char *, unsigned, const char *);
+    _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__))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141095.486950.patch
Type: text/x-patch
Size: 3314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230106/ba045efa/attachment-0001.bin>


More information about the libc-commits mailing list