[PATCH] D106899: [LLVM][NFC] Use C++ 14 and C11 noreturn specifier
Alf via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 27 18:05:41 PDT 2021
gAlfonso-bit updated this revision to Diff 362253.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106899/new/
https://reviews.llvm.org/D106899
Files:
lld/include/lld/Common/ErrorHandler.h
llvm/include/llvm/Support/Compiler.h
llvm/tools/llvm-cvtres/llvm-cvtres.cpp
mlir/lib/Interfaces/DataLayoutInterfaces.cpp
Index: mlir/lib/Interfaces/DataLayoutInterfaces.cpp
===================================================================
--- mlir/lib/Interfaces/DataLayoutInterfaces.cpp
+++ mlir/lib/Interfaces/DataLayoutInterfaces.cpp
@@ -23,7 +23,7 @@
/// Reports that the given type is missing the data layout information and
/// exits.
-static LLVM_ATTRIBUTE_NORETURN void reportMissingDataLayout(Type type) {
+LLVM_ATTRIBUTE_NORETURN static void reportMissingDataLayout(Type type) {
std::string message;
llvm::raw_string_ostream os(message);
os << "neither the scoping op nor the type class provide data layout "
Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp
===================================================================
--- llvm/tools/llvm-cvtres/llvm-cvtres.cpp
+++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp
@@ -67,7 +67,7 @@
};
}
-static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
+LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
errs() << Msg;
exit(1);
}
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)
Index: lld/include/lld/Common/ErrorHandler.h
===================================================================
--- lld/include/lld/Common/ErrorHandler.h
+++ lld/include/lld/Common/ErrorHandler.h
@@ -133,7 +133,7 @@
inline void error(const Twine &msg, ErrorTag tag, ArrayRef<StringRef> args) {
errorHandler().error(msg, tag, args);
}
-inline LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &msg) {
+LLVM_ATTRIBUTE_NORETURN inline void fatal(const Twine &msg) {
errorHandler().fatal(msg);
}
inline void log(const Twine &msg) { errorHandler().log(msg); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106899.362253.patch
Type: text/x-patch
Size: 2370 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210728/1a5f5fd1/attachment.bin>
More information about the llvm-commits
mailing list