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); } 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: 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: 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: 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: llvm/include/llvm/MC/MCContext.h =================================================================== --- llvm/include/llvm/MC/MCContext.h +++ llvm/include/llvm/MC/MCContext.h @@ -817,7 +817,7 @@ // Unrecoverable error has occurred. Display the best diagnostic we can // and bail via exit(1). For now, most MC backend errors are unrecoverable. // FIXME: We should really do something about that. - LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg); + [[noreturn]] void reportFatalError(SMLoc L, const Twine &Msg); const MCAsmMacro *lookupMacro(StringRef Name) { StringMap::iterator I = MacroMap.find(Name); Index: llvm/include/llvm/Support/Compiler.h =================================================================== --- llvm/include/llvm/Support/Compiler.h +++ llvm/include/llvm/Support/Compiler.h @@ -242,14 +242,6 @@ #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline #endif -#ifdef __GNUC__ -#define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) -#elif defined(_MSC_VER) -#define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) -#else -#define LLVM_ATTRIBUTE_NORETURN -#endif - #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #elif defined(_MSC_VER) Index: llvm/include/llvm/Support/CrashRecoveryContext.h =================================================================== --- llvm/include/llvm/Support/CrashRecoveryContext.h +++ llvm/include/llvm/Support/CrashRecoveryContext.h @@ -99,8 +99,7 @@ /// Explicitly trigger a crash recovery in the current process, and /// return failure from RunSafely(). This function does not return. - LLVM_ATTRIBUTE_NORETURN - void HandleExit(int RetCode); + [[noreturn]] void HandleExit(int RetCode); /// Throw again a signal or an exception, after it was catched once by a /// CrashRecoveryContext. Index: llvm/include/llvm/Support/Error.h =================================================================== --- llvm/include/llvm/Support/Error.h +++ llvm/include/llvm/Support/Error.h @@ -257,8 +257,7 @@ // of debug prints can cause the function to be too large for inlining. So // it's important that we define this function out of line so that it can't be // inlined. - LLVM_ATTRIBUTE_NORETURN - void fatalUncheckedError() const; + [[noreturn]] void fatalUncheckedError() const; #endif void assertIsChecked() { @@ -688,9 +687,7 @@ } #if LLVM_ENABLE_ABI_BREAKING_CHECKS - LLVM_ATTRIBUTE_NORETURN - LLVM_ATTRIBUTE_NOINLINE - void fatalUncheckedExpected() const { + [[noreturn]] LLVM_ATTRIBUTE_NOINLINE void fatalUncheckedExpected() const { dbgs() << "Expected must be checked before access or destruction.\n"; if (HasError) { dbgs() << "Unchecked Expected contained error:\n"; @@ -722,8 +719,7 @@ /// Report a serious error, calling any installed error handler. See /// ErrorHandling.h. -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, - bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(Error Err, bool gen_crash_diag = true); /// Report a fatal error if Err is a failure value. /// Index: llvm/include/llvm/Support/ErrorHandling.h =================================================================== --- llvm/include/llvm/Support/ErrorHandling.h +++ llvm/include/llvm/Support/ErrorHandling.h @@ -19,46 +19,46 @@ namespace llvm { class StringRef; - class Twine; - - /// An error handler callback. - typedef void (*fatal_error_handler_t)(void *user_data, - const std::string& reason, - bool gen_crash_diag); - - /// install_fatal_error_handler - Installs a new error handler to be used - /// whenever a serious (non-recoverable) error is encountered by LLVM. - /// - /// If no error handler is installed the default is to print the error message - /// to stderr, and call exit(1). If an error handler is installed then it is - /// the handler's responsibility to log the message, it will no longer be - /// printed to stderr. If the error handler returns, then exit(1) will be - /// called. - /// - /// It is dangerous to naively use an error handler which throws an exception. - /// Even though some applications desire to gracefully recover from arbitrary - /// faults, blindly throwing exceptions through unfamiliar code isn't a way to - /// achieve this. - /// - /// \param user_data - An argument which will be passed to the install error - /// handler. - void install_fatal_error_handler(fatal_error_handler_t handler, - void *user_data = nullptr); - - /// Restores default error handling behaviour. - void remove_fatal_error_handler(); - - /// ScopedFatalErrorHandler - This is a simple helper class which just - /// calls install_fatal_error_handler in its constructor and - /// remove_fatal_error_handler in its destructor. - struct ScopedFatalErrorHandler { - explicit ScopedFatalErrorHandler(fatal_error_handler_t handler, - void *user_data = nullptr) { - install_fatal_error_handler(handler, user_data); - } - - ~ScopedFatalErrorHandler() { remove_fatal_error_handler(); } - }; +class Twine; + +/// An error handler callback. +typedef void (*fatal_error_handler_t)(void *user_data, + const std::string &reason, + bool gen_crash_diag); + +/// install_fatal_error_handler - Installs a new error handler to be used +/// whenever a serious (non-recoverable) error is encountered by LLVM. +/// +/// If no error handler is installed the default is to print the error message +/// to stderr, and call exit(1). If an error handler is installed then it is +/// the handler's responsibility to log the message, it will no longer be +/// printed to stderr. If the error handler returns, then exit(1) will be +/// called. +/// +/// It is dangerous to naively use an error handler which throws an exception. +/// Even though some applications desire to gracefully recover from arbitrary +/// faults, blindly throwing exceptions through unfamiliar code isn't a way to +/// achieve this. +/// +/// \param user_data - An argument which will be passed to the install error +/// handler. +void install_fatal_error_handler(fatal_error_handler_t handler, + void *user_data = nullptr); + +/// Restores default error handling behaviour. +void remove_fatal_error_handler(); + +/// ScopedFatalErrorHandler - This is a simple helper class which just +/// calls install_fatal_error_handler in its constructor and +/// remove_fatal_error_handler in its destructor. +struct ScopedFatalErrorHandler { + explicit ScopedFatalErrorHandler(fatal_error_handler_t handler, + void *user_data = nullptr) { + install_fatal_error_handler(handler, user_data); + } + + ~ScopedFatalErrorHandler() { remove_fatal_error_handler(); } +}; /// Reports a serious error, calling any installed error handler. These /// functions are intended to be used for error conditions which are outside @@ -68,14 +68,14 @@ /// standard error, followed by a newline. /// After the error handler is called this function will call abort(), it /// does not return. -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, - bool gen_crash_diag = true); -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const std::string &reason, - bool gen_crash_diag = true); -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(StringRef reason, - bool gen_crash_diag = true); -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const Twine &reason, - bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(const char *reason, + bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(const std::string &reason, + bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(StringRef reason, + bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(const Twine &reason, + bool gen_crash_diag = true); /// Installs a new bad alloc error handler that should be used whenever a /// bad alloc error, e.g. failing malloc/calloc, is encountered by LLVM. @@ -113,16 +113,16 @@ /// If no error handler is installed (default), throws a bad_alloc exception /// if LLVM is compiled with exception support. Otherwise prints the error /// to standard error and calls abort(). -LLVM_ATTRIBUTE_NORETURN void report_bad_alloc_error(const char *Reason, - bool GenCrashDiag = true); +[[noreturn]] void report_bad_alloc_error(const char *Reason, + bool GenCrashDiag = true); /// This function calls abort(), and prints the optional message to stderr. /// Use the llvm_unreachable macro (that adds location info), instead of /// calling this function directly. -LLVM_ATTRIBUTE_NORETURN void -llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr, - unsigned line = 0); -} +[[noreturn]] void llvm_unreachable_internal(const char *msg = nullptr, + const char *file = nullptr, + unsigned line = 0); +} // namespace llvm /// Marks that the current location is not supposed to be reachable. /// In !NDEBUG builds, prints the message and location info to stderr. @@ -133,7 +133,7 @@ /// Use this instead of assert(0). It conveys intent more clearly and /// allows compilers to omit some unnecessary code. #ifndef NDEBUG -#define llvm_unreachable(msg) \ +#define llvm_unreachable(msg) \ ::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__) #elif defined(LLVM_BUILTIN_UNREACHABLE) #define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE Index: llvm/include/llvm/Support/Process.h =================================================================== --- llvm/include/llvm/Support/Process.h +++ llvm/include/llvm/Support/Process.h @@ -214,12 +214,10 @@ /// In that case, the control flow will resume after RunSafely(), like for a /// crash, rather than exiting the current process. /// Use \arg NoCleanup for calling _exit() instead of exit(). - LLVM_ATTRIBUTE_NORETURN - static void Exit(int RetCode, bool NoCleanup = false); + [[noreturn]] static void Exit(int RetCode, bool NoCleanup = false); private: - LLVM_ATTRIBUTE_NORETURN - static void ExitNoCleanup(int RetCode); + [[noreturn]] static void ExitNoCleanup(int RetCode); }; } Index: llvm/include/llvm/Support/Windows/WindowsSupport.h =================================================================== --- llvm/include/llvm/Support/Windows/WindowsSupport.h +++ llvm/include/llvm/Support/Windows/WindowsSupport.h @@ -68,7 +68,7 @@ bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix); // Include GetLastError() in a fatal error message. -LLVM_ATTRIBUTE_NORETURN inline void ReportLastErrorFatal(const char *Msg) { +[[noreturn]] inline void ReportLastErrorFatal(const char *Msg) { std::string ErrMsg; MakeErrMsg(&ErrMsg, Msg); llvm::report_fatal_error(ErrMsg); Index: llvm/include/llvm/TableGen/Error.h =================================================================== --- llvm/include/llvm/TableGen/Error.h +++ llvm/include/llvm/TableGen/Error.h @@ -22,13 +22,10 @@ void PrintNote(const Twine &Msg); void PrintNote(ArrayRef NoteLoc, const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(ArrayRef ErrorLoc, - const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Record *Rec, - const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const RecordVal *RecVal, - const Twine &Msg); +[[noreturn]] void PrintFatalNote(const Twine &Msg); +[[noreturn]] void PrintFatalNote(ArrayRef ErrorLoc, const Twine &Msg); +[[noreturn]] void PrintFatalNote(const Record *Rec, const Twine &Msg); +[[noreturn]] void PrintFatalNote(const RecordVal *RecVal, const Twine &Msg); void PrintWarning(const Twine &Msg); void PrintWarning(ArrayRef WarningLoc, const Twine &Msg); @@ -40,13 +37,10 @@ void PrintError(const Record *Rec, const Twine &Msg); void PrintError(const RecordVal *RecVal, const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalError(ArrayRef ErrorLoc, - const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const Record *Rec, - const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const RecordVal *RecVal, - const Twine &Msg); +[[noreturn]] void PrintFatalError(const Twine &Msg); +[[noreturn]] void PrintFatalError(ArrayRef ErrorLoc, const Twine &Msg); +[[noreturn]] void PrintFatalError(const Record *Rec, const Twine &Msg); +[[noreturn]] void PrintFatalError(const RecordVal *RecVal, const Twine &Msg); void CheckAssert(SMLoc Loc, Init *Condition, Init *Message); Index: llvm/lib/LTO/LTOBackend.cpp =================================================================== --- llvm/lib/LTO/LTOBackend.cpp +++ llvm/lib/LTO/LTOBackend.cpp @@ -74,7 +74,7 @@ cl::desc("Assume the input has already undergone ThinLTO function " "importing and the other pre-optimization pipeline changes.")); -LLVM_ATTRIBUTE_NORETURN static void reportOpenError(StringRef Path, Twine Msg) { +[[noreturn]] static void reportOpenError(StringRef Path, Twine Msg) { errs() << "failed to open " << Path << ": " << Msg << '\n'; errs().flush(); exit(1); Index: llvm/lib/Support/CrashRecoveryContext.cpp =================================================================== --- llvm/lib/Support/CrashRecoveryContext.cpp +++ llvm/lib/Support/CrashRecoveryContext.cpp @@ -428,8 +428,7 @@ #endif // !_MSC_VER -LLVM_ATTRIBUTE_NORETURN -void CrashRecoveryContext::HandleExit(int RetCode) { +[[noreturn]] void CrashRecoveryContext::HandleExit(int RetCode) { #if defined(_WIN32) // SEH and VEH ::RaiseException(0xE0000000 | RetCode, 0, 0, NULL); Index: llvm/lib/Support/Process.cpp =================================================================== --- llvm/lib/Support/Process.cpp +++ llvm/lib/Support/Process.cpp @@ -92,8 +92,7 @@ bool Process::AreCoreFilesPrevented() { return coreFilesPrevented; } -LLVM_ATTRIBUTE_NORETURN -void Process::Exit(int RetCode, bool NoCleanup) { +[[noreturn]] void Process::Exit(int RetCode, bool NoCleanup) { if (CrashRecoveryContext *CRC = CrashRecoveryContext::GetCurrent()) CRC->HandleExit(RetCode); Index: llvm/lib/Support/SmallVector.cpp =================================================================== --- llvm/lib/Support/SmallVector.cpp +++ llvm/lib/Support/SmallVector.cpp @@ -47,8 +47,7 @@ /// Report that MinSize doesn't fit into this vector's size type. Throws /// std::length_error or calls report_fatal_error. -LLVM_ATTRIBUTE_NORETURN -static void report_size_overflow(size_t MinSize, size_t MaxSize); +[[noreturn]] static void report_size_overflow(size_t MinSize, size_t MaxSize); static void report_size_overflow(size_t MinSize, size_t MaxSize) { std::string Reason = "SmallVector unable to grow. Requested capacity (" + std::to_string(MinSize) + @@ -63,7 +62,7 @@ /// Report that this vector is already at maximum capacity. Throws /// std::length_error or calls report_fatal_error. -LLVM_ATTRIBUTE_NORETURN static void report_at_maximum_capacity(size_t MaxSize); +[[noreturn]] static void report_at_maximum_capacity(size_t MaxSize); static void report_at_maximum_capacity(size_t MaxSize) { std::string Reason = "SmallVector capacity unable to grow. Already at maximum size " + Index: llvm/lib/Support/Unix/Process.inc =================================================================== --- llvm/lib/Support/Unix/Process.inc +++ llvm/lib/Support/Unix/Process.inc @@ -461,5 +461,4 @@ #endif } -LLVM_ATTRIBUTE_NORETURN -void Process::ExitNoCleanup(int RetCode) { _Exit(RetCode); } +[[noreturn]] void Process::ExitNoCleanup(int RetCode) { _Exit(RetCode); } Index: llvm/lib/Support/Unix/Unix.h =================================================================== --- llvm/lib/Support/Unix/Unix.h +++ llvm/lib/Support/Unix/Unix.h @@ -67,8 +67,7 @@ } // Include StrError(errnum) in a fatal error message. -LLVM_ATTRIBUTE_NORETURN static inline void ReportErrnumFatal(const char *Msg, - int errnum) { +[[noreturn]] static inline void ReportErrnumFatal(const char *Msg, int errnum) { std::string ErrMsg; MakeErrMsg(&ErrMsg, Msg, errnum); llvm::report_fatal_error(ErrMsg); Index: llvm/lib/Support/Windows/Process.inc =================================================================== --- llvm/lib/Support/Windows/Process.inc +++ llvm/lib/Support/Windows/Process.inc @@ -504,8 +504,7 @@ return GetWindowsOSVersion() >= llvm::VersionTuple(6, 2, 0, 0); } -LLVM_ATTRIBUTE_NORETURN -void Process::ExitNoCleanup(int RetCode) { +[[noreturn]] void Process::ExitNoCleanup(int RetCode) { TerminateProcess(GetCurrentProcess(), RetCode); llvm_unreachable("TerminateProcess doesn't return"); } Index: llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp =================================================================== --- llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp +++ llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp @@ -448,8 +448,7 @@ ++MCNumEmitted; } -LLVM_ATTRIBUTE_NORETURN -static void raise_relocation_error(unsigned Width, unsigned Kind) { +[[noreturn]] static void raise_relocation_error(unsigned Width, unsigned Kind) { std::string Text; raw_string_ostream Stream(Text); Stream << "Unrecognized relocation combination: width=" << Width Index: llvm/lib/Transforms/Coroutines/Coroutines.cpp =================================================================== --- llvm/lib/Transforms/Coroutines/Coroutines.cpp +++ llvm/lib/Transforms/Coroutines/Coroutines.cpp @@ -571,8 +571,8 @@ llvm_unreachable("Unknown coro::ABI enum"); } -LLVM_ATTRIBUTE_NORETURN -static void fail(const Instruction *I, const char *Reason, Value *V) { +[[noreturn]] static void fail(const Instruction *I, const char *Reason, + Value *V) { #ifndef NDEBUG I->dump(); if (V) { Index: llvm/tools/llc/llc.cpp =================================================================== --- llvm/tools/llc/llc.cpp +++ llvm/tools/llc/llc.cpp @@ -201,8 +201,7 @@ static int compileModule(char **, LLVMContext &); -LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg, - StringRef Filename = "") { +[[noreturn]] static void reportError(Twine Msg, StringRef Filename = "") { SmallString<256> Prefix; if (!Filename.empty()) { if (Filename == "-") @@ -213,7 +212,7 @@ exit(1); } -LLVM_ATTRIBUTE_NORETURN static void reportError(Error Err, StringRef Filename) { +[[noreturn]] static void reportError(Error Err, StringRef Filename) { assert(Err); handleAllErrors(createFileError(Filename, std::move(Err)), [&](const ErrorInfoBase &EI) { reportError(EI.message()); }); Index: llvm/tools/lli/lli.cpp =================================================================== --- llvm/tools/lli/lli.cpp +++ llvm/tools/lli/lli.cpp @@ -410,8 +410,7 @@ llvm_unreachable("Unrecognized opt level."); } -LLVM_ATTRIBUTE_NORETURN -static void reportError(SMDiagnostic Err, const char *ProgName) { +[[noreturn]] static void reportError(SMDiagnostic Err, const char *ProgName) { Err.print(ProgName, errs()); exit(1); } Index: llvm/tools/llvm-ar/llvm-ar.cpp =================================================================== --- llvm/tools/llvm-ar/llvm-ar.cpp +++ llvm/tools/llvm-ar/llvm-ar.cpp @@ -136,14 +136,14 @@ static bool ParsingMRIScript; // Show the error plus the usage message, and exit. -LLVM_ATTRIBUTE_NORETURN static void badUsage(Twine Error) { +[[noreturn]] static void badUsage(Twine Error) { WithColor::error(errs(), ToolName) << Error << "\n"; printHelpMessage(); exit(1); } // Show the error message and exit. -LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) { +[[noreturn]] static void fail(Twine Error) { if (ParsingMRIScript) { WithColor::error(errs(), ToolName) << "script line " << MRILineNumber << ": " << Error << "\n"; 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) { +[[noreturn]] static void reportError(Twine Msg) { errs() << Msg; exit(1); } Index: llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp =================================================================== --- llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -49,7 +49,7 @@ exit(1); } -LLVM_ATTRIBUTE_NORETURN static void error(Error Err) { +[[noreturn]] static void error(Error Err) { logAllUnhandledErrors(std::move(Err), WithColor::error(outs()), "reading file: "); outs().flush(); Index: llvm/tools/llvm-ifs/ErrorCollector.h =================================================================== --- llvm/tools/llvm-ifs/ErrorCollector.h +++ llvm/tools/llvm-ifs/ErrorCollector.h @@ -61,7 +61,7 @@ bool allErrorsHandled() const; /// Dump output and crash. - LLVM_ATTRIBUTE_NORETURN void fatalUnhandledError(); + [[noreturn]] void fatalUnhandledError(); bool ErrorsAreFatal; std::vector Errors; Index: llvm/tools/llvm-ifs/ErrorCollector.cpp =================================================================== --- llvm/tools/llvm-ifs/ErrorCollector.cpp +++ llvm/tools/llvm-ifs/ErrorCollector.cpp @@ -57,7 +57,7 @@ } } -LLVM_ATTRIBUTE_NORETURN void ErrorCollector::fatalUnhandledError() { +[[noreturn]] void ErrorCollector::fatalUnhandledError() { errs() << "Program aborted due to unhandled Error(s):\n"; log(errs()); errs() << "\n"; Index: llvm/tools/llvm-lipo/llvm-lipo.cpp =================================================================== --- llvm/tools/llvm-lipo/llvm-lipo.cpp +++ llvm/tools/llvm-lipo/llvm-lipo.cpp @@ -36,13 +36,13 @@ static const StringRef ToolName = "llvm-lipo"; static LLVMContext LLVMCtx; -LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Message) { +[[noreturn]] static void reportError(Twine Message) { WithColor::error(errs(), ToolName) << Message << "\n"; errs().flush(); exit(EXIT_FAILURE); } -LLVM_ATTRIBUTE_NORETURN static void reportError(Error E) { +[[noreturn]] static void reportError(Error E) { assert(E); std::string Buf; raw_string_ostream OS(Buf); @@ -51,7 +51,7 @@ reportError(Buf); } -LLVM_ATTRIBUTE_NORETURN static void reportError(StringRef File, Error E) { +[[noreturn]] static void reportError(StringRef File, Error E) { assert(E); std::string Buf; raw_string_ostream OS(Buf); @@ -328,11 +328,10 @@ !B->isIR()) reportError("File " + IF.FileName + " has unsupported binary format"); if (IF.ArchType && (B->isMachO() || B->isArchive() || B->isIR())) { - const auto S = B->isMachO() - ? Slice(*cast(B)) - : B->isArchive() - ? createSliceFromArchive(*cast(B)) - : createSliceFromIR(*cast(B), 0); + const auto S = B->isMachO() ? Slice(*cast(B)) + : B->isArchive() + ? createSliceFromArchive(*cast(B)) + : createSliceFromIR(*cast(B), 0); const auto SpecifiedCPUType = MachO::getCPUTypeFromArchitecture( MachO::getArchitectureFromName( Triple(*IF.ArchType).getArchName())) @@ -350,9 +349,9 @@ return InputBinaries; } -LLVM_ATTRIBUTE_NORETURN -static void verifyArch(ArrayRef> InputBinaries, - ArrayRef VerifyArchList) { +[[noreturn]] static void +verifyArch(ArrayRef> InputBinaries, + ArrayRef VerifyArchList) { assert(!VerifyArchList.empty() && "The list of architectures should be non-empty"); assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); @@ -429,19 +428,19 @@ Expected SliceOrErr = createSliceFromIR(*IR, 0); if (!SliceOrErr) reportError(IR->getFileName(), SliceOrErr.takeError()); - + OS << SliceOrErr->getArchString() << " \n"; } -LLVM_ATTRIBUTE_NORETURN -static void printArchs(ArrayRef> InputBinaries) { +[[noreturn]] static void +printArchs(ArrayRef> InputBinaries) { assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); printBinaryArchs(InputBinaries.front().getBinary(), outs()); exit(EXIT_SUCCESS); } -LLVM_ATTRIBUTE_NORETURN -static void printInfo(ArrayRef> InputBinaries) { +[[noreturn]] static void +printInfo(ArrayRef> InputBinaries) { // Group universal and thin files together for compatibility with cctools lipo for (auto &IB : InputBinaries) { const Binary *Binary = IB.getBinary(); @@ -463,9 +462,9 @@ exit(EXIT_SUCCESS); } -LLVM_ATTRIBUTE_NORETURN -static void thinSlice(ArrayRef> InputBinaries, - StringRef ArchType, StringRef OutputFileName) { +[[noreturn]] static void thinSlice(ArrayRef> InputBinaries, + StringRef ArchType, + StringRef OutputFileName) { assert(!ArchType.empty() && "The architecture type should be non-empty"); assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); assert(!OutputFileName.empty() && "Thin expects a single output file"); @@ -599,10 +598,10 @@ return Slices; } -LLVM_ATTRIBUTE_NORETURN -static void createUniversalBinary(ArrayRef> InputBinaries, - const StringMap &Alignments, - StringRef OutputFileName) { +[[noreturn]] static void +createUniversalBinary(ArrayRef> InputBinaries, + const StringMap &Alignments, + StringRef OutputFileName) { assert(InputBinaries.size() >= 1 && "Incorrect number of input binaries"); assert(!OutputFileName.empty() && "Create expects a single output file"); @@ -619,12 +618,11 @@ exit(EXIT_SUCCESS); } -LLVM_ATTRIBUTE_NORETURN -static void extractSlice(ArrayRef> InputBinaries, - const StringMap &Alignments, - StringRef ArchType, StringRef OutputFileName) { - assert(!ArchType.empty() && - "The architecture type should be non-empty"); +[[noreturn]] static void +extractSlice(ArrayRef> InputBinaries, + const StringMap &Alignments, StringRef ArchType, + StringRef OutputFileName) { + assert(!ArchType.empty() && "The architecture type should be non-empty"); assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); assert(!OutputFileName.empty() && "Thin expects a single output file"); @@ -642,9 +640,9 @@ }); if (Slices.empty()) - reportError( - "fat input file " + InputBinaries.front().getBinary()->getFileName() + - " does not contain the specified architecture " + ArchType); + reportError("fat input file " + + InputBinaries.front().getBinary()->getFileName() + + " does not contain the specified architecture " + ArchType); llvm::stable_sort(Slices); if (Error E = writeUniversalBinary(Slices, OutputFileName)) @@ -678,11 +676,10 @@ return Slices; } -LLVM_ATTRIBUTE_NORETURN -static void replaceSlices(ArrayRef> InputBinaries, - const StringMap &Alignments, - StringRef OutputFileName, - ArrayRef ReplacementFiles) { +[[noreturn]] static void +replaceSlices(ArrayRef> InputBinaries, + const StringMap &Alignments, + StringRef OutputFileName, ArrayRef ReplacementFiles) { assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); assert(!OutputFileName.empty() && "Replace expects a single output file"); Index: llvm/tools/llvm-mt/llvm-mt.cpp =================================================================== --- llvm/tools/llvm-mt/llvm-mt.cpp +++ llvm/tools/llvm-mt/llvm-mt.cpp @@ -64,7 +64,7 @@ }; } // namespace -LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) { +[[noreturn]] static void reportError(Twine Msg) { WithColor::error(errs(), "llvm-mt") << Msg << '\n'; exit(1); } Index: llvm/tools/llvm-objdump/llvm-objdump.h =================================================================== --- llvm/tools/llvm-objdump/llvm-objdump.h +++ llvm/tools/llvm-objdump/llvm-objdump.h @@ -139,14 +139,14 @@ void printSymbol(const object::ObjectFile *O, const object::SymbolRef &Symbol, StringRef FileName, StringRef ArchiveName, StringRef ArchitectureName, bool DumpDynamic); -LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, const Twine &Message); -LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName, - StringRef ArchiveName = "", - StringRef ArchitectureName = ""); +[[noreturn]] void reportError(StringRef File, const Twine &Message); +[[noreturn]] void reportError(Error E, StringRef FileName, + StringRef ArchiveName = "", + StringRef ArchitectureName = ""); void reportWarning(const Twine &Message, StringRef File); template -T unwrapOrError(Expected EO, Ts &&... Args) { +T unwrapOrError(Expected EO, Ts &&...Args) { if (EO) return std::move(*EO); reportError(EO.takeError(), std::forward(Args)...); Index: llvm/tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- llvm/tools/llvm-objdump/llvm-objdump.cpp +++ llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -297,16 +297,15 @@ << "'" << File << "': " << Message << "\n"; } -LLVM_ATTRIBUTE_NORETURN void objdump::reportError(StringRef File, - const Twine &Message) { +[[noreturn]] void objdump::reportError(StringRef File, const Twine &Message) { outs().flush(); WithColor::error(errs(), ToolName) << "'" << File << "': " << Message << "\n"; exit(1); } -LLVM_ATTRIBUTE_NORETURN void objdump::reportError(Error E, StringRef FileName, - StringRef ArchiveName, - StringRef ArchitectureName) { +[[noreturn]] void objdump::reportError(Error E, StringRef FileName, + StringRef ArchiveName, + StringRef ArchitectureName) { assert(E); outs().flush(); WithColor::error(errs(), ToolName); @@ -325,7 +324,7 @@ WithColor::warning(errs(), ToolName) << Message << "\n"; } -LLVM_ATTRIBUTE_NORETURN static void reportCmdLineError(const Twine &Message) { +[[noreturn]] static void reportCmdLineError(const Twine &Message) { WithColor::error(errs(), ToolName) << Message << "\n"; exit(1); } Index: llvm/tools/llvm-profgen/ErrorHandling.h =================================================================== --- llvm/tools/llvm-profgen/ErrorHandling.h +++ llvm/tools/llvm-profgen/ErrorHandling.h @@ -18,9 +18,9 @@ using namespace llvm; -LLVM_ATTRIBUTE_NORETURN inline void -exitWithError(const Twine &Message, StringRef Whence = StringRef(), - StringRef Hint = StringRef()) { +[[noreturn]] inline void exitWithError(const Twine &Message, + StringRef Whence = StringRef(), + StringRef Hint = StringRef()) { WithColor::error(errs(), "llvm-profgen"); if (!Whence.empty()) errs() << Whence.str() << ": "; @@ -30,17 +30,17 @@ ::exit(EXIT_FAILURE); } -LLVM_ATTRIBUTE_NORETURN inline void -exitWithError(std::error_code EC, StringRef Whence = StringRef()) { +[[noreturn]] inline void exitWithError(std::error_code EC, + StringRef Whence = StringRef()) { exitWithError(EC.message(), Whence); } -LLVM_ATTRIBUTE_NORETURN inline void exitWithError(Error E, StringRef Whence) { +[[noreturn]] inline void exitWithError(Error E, StringRef Whence) { exitWithError(errorToErrorCode(std::move(E)), Whence); } template -T unwrapOrError(Expected EO, Ts &&... Args) { +T unwrapOrError(Expected EO, Ts &&...Args) { if (EO) return std::move(*EO); exitWithError(EO.takeError(), std::forward(Args)...); Index: llvm/tools/llvm-rc/llvm-rc.cpp =================================================================== --- llvm/tools/llvm-rc/llvm-rc.cpp +++ llvm/tools/llvm-rc/llvm-rc.cpp @@ -111,7 +111,7 @@ static FileRemover TempPreprocFile; static FileRemover TempResFile; -LLVM_ATTRIBUTE_NORETURN static void fatalError(const Twine &Message) { +[[noreturn]] static void fatalError(const Twine &Message) { errs() << Message << "\n"; exit(1); } Index: llvm/tools/llvm-readobj/llvm-readobj.h =================================================================== --- llvm/tools/llvm-readobj/llvm-readobj.h +++ llvm/tools/llvm-readobj/llvm-readobj.h @@ -11,24 +11,24 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/ErrorOr.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ErrorOr.h" #include namespace llvm { - namespace object { - class RelocationRef; - } - - // Various helper functions. - LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input); - void reportWarning(Error Err, StringRef Input); - - template T unwrapOrError(StringRef Input, Expected EO) { - if (EO) - return *EO; - reportError(EO.takeError(), Input); - } +namespace object { +class RelocationRef; +} + +// Various helper functions. +[[noreturn]] void reportError(Error Err, StringRef Input); +void reportWarning(Error Err, StringRef Input); + +template T unwrapOrError(StringRef Input, Expected EO) { + if (EO) + return *EO; + reportError(EO.takeError(), Input); +} } // namespace llvm namespace opts { @@ -43,10 +43,10 @@ extern OutputStyleTy Output; } // namespace opts -#define LLVM_READOBJ_ENUM_ENT(ns, enum) \ +#define LLVM_READOBJ_ENUM_ENT(ns, enum) \ { #enum, ns::enum } -#define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \ - { #enum, std::underlying_type::type(enum_class::enum) } +#define LLVM_READOBJ_ENUM_CLASS_ENT(enum_class, enum) \ + { #enum, std::underlying_type < enum_class> ::type(enum_class::enum) } #endif Index: llvm/tools/llvm-readobj/llvm-readobj.cpp =================================================================== --- llvm/tools/llvm-readobj/llvm-readobj.cpp +++ llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -157,7 +157,7 @@ namespace llvm { -LLVM_ATTRIBUTE_NORETURN static void error(Twine Msg) { +[[noreturn]] static void error(Twine Msg) { // Flush the standard output to print the error at a // proper place. fouts().flush(); @@ -165,7 +165,7 @@ exit(1); } -LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input) { +[[noreturn]] void reportError(Error Err, StringRef Input) { assert(Err); if (Input == "-") Input = ""; @@ -499,7 +499,6 @@ reportError(std::move(Err), WinRes->getFileName()); } - /// Opens \a File and dumps it. static void dumpInput(StringRef File, ScopedPrinter &Writer) { ErrorOr> FileOrErr = Index: llvm/tools/llvm-strings/llvm-strings.cpp =================================================================== --- llvm/tools/llvm-strings/llvm-strings.cpp +++ llvm/tools/llvm-strings/llvm-strings.cpp @@ -73,7 +73,7 @@ enum radix { none, octal, hexadecimal, decimal }; static radix Radix; -LLVM_ATTRIBUTE_NORETURN static void reportCmdLineError(const Twine &Message) { +[[noreturn]] static void reportCmdLineError(const Twine &Message) { WithColor::error(errs(), ToolName) << Message << "\n"; exit(1); } Index: llvm/tools/split-file/split-file.cpp =================================================================== --- llvm/tools/split-file/split-file.cpp +++ llvm/tools/split-file/split-file.cpp @@ -42,8 +42,7 @@ static StringRef toolName; static int errorCount; -LLVM_ATTRIBUTE_NORETURN static void fatal(StringRef filename, - const Twine &message) { +[[noreturn]] static void fatal(StringRef filename, const Twine &message) { if (filename.empty()) WithColor::error(errs(), toolName) << message << '\n'; else