[PATCH] D106899: [LLVM] Use C++ 14 and C11 noreturn specifier

Alf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 27 13:10:44 PDT 2021


gAlfonso-bit updated this revision to Diff 362153.
gAlfonso-bit added a comment.

Removed unneeded formatting changes


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

https://reviews.llvm.org/D106899

Files:
  llvm/include/llvm/Support/Compiler.h


Index: llvm/include/llvm/Support/Compiler.h
===================================================================
--- llvm/include/llvm/Support/Compiler.h
+++ llvm/include/llvm/Support/Compiler.h
@@ -242,7 +242,14 @@
 #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline
 #endif
 
-#ifdef __GNUC__
+// C++14 and up has [[noreturn]]
+#if defined(__cplusplus) && __cplusplus > 201300 &&                            \
+    LLVM_HAS_CPP_ATTRIBUTE(noreturn)
+#define LLVM_ATTRIBUTE_NORETURN [[noreturn]]
+// C11 and up has _Noreturn
+#elif !defined(__cplusplus) && __STDC_VERSION__ > 201112L
+#define LLVM_ATTRIBUTE_NORETURN _Noreturn;
+#elif defined(__GNUC__) || __has_attribute(noreturn)
 #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn))
 #elif defined(_MSC_VER)
 #define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106899.362153.patch
Type: text/x-patch
Size: 811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210727/6e0ad09e/attachment.bin>


More information about the llvm-commits mailing list