[PATCH] D106899: [LLVM][NFC] Remove LLVM_ATTRIBUTE_NORETURN and use [[noreturn]] directly

Alf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 28 10:07:52 PDT 2021


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

Rebased


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

https://reviews.llvm.org/D106899

Files:
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
  flang/include/flang/Optimizer/Support/FatalError.h
  lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
  lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
  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)
Index: lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
===================================================================
--- lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -29,7 +29,7 @@
 #if defined(__arm64__) || defined(__aarch64__)
 namespace {
 
-void LLVM_ATTRIBUTE_NORETURN Child() {
+[[noreturn]] void Child() {
   if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
     _exit(1);
 
Index: lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
===================================================================
--- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -46,8 +46,7 @@
 #endif
 }
 
-static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
-                                                  const char *operation) {
+[[noreturn]] static void ExitWithError(int error_fd, const char *operation) {
   int err = errno;
   llvm::raw_fd_ostream os(error_fd, true);
   os << operation << " failed: " << llvm::sys::StrError(err);
@@ -88,7 +87,7 @@
   return;
 }
 
-static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
+[[noreturn]] static void ChildFunc(int error_fd,
                                               const ProcessLaunchInfo &info) {
   if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
     if (setpgid(0, 0) != 0)
Index: flang/include/flang/Optimizer/Support/FatalError.h
===================================================================
--- flang/include/flang/Optimizer/Support/FatalError.h
+++ flang/include/flang/Optimizer/Support/FatalError.h
@@ -20,8 +20,8 @@
 
 /// Fatal error reporting helper. Report a fatal error with a source location
 /// and immediately abort flang.
-LLVM_ATTRIBUTE_NORETURN inline void emitFatalError(mlir::Location loc,
-                                                   const llvm::Twine &message) {
+[[noreturn]] inline void emitFatalError(mlir::Location loc,
+                                        const llvm::Twine &message) {
   mlir::emitError(loc, message);
   llvm::report_fatal_error("aborting");
 }
Index: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
===================================================================
--- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -614,7 +614,7 @@
     return It->second.Root;
   }
 
-  LLVM_ATTRIBUTE_NORETURN void PrintFatalError(llvm::Twine const &Msg) const {
+  [[noreturn]] void PrintFatalError(llvm::Twine const &Msg) const {
     assert(EvaluatingRecord && "not evaluating a record?");
     llvm::PrintFatalError(EvaluatingRecord->getLoc(), Msg);
   }
Index: clang-tools-extra/pp-trace/PPTrace.cpp
===================================================================
--- clang-tools-extra/pp-trace/PPTrace.cpp
+++ clang-tools-extra/pp-trace/PPTrace.cpp
@@ -69,7 +69,7 @@
     cl::desc("Output trace to the given file name or '-' for stdout."),
     cl::cat(Cat));
 
-LLVM_ATTRIBUTE_NORETURN static void error(Twine Message) {
+[[noreturn]] static void error(Twine Message) {
   WithColor::error() << Message << '\n';
   exit(1);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106899.362437.patch
Type: text/x-patch
Size: 3997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210728/daa28926/attachment.bin>


More information about the cfe-commits mailing list