diff options
author | Fangrui Song <i@maskray.me> | 2021-07-28 09:31:14 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-07-28 09:31:14 -0700 |
commit | 6da3d8b19c32c76bb503b1a71fc167a0487ef200 (patch) | |
tree | bb382aee391f9bd0977e607f5e3db2d77c912cd0 /llvm | |
parent | 49f745f59cbe1eda4653d917cc7d8d0b586fc6a4 (diff) | |
download | llvm-6da3d8b19c32c76bb503b1a71fc167a0487ef200.zip llvm-6da3d8b19c32c76bb503b1a71fc167a0487ef200.tar.gz llvm-6da3d8b19c32c76bb503b1a71fc167a0487ef200.tar.bz2 |
[llvm] Replace LLVM_ATTRIBUTE_NORETURN with C++11 [[noreturn]]
[[noreturn]] can be used since Oct 2016 when the minimum compiler requirement was bumped to GCC 4.8/MSVC 2015.
Note: the definition of LLVM_ATTRIBUTE_NORETURN is kept for now.
Diffstat (limited to 'llvm')
33 files changed, 94 insertions, 119 deletions
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h index 877b2dc..bde7507 100644 --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -817,7 +817,7 @@ namespace llvm { // 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<MCAsmMacro>::iterator I = MacroMap.find(Name); diff --git a/llvm/include/llvm/Support/CrashRecoveryContext.h b/llvm/include/llvm/Support/CrashRecoveryContext.h index 4986906..2604ccb 100644 --- a/llvm/include/llvm/Support/CrashRecoveryContext.h +++ b/llvm/include/llvm/Support/CrashRecoveryContext.h @@ -99,8 +99,7 @@ public: /// 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. diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h index e8f340e..4708d5b 100644 --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -257,8 +257,7 @@ private: // 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 @@ private: } #if LLVM_ENABLE_ABI_BREAKING_CHECKS - LLVM_ATTRIBUTE_NORETURN - LLVM_ATTRIBUTE_NOINLINE - void fatalUncheckedExpected() const { + [[noreturn]] LLVM_ATTRIBUTE_NOINLINE void fatalUncheckedExpected() const { dbgs() << "Expected<T> must be checked before access or destruction.\n"; if (HasError) { dbgs() << "Unchecked Expected<T> contained error:\n"; @@ -722,8 +719,7 @@ private: /// 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. /// diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h index 0ec0242..81cac47 100644 --- a/llvm/include/llvm/Support/ErrorHandling.h +++ b/llvm/include/llvm/Support/ErrorHandling.h @@ -68,14 +68,14 @@ class StringRef; /// 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,13 +113,13 @@ void install_out_of_memory_new_handler(); /// 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 +[[noreturn]] void llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr, unsigned line = 0); } diff --git a/llvm/include/llvm/Support/Process.h b/llvm/include/llvm/Support/Process.h index 6687e5e..ee03efe 100644 --- a/llvm/include/llvm/Support/Process.h +++ b/llvm/include/llvm/Support/Process.h @@ -214,12 +214,10 @@ public: /// 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); }; } diff --git a/llvm/include/llvm/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h index a45eeab..e03d0da 100644 --- a/llvm/include/llvm/Support/Windows/WindowsSupport.h +++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h @@ -68,7 +68,7 @@ llvm::VersionTuple GetWindowsOSVersion(); 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); diff --git a/llvm/include/llvm/TableGen/Error.h b/llvm/include/llvm/TableGen/Error.h index a0e23ac..da0132b 100644 --- a/llvm/include/llvm/TableGen/Error.h +++ b/llvm/include/llvm/TableGen/Error.h @@ -22,13 +22,10 @@ namespace llvm { void PrintNote(const Twine &Msg); void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(const Twine &Msg); -LLVM_ATTRIBUTE_NORETURN void PrintFatalNote(ArrayRef<SMLoc> 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<SMLoc> 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<SMLoc> WarningLoc, const Twine &Msg); @@ -40,13 +37,10 @@ void PrintError(const char *Loc, const Twine &Msg); 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<SMLoc> 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<SMLoc> 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); diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 4e4ba4f..2840940 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -74,7 +74,7 @@ static cl::opt<bool> ThinLTOAssumeMerged( 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); diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp index 433d99d..b6aaf37 100644 --- a/llvm/lib/Support/CrashRecoveryContext.cpp +++ b/llvm/lib/Support/CrashRecoveryContext.cpp @@ -428,8 +428,7 @@ bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) { #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); diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index e7e9a8b..547b3b7 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -92,8 +92,7 @@ static bool coreFilesPrevented = !LLVM_ENABLE_CRASH_DUMPS; 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); diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp index 0005f78..0e2378b 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp @@ -47,8 +47,7 @@ static_assert(sizeof(SmallVector<char, 0>) == /// 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 @@ static void report_size_overflow(size_t MinSize, size_t MaxSize) { /// 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 " + diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc index 30b957e..d3d9fb7 100644 --- a/llvm/lib/Support/Unix/Process.inc +++ b/llvm/lib/Support/Unix/Process.inc @@ -461,5 +461,4 @@ unsigned llvm::sys::Process::GetRandomNumber() { #endif } -LLVM_ATTRIBUTE_NORETURN -void Process::ExitNoCleanup(int RetCode) { _Exit(RetCode); } +[[noreturn]] void Process::ExitNoCleanup(int RetCode) { _Exit(RetCode); } diff --git a/llvm/lib/Support/Unix/Unix.h b/llvm/lib/Support/Unix/Unix.h index 6092913..e392434 100644 --- a/llvm/lib/Support/Unix/Unix.h +++ b/llvm/lib/Support/Unix/Unix.h @@ -67,8 +67,7 @@ static inline bool MakeErrMsg( } // 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); diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc index 6f58c52..a0d94e6 100644 --- a/llvm/lib/Support/Windows/Process.inc +++ b/llvm/lib/Support/Windows/Process.inc @@ -504,8 +504,7 @@ bool llvm::RunningWindows8OrGreater() { 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"); } diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp index 24169c8..4779fa4 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp @@ -448,8 +448,7 @@ void HexagonMCCodeEmitter::EncodeSingleInstruction(const MCInst &MI, ++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 diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp index ae2d9e1..c131e29 100644 --- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp +++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp @@ -571,8 +571,8 @@ void coro::Shape::emitDealloc(IRBuilder<> &Builder, Value *Ptr, 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) { diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 6a1e2ba..58f19b2 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -201,8 +201,7 @@ static cl::opt<RunPassOption, true, cl::parser<std::string>> RunPass( 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 @@ LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg, 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()); }); diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index af614c0..170cc3b 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -410,8 +410,7 @@ CodeGenOpt::Level getOptLevel() { 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); } diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 0e1dce6..68084ba 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -136,14 +136,14 @@ static unsigned MRILineNumber; 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"; diff --git a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp index 24b3c65..0907c0a 100644 --- a/llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ b/llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -67,7 +67,7 @@ public: }; } -static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) { +[[noreturn]] static void reportError(Twine Msg) { errs() << Msg; exit(1); } diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp index f214288..4e1cca7 100644 --- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -49,7 +49,7 @@ static void error(std::error_code EC) { 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(); diff --git a/llvm/tools/llvm-ifs/ErrorCollector.cpp b/llvm/tools/llvm-ifs/ErrorCollector.cpp index 087a30c..04daa84 100644 --- a/llvm/tools/llvm-ifs/ErrorCollector.cpp +++ b/llvm/tools/llvm-ifs/ErrorCollector.cpp @@ -57,7 +57,7 @@ ErrorCollector::~ErrorCollector() { } } -LLVM_ATTRIBUTE_NORETURN void ErrorCollector::fatalUnhandledError() { +[[noreturn]] void ErrorCollector::fatalUnhandledError() { errs() << "Program aborted due to unhandled Error(s):\n"; log(errs()); errs() << "\n"; diff --git a/llvm/tools/llvm-ifs/ErrorCollector.h b/llvm/tools/llvm-ifs/ErrorCollector.h index 67996f4..7217ca3 100644 --- a/llvm/tools/llvm-ifs/ErrorCollector.h +++ b/llvm/tools/llvm-ifs/ErrorCollector.h @@ -61,7 +61,7 @@ private: bool allErrorsHandled() const; /// Dump output and crash. - LLVM_ATTRIBUTE_NORETURN void fatalUnhandledError(); + [[noreturn]] void fatalUnhandledError(); bool ErrorsAreFatal; std::vector<Error> Errors; diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp index d099ea1..738f16a 100644 --- a/llvm/tools/llvm-lipo/llvm-lipo.cpp +++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp @@ -36,13 +36,13 @@ using namespace llvm::object; 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 @@ LLVM_ATTRIBUTE_NORETURN static void reportError(Error E) { 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); @@ -350,9 +350,9 @@ readInputBinaries(ArrayRef<InputFile> InputFiles) { return InputBinaries; } -LLVM_ATTRIBUTE_NORETURN -static void verifyArch(ArrayRef<OwningBinary<Binary>> InputBinaries, - ArrayRef<std::string> VerifyArchList) { +[[noreturn]] static void +verifyArch(ArrayRef<OwningBinary<Binary>> InputBinaries, + ArrayRef<std::string> VerifyArchList) { assert(!VerifyArchList.empty() && "The list of architectures should be non-empty"); assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); @@ -433,15 +433,15 @@ static void printBinaryArchs(const Binary *Binary, raw_ostream &OS) { OS << SliceOrErr->getArchString() << " \n"; } -LLVM_ATTRIBUTE_NORETURN -static void printArchs(ArrayRef<OwningBinary<Binary>> InputBinaries) { +[[noreturn]] static void +printArchs(ArrayRef<OwningBinary<Binary>> 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<OwningBinary<Binary>> InputBinaries) { +[[noreturn]] static void +printInfo(ArrayRef<OwningBinary<Binary>> InputBinaries) { // Group universal and thin files together for compatibility with cctools lipo for (auto &IB : InputBinaries) { const Binary *Binary = IB.getBinary(); @@ -463,9 +463,9 @@ static void printInfo(ArrayRef<OwningBinary<Binary>> InputBinaries) { exit(EXIT_SUCCESS); } -LLVM_ATTRIBUTE_NORETURN -static void thinSlice(ArrayRef<OwningBinary<Binary>> InputBinaries, - StringRef ArchType, StringRef OutputFileName) { +[[noreturn]] static void thinSlice(ArrayRef<OwningBinary<Binary>> 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 +599,10 @@ buildSlices(ArrayRef<OwningBinary<Binary>> InputBinaries, return Slices; } -LLVM_ATTRIBUTE_NORETURN -static void createUniversalBinary(ArrayRef<OwningBinary<Binary>> InputBinaries, - const StringMap<const uint32_t> &Alignments, - StringRef OutputFileName) { +[[noreturn]] static void +createUniversalBinary(ArrayRef<OwningBinary<Binary>> InputBinaries, + const StringMap<const uint32_t> &Alignments, + StringRef OutputFileName) { assert(InputBinaries.size() >= 1 && "Incorrect number of input binaries"); assert(!OutputFileName.empty() && "Create expects a single output file"); @@ -619,10 +619,10 @@ static void createUniversalBinary(ArrayRef<OwningBinary<Binary>> InputBinaries, exit(EXIT_SUCCESS); } -LLVM_ATTRIBUTE_NORETURN -static void extractSlice(ArrayRef<OwningBinary<Binary>> InputBinaries, - const StringMap<const uint32_t> &Alignments, - StringRef ArchType, StringRef OutputFileName) { +[[noreturn]] static void +extractSlice(ArrayRef<OwningBinary<Binary>> InputBinaries, + const StringMap<const uint32_t> &Alignments, StringRef ArchType, + StringRef OutputFileName) { assert(!ArchType.empty() && "The architecture type should be non-empty"); assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); @@ -678,11 +678,10 @@ buildReplacementSlices(ArrayRef<OwningBinary<Binary>> ReplacementBinaries, return Slices; } -LLVM_ATTRIBUTE_NORETURN -static void replaceSlices(ArrayRef<OwningBinary<Binary>> InputBinaries, - const StringMap<const uint32_t> &Alignments, - StringRef OutputFileName, - ArrayRef<InputFile> ReplacementFiles) { +[[noreturn]] static void +replaceSlices(ArrayRef<OwningBinary<Binary>> InputBinaries, + const StringMap<const uint32_t> &Alignments, + StringRef OutputFileName, ArrayRef<InputFile> ReplacementFiles) { assert(InputBinaries.size() == 1 && "Incorrect number of input binaries"); assert(!OutputFileName.empty() && "Replace expects a single output file"); diff --git a/llvm/tools/llvm-mt/llvm-mt.cpp b/llvm/tools/llvm-mt/llvm-mt.cpp index 6f26765..1ff66ee 100644 --- a/llvm/tools/llvm-mt/llvm-mt.cpp +++ b/llvm/tools/llvm-mt/llvm-mt.cpp @@ -64,7 +64,7 @@ public: }; } // namespace -LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) { +[[noreturn]] static void reportError(Twine Msg) { WithColor::error(errs(), "llvm-mt") << Msg << '\n'; exit(1); } diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 48ae92f..0e4f402 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -297,16 +297,15 @@ void objdump::reportWarning(const Twine &Message, StringRef File) { << "'" << 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 @@ static void reportCmdLineWarning(const Twine &Message) { 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); } diff --git a/llvm/tools/llvm-objdump/llvm-objdump.h b/llvm/tools/llvm-objdump/llvm-objdump.h index 33fb3f2..3796878 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.h +++ b/llvm/tools/llvm-objdump/llvm-objdump.h @@ -139,10 +139,10 @@ void printSymbolTable(const object::ObjectFile *O, StringRef ArchiveName, 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 <typename T, typename... Ts> diff --git a/llvm/tools/llvm-profgen/ErrorHandling.h b/llvm/tools/llvm-profgen/ErrorHandling.h index 1d118c5..5d08c01 100644 --- a/llvm/tools/llvm-profgen/ErrorHandling.h +++ b/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,12 +30,12 @@ exitWithError(const Twine &Message, StringRef Whence = StringRef(), ::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); } diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp index 0f70e30..c7c93ae 100644 --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -111,7 +111,7 @@ static ExitOnError ExitOnErr; 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); } diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp index 0b49f03..76ac5be 100644 --- a/llvm/tools/llvm-readobj/llvm-readobj.cpp +++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -157,7 +157,7 @@ static StringRef ToolName; 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 @@ LLVM_ATTRIBUTE_NORETURN static void error(Twine Msg) { exit(1); } -LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input) { +[[noreturn]] void reportError(Error Err, StringRef Input) { assert(Err); if (Input == "-") Input = "<stdin>"; diff --git a/llvm/tools/llvm-readobj/llvm-readobj.h b/llvm/tools/llvm-readobj/llvm-readobj.h index 43d19b4..7672da5 100644 --- a/llvm/tools/llvm-readobj/llvm-readobj.h +++ b/llvm/tools/llvm-readobj/llvm-readobj.h @@ -21,7 +21,7 @@ namespace llvm { } // Various helper functions. - LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input); + [[noreturn]] void reportError(Error Err, StringRef Input); void reportWarning(Error Err, StringRef Input); template <class T> T unwrapOrError(StringRef Input, Expected<T> EO) { diff --git a/llvm/tools/llvm-strings/llvm-strings.cpp b/llvm/tools/llvm-strings/llvm-strings.cpp index 0b068749..e7c50f8 100644 --- a/llvm/tools/llvm-strings/llvm-strings.cpp +++ b/llvm/tools/llvm-strings/llvm-strings.cpp @@ -73,7 +73,7 @@ static bool PrintFileName; 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); } diff --git a/llvm/tools/split-file/split-file.cpp b/llvm/tools/split-file/split-file.cpp index 3ebbda4..3556784 100644 --- a/llvm/tools/split-file/split-file.cpp +++ b/llvm/tools/split-file/split-file.cpp @@ -42,8 +42,7 @@ static cl::opt<bool> noLeadingLines("no-leading-lines", 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 |