diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -47,7 +47,7 @@ DL(std::move(DL)), Mangle(ES, this->DL), Ctx(std::make_unique()) { ES.getMainJITDylib().addGenerator( - cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( + llvm_cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( DL.getGlobalPrefix()))); } diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -54,7 +54,7 @@ DL(std::move(DL)), Mangle(ES, this->DL), Ctx(std::make_unique()) { ES.getMainJITDylib().addGenerator( - cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( + llvm_cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess( DL.getGlobalPrefix()))); } diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -76,7 +76,7 @@ [this](std::unique_ptr M) { return optimizeModule(std::move(M)); }), - CompileCallbackManager(cantFail(orc::createLocalCompileCallbackManager( + CompileCallbackManager(llvm_cantFail(orc::createLocalCompileCallbackManager( TM->getTargetTriple(), ES, 0))), CODLayer( AcknowledgeORCv1Deprecation, ES, OptimizeLayer, @@ -110,10 +110,10 @@ return JITSymbol(SymAddr, JITSymbolFlags::Exported); return nullptr; }, - [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); }); + [](Error Err) { llvm_cantFail(std::move(Err), "lookupFlags failed"); }); // Add the module to the JIT with the new key. - cantFail(CODLayer.addModule(K, std::move(M))); + llvm_cantFail(CODLayer.addModule(K, std::move(M))); return K; } @@ -125,7 +125,7 @@ } void removeModule(VModuleKey K) { - cantFail(CODLayer.removeModule(K)); + llvm_cantFail(CODLayer.removeModule(K)); } private: diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp @@ -1150,7 +1150,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -103,7 +103,7 @@ return JITSymbol(SymAddr, JITSymbolFlags::Exported); return nullptr; }, - [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })), + [](Error Err) { llvm_cantFail(std::move(Err), "lookupFlags failed"); })), TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), ObjectLayer(AcknowledgeORCv1Deprecation, ES, [this](VModuleKey K) { @@ -116,7 +116,7 @@ [this](std::unique_ptr M) { return optimizeModule(std::move(M)); }), - CompileCallbackMgr(cantFail(orc::createLocalCompileCallbackManager( + CompileCallbackMgr(llvm_cantFail(orc::createLocalCompileCallbackManager( TM->getTargetTriple(), ES, 0))) { auto IndirectStubsMgrBuilder = orc::createLocalIndirectStubsManagerBuilder(TM->getTargetTriple()); @@ -129,7 +129,7 @@ VModuleKey addModule(std::unique_ptr M) { // Add the module to the JIT with a new VModuleKey. auto K = ES.allocateVModule(); - cantFail(OptimizeLayer.addModule(K, std::move(M))); + llvm_cantFail(OptimizeLayer.addModule(K, std::move(M))); return K; } @@ -159,7 +159,7 @@ addModule(std::move(M)); auto Sym = findSymbol(SharedFnAST->getName() + "$impl"); assert(Sym && "Couldn't find compiled function?"); - JITTargetAddress SymAddr = cantFail(Sym.getAddress()); + JITTargetAddress SymAddr = llvm_cantFail(Sym.getAddress()); if (auto Err = IndirectStubsMgr->updatePointer( mangle(SharedFnAST->getName()), SymAddr)) { logAllUnhandledErrors(std::move(Err), errs(), @@ -172,7 +172,7 @@ // Create a CompileCallback using the CompileAction - this is the re-entry // point into the compiler for functions that haven't been compiled yet. - auto CCAddr = cantFail( + auto CCAddr = llvm_cantFail( CompileCallbackMgr->getCompileCallback(std::move(CompileAction))); // Create an indirect stub. This serves as the functions "canonical @@ -194,7 +194,7 @@ } void removeModule(VModuleKey K) { - cantFail(OptimizeLayer.removeModule(K)); + llvm_cantFail(OptimizeLayer.removeModule(K)); } private: diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp @@ -1153,7 +1153,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h @@ -105,18 +105,18 @@ return Sym; else if (auto Err = Sym.takeError()) return std::move(Err); - if (auto Addr = cantFail(this->Remote.getSymbolAddress(Name))) + if (auto Addr = llvm_cantFail(this->Remote.getSymbolAddress(Name))) return JITSymbol(Addr, JITSymbolFlags::Exported); return nullptr; }, - [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })), + [](Error Err) { llvm_cantFail(std::move(Err), "lookupFlags failed"); })), TM(EngineBuilder().selectTarget(Triple(Remote.getTargetTriple()), "", "", SmallVector())), DL(TM->createDataLayout()), ObjectLayer(AcknowledgeORCv1Deprecation, ES, [this](VModuleKey K) { return LegacyRTDyldObjectLinkingLayer::Resources{ - cantFail(this->Remote.createRemoteMemoryManager()), + llvm_cantFail(this->Remote.createRemoteMemoryManager()), Resolver}; }), CompileLayer(AcknowledgeORCv1Deprecation, ObjectLayer, @@ -133,7 +133,7 @@ exit(1); } CompileCallbackMgr = &*CCMgrOrErr; - IndirectStubsMgr = cantFail(Remote.createIndirectStubsManager()); + IndirectStubsMgr = llvm_cantFail(Remote.createIndirectStubsManager()); llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr); } @@ -142,7 +142,7 @@ VModuleKey addModule(std::unique_ptr M) { // Add the module with a new VModuleKey. auto K = ES.allocateVModule(); - cantFail(OptimizeLayer.addModule(K, std::move(M))); + llvm_cantFail(OptimizeLayer.addModule(K, std::move(M))); return K; } @@ -172,7 +172,7 @@ addModule(std::move(M)); auto Sym = findSymbol(SharedFnAST->getName() + "$impl"); assert(Sym && "Couldn't find compiled function?"); - JITTargetAddress SymAddr = cantFail(Sym.getAddress()); + JITTargetAddress SymAddr = llvm_cantFail(Sym.getAddress()); if (auto Err = IndirectStubsMgr->updatePointer( mangle(SharedFnAST->getName()), SymAddr)) { logAllUnhandledErrors(std::move(Err), errs(), @@ -185,7 +185,7 @@ // Create a CompileCallback suing the CompileAction - this is the re-entry // point into the compiler for functions that haven't been compiled yet. - auto CCAddr = cantFail( + auto CCAddr = llvm_cantFail( CompileCallbackMgr->getCompileCallback(std::move(CompileAction))); // Create an indirect stub. This serves as the functions "canonical @@ -211,7 +211,7 @@ } void removeModule(VModuleKey K) { - cantFail(OptimizeLayer.removeModule(K)); + llvm_cantFail(OptimizeLayer.removeModule(K)); } private: diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp @@ -1177,7 +1177,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - ExitOnErr(TheJIT->executeRemoteExpr(cantFail(ExprSymbol.getAddress()))); + ExitOnErr(TheJIT->executeRemoteExpr(llvm_cantFail(ExprSymbol.getAddress()))); // Delete the anonymous expression module from the JIT. TheJIT->removeModule(H); diff --git a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp --- a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter4/toy.cpp @@ -612,7 +612,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. diff --git a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp --- a/llvm/examples/Kaleidoscope/Chapter5/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter5/toy.cpp @@ -886,7 +886,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. diff --git a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp --- a/llvm/examples/Kaleidoscope/Chapter6/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter6/toy.cpp @@ -1005,7 +1005,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp --- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp @@ -1175,7 +1175,7 @@ // Get the symbol's address and cast it to the right type (takes no // arguments, returns a double) so we can call it as a native function. - double (*FP)() = (double (*)())(intptr_t)cantFail(ExprSymbol.getAddress()); + double (*FP)() = (double (*)())(intptr_t)llvm_cantFail(ExprSymbol.getAddress()); fprintf(stderr, "Evaluated to %f\n", FP()); // Delete the anonymous expression module from the JIT. diff --git a/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h --- a/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h @@ -46,7 +46,7 @@ : Resolver(createLegacyLookupResolver( ES, [this](const std::string &Name) { return findMangledSymbol(Name); }, - [](Error Err) { cantFail(std::move(Err), "lookupFlags failed"); })), + [](Error Err) { llvm_cantFail(std::move(Err), "lookupFlags failed"); })), TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()), ObjectLayer(AcknowledgeORCv1Deprecation, ES, [this](VModuleKey) { @@ -62,14 +62,14 @@ VModuleKey addModule(std::unique_ptr M) { auto K = ES.allocateVModule(); - cantFail(CompileLayer.addModule(K, std::move(M))); + llvm_cantFail(CompileLayer.addModule(K, std::move(M))); ModuleKeys.push_back(K); return K; } void removeModule(VModuleKey K) { ModuleKeys.erase(find(ModuleKeys, K)); - cantFail(CompileLayer.removeModule(K)); + llvm_cantFail(CompileLayer.removeModule(K)); } JITSymbol findSymbol(const std::string Name) { diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -211,7 +211,7 @@ /// method returns an error then clients should log it and call /// failMaterialize. If no dependencies have been registered for the /// symbols covered by this MaterializationResponsibiility then this method - /// is guaranteed to return Error::success() and can be wrapped with cantFail. + /// is guaranteed to return Error::success() and can be wrapped with llvm_cantFail. Error notifyResolved(const SymbolMap &Symbols); /// Notifies the target JITDylib (and any pending queries on that JITDylib) @@ -223,7 +223,7 @@ /// method returns an error then clients should log it and call /// failMaterialize. If no dependencies have been registered for the /// symbols covered by this MaterializationResponsibiility then this method - /// is guaranteed to return Error::success() and can be wrapped with cantFail. + /// is guaranteed to return Error::success() and can be wrapped with llvm_cantFail. Error notifyEmitted(); /// Adds new symbols to the JITDylib and this responsibility instance. diff --git a/llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h b/llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h --- a/llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/RPC/RPCUtils.h @@ -1023,7 +1023,7 @@ else { // Negotiation failed. Notify the handler then return the negotiate-failed // error. - cantFail(Handler(make_error())); + llvm_cantFail(Handler(make_error())); return FnIdOrErr.takeError(); } diff --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h --- a/llvm/include/llvm/MC/MCDwarf.h +++ b/llvm/include/llvm/MC/MCDwarf.h @@ -291,7 +291,7 @@ Optional Checksum, uint16_t DwarfVersion, Optional Source) { HasSplitLineTable = true; - return cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source, + return llvm_cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion)); } @@ -319,7 +319,7 @@ unsigned getFile(StringRef &Directory, StringRef &FileName, Optional Checksum, Optional Source, uint16_t DwarfVersion, unsigned FileNumber = 0) { - return cantFail(tryGetFile(Directory, FileName, Checksum, Source, + return llvm_cantFail(tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion, FileNumber)); } diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -808,7 +808,7 @@ Optional Checksum = None, Optional Source = None, unsigned CUID = 0) { - return cantFail( + return llvm_cantFail( tryEmitDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source, CUID)); } diff --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h --- a/llvm/include/llvm/Support/Error.h +++ b/llvm/include/llvm/Support/Error.h @@ -687,6 +687,48 @@ LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag = true); +namespace detail { + +inline LLVM_ATTRIBUTE_NORETURN void handleError(Error Err, const char *Msg, + const char *file = nullptr, + unsigned line = 0) { + if (!Msg) + Msg = "Failure value returned from cantFail wrapped call"; +#ifndef NDEBUG + std::string Str; + raw_string_ostream OS(Str); + OS << Err << "\n" << Msg; + if (file) + OS << " at " << file << ":" << line; + Msg = OS.str().c_str(); +#endif + llvm_unreachable(Msg); +} + +inline void cantFail_annotated(const char *file, unsigned line, Error Err, + const char *Msg = nullptr) { + if (Err) + handleError(std::move(Err), Msg, file, line); +} + +template +T cantFail_annotated(const char *file, unsigned line, Expected ValOrErr, + const char *Msg = nullptr) { + if (ValOrErr) + return std::move(*ValOrErr); + handleError(std::move(ValOrErr.takeError()), Msg, file, line); +} + +template +T &cantFail_annotated(const char *file, unsigned line, Expected ValOrErr, + const char *Msg = nullptr) { + if (ValOrErr) + return *ValOrErr; + handleError(std::move(ValOrErr.takeError()), Msg, file, line); +} + +} // namespace detail + /// Report a fatal error if Err is a failure value. /// /// This function can be used to wrap calls to fallible functions ONLY when it @@ -701,17 +743,8 @@ /// cantFail(foo(false)); /// @endcode inline void cantFail(Error Err, const char *Msg = nullptr) { - if (Err) { - if (!Msg) - Msg = "Failure value returned from cantFail wrapped call"; -#ifndef NDEBUG - std::string Str; - raw_string_ostream OS(Str); - OS << Msg << "\n" << Err; - Msg = OS.str().c_str(); -#endif - llvm_unreachable(Msg); - } + if (Err) + detail::handleError(std::move(Err), Msg); } /// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and @@ -731,18 +764,7 @@ T cantFail(Expected ValOrErr, const char *Msg = nullptr) { if (ValOrErr) return std::move(*ValOrErr); - else { - if (!Msg) - Msg = "Failure value returned from cantFail wrapped call"; -#ifndef NDEBUG - std::string Str; - raw_string_ostream OS(Str); - auto E = ValOrErr.takeError(); - OS << Msg << "\n" << E; - Msg = OS.str().c_str(); -#endif - llvm_unreachable(Msg); - } + detail::handleError(std::move(ValOrErr.takeError()), Msg); } /// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and @@ -759,22 +781,19 @@ /// Bar &X = cantFail(foo(false)); /// @endcode template -T& cantFail(Expected ValOrErr, const char *Msg = nullptr) { +T &cantFail(Expected ValOrErr, const char *Msg = nullptr) { if (ValOrErr) return *ValOrErr; - else { - if (!Msg) - Msg = "Failure value returned from cantFail wrapped call"; + detail::handleError(std::move(ValOrErr.takeError()), Msg); +} + #ifndef NDEBUG - std::string Str; - raw_string_ostream OS(Str); - auto E = ValOrErr.takeError(); - OS << Msg << "\n" << E; - Msg = OS.str().c_str(); +#define llvm_cantFail(...) \ + ::llvm::detail::cantFail_annotated(__FILE__, __LINE__, __VA_ARGS__) +#else +#define llvm_cantFail(...) \ + ::llvm::detail::cantFail_annotated(nullptr, 0, __VA_ARGS__) #endif - llvm_unreachable(Msg); - } -} /// Helper for testing applicability of, and applying, handlers for /// ErrorInfo types. @@ -922,13 +941,13 @@ /// errors after running the handlers, or llvm_unreachable is called). template void handleAllErrors(Error E, HandlerTs &&... Handlers) { - cantFail(handleErrors(std::move(E), std::forward(Handlers)...)); + llvm_cantFail(handleErrors(std::move(E), std::forward(Handlers)...)); } /// Check that E is a non-error, then drop it. /// If E is an error, llvm_unreachable will be called. inline void handleAllErrors(Error E) { - cantFail(std::move(E)); + llvm_cantFail(std::move(E)); } /// Handle any errors (if present) in an Expected, then try a recovery path. diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -3113,7 +3113,7 @@ uint8_t data[10]; BinaryStreamWriter Writer(data, llvm::support::endianness::little); CodeViewRecordIO IO(Writer); - cantFail(IO.mapEncodedInteger(Val)); + llvm_cantFail(IO.mapEncodedInteger(Val)); StringRef SRef((char *)data, Writer.getOffset()); OS.EmitBinaryData(SRef); diff --git a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp --- a/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp +++ b/llvm/lib/DebugInfo/CodeView/ContinuationRecordBuilder.cpp @@ -26,7 +26,7 @@ int PaddingBytes = 4 - Align; while (PaddingBytes > 0) { uint8_t Pad = static_cast(LF_PAD0 + PaddingBytes); - cantFail(Writer.writeInteger(Pad)); + llvm_cantFail(Writer.writeInteger(Pad)); --PaddingBytes; } } @@ -69,9 +69,9 @@ // Seed the first record with an appropriate record prefix. RecordPrefix Prefix(getTypeLeafKind(RecordKind)); CVType Type(&Prefix, sizeof(Prefix)); - cantFail(Mapping.visitTypeBegin(Type)); + llvm_cantFail(Mapping.visitTypeBegin(Type)); - cantFail(SegmentWriter.writeObject(Prefix)); + llvm_cantFail(SegmentWriter.writeObject(Prefix)); } template @@ -84,12 +84,12 @@ // Member Records aren't length-prefixed, they only have a 2-byte TypeLeafKind // at the beginning. - cantFail(SegmentWriter.writeEnum(CVMR.Kind)); + llvm_cantFail(SegmentWriter.writeEnum(CVMR.Kind)); // Let the Mapping handle the rest. - cantFail(Mapping.visitMemberBegin(CVMR)); - cantFail(Mapping.visitKnownMember(CVMR, Record)); - cantFail(Mapping.visitMemberEnd(CVMR)); + llvm_cantFail(Mapping.visitMemberBegin(CVMR)); + llvm_cantFail(Mapping.visitKnownMember(CVMR, Record)); + llvm_cantFail(Mapping.visitMemberEnd(CVMR)); // Make sure it's padded to 4 bytes. addPadding(SegmentWriter); @@ -173,7 +173,7 @@ std::vector ContinuationRecordBuilder::end(TypeIndex Index) { RecordPrefix Prefix(getTypeLeafKind(*Kind)); CVType Type(&Prefix, sizeof(Prefix)); - cantFail(Mapping.visitTypeEnd(Type)); + llvm_cantFail(Mapping.visitTypeEnd(Type)); // We're now done, and we have a series of segments each beginning at an // offset specified in the SegmentOffsets array. We now need to iterate diff --git a/llvm/lib/DebugInfo/CodeView/RecordName.cpp b/llvm/lib/DebugInfo/CodeView/RecordName.cpp --- a/llvm/lib/DebugInfo/CodeView/RecordName.cpp +++ b/llvm/lib/DebugInfo/CodeView/RecordName.cpp @@ -322,9 +322,9 @@ // The container doesn't matter for single records. SymbolRecordMapping Mapping(Reader, CodeViewContainer::ObjectFile); ConstantSym Const(SymbolKind::S_CONSTANT); - cantFail(Mapping.visitSymbolBegin(Sym)); - cantFail(Mapping.visitKnownRecord(Sym, Const)); - cantFail(Mapping.visitSymbolEnd(Sym)); + llvm_cantFail(Mapping.visitSymbolBegin(Sym)); + llvm_cantFail(Mapping.visitKnownRecord(Sym, Const)); + llvm_cantFail(Mapping.visitSymbolEnd(Sym)); return Const.Name; } diff --git a/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp b/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp --- a/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp +++ b/llvm/lib/DebugInfo/CodeView/SimpleTypeSerializer.cpp @@ -11,7 +11,7 @@ int PaddingBytes = 4 - Align; while (PaddingBytes > 0) { uint8_t Pad = static_cast(LF_PAD0 + PaddingBytes); - cantFail(Writer.writeInteger(Pad)); + llvm_cantFail(Writer.writeInteger(Pad)); --PaddingBytes; } } @@ -27,14 +27,14 @@ // Write the record prefix first with a dummy length but real kind. RecordPrefix DummyPrefix(uint16_t(Record.getKind())); - cantFail(Writer.writeObject(DummyPrefix)); + llvm_cantFail(Writer.writeObject(DummyPrefix)); RecordPrefix *Prefix = reinterpret_cast(ScratchBuffer.data()); CVType CVT(Prefix, sizeof(RecordPrefix)); - cantFail(Mapping.visitTypeBegin(CVT)); - cantFail(Mapping.visitKnownRecord(CVT, Record)); - cantFail(Mapping.visitTypeEnd(CVT)); + llvm_cantFail(Mapping.visitTypeBegin(CVT)); + llvm_cantFail(Mapping.visitKnownRecord(CVT, Record)); + llvm_cantFail(Mapping.visitTypeEnd(CVT)); addPadding(Writer); diff --git a/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp b/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp --- a/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp +++ b/llvm/lib/DebugInfo/CodeView/SymbolRecordHelpers.cpp @@ -16,7 +16,7 @@ template static RecordT createRecord(const CVSymbol &sym) { RecordT record(static_cast(sym.kind())); - cantFail(SymbolDeserializer::deserializeAs(sym, record)); + llvm_cantFail(SymbolDeserializer::deserializeAs(sym, record)); return record; } diff --git a/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp b/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp --- a/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -472,7 +472,7 @@ for (const auto &Ref : Refs) { Reader.setOffset(Ref.Offset); FixedStreamArray Run; - cantFail(Reader.readArray(Run, Ref.Count)); + llvm_cantFail(Reader.readArray(Run, Ref.Count)); Indices.append(Run.begin(), Run.end()); } } diff --git a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp --- a/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp +++ b/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp @@ -357,7 +357,7 @@ Error TypeStreamMerger::remapAllTypes(const CVTypeArray &Types) { BinaryStreamRef Stream = Types.getUnderlyingStream(); ArrayRef Buffer; - cantFail(Stream.readBytes(0, Stream.getLength(), Buffer)); + llvm_cantFail(Stream.readBytes(0, Stream.getLength(), Buffer)); return forEachCodeViewRecord( Buffer, [this](const CVType &T) { return remapType(T); }); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -302,7 +302,7 @@ case dwarf::DW_LLE_default_location: case dwarf::DW_LLE_start_end: default: - cantFail(C.takeError()); + llvm_cantFail(C.takeError()); return createStringError(errc::illegal_byte_sequence, "LLE of kind %x not supported", (int)E.Kind); } diff --git a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp --- a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp +++ b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -330,7 +330,7 @@ ThisByte |= Mask; ++BI; } - cantFail(FpmWriter.writeObject(ThisByte)); + llvm_cantFail(FpmWriter.writeObject(ThisByte)); } assert(FpmWriter.bytesRemaining() == 0); } diff --git a/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp b/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp --- a/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp +++ b/llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp @@ -366,7 +366,7 @@ std::vector InitData(Layout.SB->BlockSize, 0xFF); BinaryStreamWriter Initializer(*Result); while (Initializer.bytesRemaining() > 0) - cantFail(Initializer.writeBytes(InitData)); + llvm_cantFail(Initializer.writeBytes(InitData)); return createStream(Layout.SB->BlockSize, MinLayout, MsfData, Allocator); } diff --git a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp --- a/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/GSIStreamBuilder.cpp @@ -257,7 +257,7 @@ for (const CVSymbol &Sym : Records) { assert(Sym.kind() == SymbolKind::S_PUB32); DeserializedPublics.push_back( - cantFail(SymbolDeserializer::deserializeAs(Sym))); + llvm_cantFail(SymbolDeserializer::deserializeAs(Sym))); PublicsByAddr.emplace_back(&Sym, &DeserializedPublics.back()); SymOffsets.push_back(SymOffset); SymOffset += Sym.length(); diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeEnumGlobals.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeEnumGlobals.cpp --- a/llvm/lib/DebugInfo/PDB/Native/NativeEnumGlobals.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeEnumGlobals.cpp @@ -23,8 +23,8 @@ NativeEnumGlobals::NativeEnumGlobals(NativeSession &PDBSession, std::vector Kinds) : Index(0), Session(PDBSession) { - GlobalsStream &GS = cantFail(Session.getPDBFile().getPDBGlobalsStream()); - SymbolStream &SS = cantFail(Session.getPDBFile().getPDBSymbolStream()); + GlobalsStream &GS = llvm_cantFail(Session.getPDBFile().getPDBGlobalsStream()); + SymbolStream &SS = llvm_cantFail(Session.getPDBFile().getPDBSymbolStream()); for (uint32_t Off : GS.getGlobalsTable()) { CVSymbol S = SS.readRecord(Off); if (!llvm::is_contained(Kinds, S.kind())) diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp --- a/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp @@ -46,19 +46,19 @@ uint64_t getCodeByteSize() const override { return Entry.FileSize; } std::string getFileName() const override { - StringRef Ret = cantFail(Strings.getStringForID(Entry.FileNI), + StringRef Ret = llvm_cantFail(Strings.getStringForID(Entry.FileNI), "InjectedSourceStream should have rejected this"); return Ret; } std::string getObjectFileName() const override { - StringRef Ret = cantFail(Strings.getStringForID(Entry.ObjNI), + StringRef Ret = llvm_cantFail(Strings.getStringForID(Entry.ObjNI), "InjectedSourceStream should have rejected this"); return Ret; } std::string getVirtualFileName() const override { - StringRef Ret = cantFail(Strings.getStringForID(Entry.VFileNI), + StringRef Ret = llvm_cantFail(Strings.getStringForID(Entry.VFileNI), "InjectedSourceStream should have rejected this"); return Ret; } @@ -68,7 +68,7 @@ std::string getCode() const override { // Get name of stream storing the data. StringRef VName = - cantFail(Strings.getStringForID(Entry.VFileNI), + llvm_cantFail(Strings.getStringForID(Entry.VFileNI), "InjectedSourceStream should have rejected this"); std::string StreamName = ("/src/files/" + VName).str(); diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp --- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeEnum.cpp @@ -63,7 +63,7 @@ NativeEnumEnumEnumerators::NativeEnumEnumEnumerators( NativeSession &Session, const NativeTypeEnum &ClassParent) : Session(Session), ClassParent(ClassParent) { - TpiStream &Tpi = cantFail(Session.getPDBFile().getPDBTpiStream()); + TpiStream &Tpi = llvm_cantFail(Session.getPDBFile().getPDBTpiStream()); LazyRandomTypeCollection &Types = Tpi.typeCollection(); ContinuationIndex = ClassParent.getEnumRecord().FieldList; @@ -71,7 +71,7 @@ CVType FieldList = Types.getType(*ContinuationIndex); assert(FieldList.kind() == LF_FIELDLIST); ContinuationIndex.reset(); - cantFail(visitMemberRecordStream(FieldList.data(), *this)); + llvm_cantFail(visitMemberRecordStream(FieldList.data(), *this)); } } diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp --- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp @@ -99,10 +99,10 @@ NativeTypeFunctionSig::~NativeTypeFunctionSig() {} void NativeTypeFunctionSig::initializeArgList(codeview::TypeIndex ArgListTI) { - TpiStream &Tpi = cantFail(Session.getPDBFile().getPDBTpiStream()); + TpiStream &Tpi = llvm_cantFail(Session.getPDBFile().getPDBTpiStream()); CVType CVT = Tpi.typeCollection().getType(ArgListTI); - cantFail(TypeDeserializer::deserializeAs(CVT, ArgList)); + llvm_cantFail(TypeDeserializer::deserializeAs(CVT, ArgList)); } void NativeTypeFunctionSig::dump(raw_ostream &OS, int Indent, diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp --- a/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -432,7 +432,7 @@ if (StreamIPI >= getNumStreams()) return false; - auto &InfoStream = cantFail(const_cast(this)->getPDBInfoStream()); + auto &InfoStream = llvm_cantFail(const_cast(this)->getPDBInfoStream()); return InfoStream.containsIdStream(); } diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp --- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp @@ -226,7 +226,7 @@ const msf::MSFLayout &Layout) { assert(!InjectedSourceTable.empty()); - uint32_t SN = cantFail(getNamedStreamIndex("/src/headerblock")); + uint32_t SN = llvm_cantFail(getNamedStreamIndex("/src/headerblock")); auto Stream = WritableMappedBlockStream::createIndexedStream( Layout, MsfBuffer, SN, Allocator); BinaryStreamWriter Writer(*Stream); @@ -236,8 +236,8 @@ Header.Version = static_cast(PdbRaw_SrcHeaderBlockVer::SrcVerOne); Header.Size = Writer.bytesRemaining(); - cantFail(Writer.writeObject(Header)); - cantFail(InjectedSourceTable.commit(Writer)); + llvm_cantFail(Writer.writeObject(Header)); + llvm_cantFail(InjectedSourceTable.commit(Writer)); assert(Writer.bytesRemaining() == 0); } @@ -250,13 +250,13 @@ commitSrcHeaderBlock(MsfBuffer, Layout); for (const auto &IS : InjectedSources) { - uint32_t SN = cantFail(getNamedStreamIndex(IS.StreamName)); + uint32_t SN = llvm_cantFail(getNamedStreamIndex(IS.StreamName)); auto SourceStream = WritableMappedBlockStream::createIndexedStream( Layout, MsfBuffer, SN, Allocator); BinaryStreamWriter SourceWriter(*SourceStream); assert(SourceWriter.bytesRemaining() == IS.Content->getBufferSize()); - cantFail(SourceWriter.writeBytes( + llvm_cantFail(SourceWriter.writeBytes( arrayRefFromStringRef(IS.Content->getBuffer()))); } } diff --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp --- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp @@ -260,12 +260,12 @@ if (Iter != GlobalOffsetToSymbolId.end()) return Iter->second; - SymbolStream &SS = cantFail(Session.getPDBFile().getPDBSymbolStream()); + SymbolStream &SS = llvm_cantFail(Session.getPDBFile().getPDBSymbolStream()); CVSymbol CVS = SS.readRecord(Offset); SymIndexId Id = 0; switch (CVS.kind()) { case SymbolKind::S_UDT: { - UDTSym US = cantFail(SymbolDeserializer::deserializeAs(CVS)); + UDTSym US = llvm_cantFail(SymbolDeserializer::deserializeAs(CVS)); Id = createSymbol(std::move(US)); break; } diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp --- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -147,7 +147,7 @@ // Materialize all globals in the module if they have not been // materialized already. - cantFail(M->materializeAll()); + llvm_cantFail(M->materializeAll()); // This must be a module which has already been added but not loaded to this // MCJIT instance, since these conditions are tested by our caller, diff --git a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp --- a/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp @@ -76,7 +76,7 @@ : JTMB(std::move(JTMB)), ObjCache(ObjCache) {} std::unique_ptr ConcurrentIRCompiler::operator()(Module &M) { - auto TM = cantFail(JTMB.createTargetMachine()); + auto TM = llvm_cantFail(JTMB.createTargetMachine()); SimpleCompiler C(*TM, ObjCache); return C(M); } diff --git a/llvm/lib/ExecutionEngine/Orc/Core.cpp b/llvm/lib/ExecutionEngine/Orc/Core.cpp --- a/llvm/lib/ExecutionEngine/Orc/Core.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Core.cpp @@ -492,8 +492,8 @@ void AbsoluteSymbolsMaterializationUnit::materialize( MaterializationResponsibility R) { // No dependencies, so these calls can't fail. - cantFail(R.notifyResolved(Symbols)); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(Symbols)); + llvm_cantFail(R.notifyEmitted()); } void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD, @@ -726,7 +726,7 @@ } if (!Added.empty()) - cantFail(JD.define(reexports(SourceJD, AliasMap, MatchNonExported))); + llvm_cantFail(JD.define(reexports(SourceJD, AliasMap, MatchNonExported))); return Added; } @@ -1431,7 +1431,7 @@ // Lodge query. This can not fail as any new definitions were added // by the generator under the session locked. Since they can't have // started materializing yet the can not have failed. - cantFail(lodgeQueryImpl(Q, *NewDefs, MatchNonExported, MUs)); + llvm_cantFail(lodgeQueryImpl(Q, *NewDefs, MatchNonExported, MUs)); assert(NewDefs->empty() && "All fallback defs should have been found by lookupImpl"); diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp --- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp @@ -220,9 +220,9 @@ // Add any new symbols to JD. Since the generator is only called for symbols // that are not already defined, this will never trigger a duplicate - // definition error, so we can wrap this call in a 'cantFail'. + // definition error, so we can wrap this call in a 'llvm_cantFail'. if (!NewSymbols.empty()) - cantFail(JD.define(absoluteSymbols(std::move(NewSymbols)))); + llvm_cantFail(JD.define(absoluteSymbols(std::move(NewSymbols)))); return Added; } diff --git a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp --- a/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp +++ b/llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp @@ -38,8 +38,8 @@ SymbolMap Result; Result[Name] = JITEvaluatedSymbol(Compile(), JITSymbolFlags::Exported); // No dependencies, so these calls cannot fail. - cantFail(R.notifyResolved(Result)); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(Result)); + llvm_cantFail(R.notifyEmitted()); } void discard(const JITDylib &JD, const SymbolStringPtr &Name) override { @@ -66,7 +66,7 @@ std::lock_guard Lock(CCMgrMutex); AddrToSymbol[*TrampolineAddr] = CallbackName; - cantFail(CallbacksJD.define( + llvm_cantFail(CallbacksJD.define( std::make_unique( std::move(CallbackName), std::move(Compile), ES.allocateVModule()))); diff --git a/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp b/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp --- a/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp @@ -184,8 +184,8 @@ Stubs[Alias.first] = ISManager.findStub(*Alias.first, false); // No registered dependencies, so these calls cannot fail. - cantFail(R.notifyResolved(Stubs)); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(Stubs)); + llvm_cantFail(R.notifyEmitted()); } void LazyReexportsMaterializationUnit::discard(const JITDylib &JD, diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h --- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h +++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h @@ -292,11 +292,11 @@ UnexecutedConstructors[K] = std::move(CtorNames); UnexecutedDestructors[K] = std::move(DtorNames); - cantFail(LazyEmitLayer.addModule(K, std::move(M))); + llvm_cantFail(LazyEmitLayer.addModule(K, std::move(M))); } void addObjectFile(std::unique_ptr O) override { - cantFail(ObjectLayer.addObject( + llvm_cantFail(ObjectLayer.addObject( ES.allocateVModule(), MemoryBuffer::getMemBufferCopy(O->getData()))); } @@ -304,7 +304,7 @@ std::unique_ptr Obj; std::unique_ptr ObjBuffer; std::tie(Obj, ObjBuffer) = O.takeBinary(); - cantFail(ObjectLayer.addObject(ES.allocateVModule(), std::move(ObjBuffer))); + llvm_cantFail(ObjectLayer.addObject(ES.allocateVModule(), std::move(ObjBuffer))); } void addArchive(object::OwningBinary A) override { @@ -323,7 +323,7 @@ } uint64_t getSymbolAddress(StringRef Name) { - return cantFail(findSymbol(Name).getAddress()); + return llvm_cantFail(findSymbol(Name).getAddress()); } JITSymbol findSymbol(StringRef Name) { @@ -407,7 +407,7 @@ } std::unique_ptr &ChildBin = ChildBinOrErr.get(); if (ChildBin->isObject()) { - cantFail(ObjectLayer.addObject( + llvm_cantFail(ObjectLayer.addObject( ES.allocateVModule(), MemoryBuffer::getMemBufferCopy(ChildBin->getData()))); if (auto Sym = ObjectLayer.findSymbol(Name, true)) diff --git a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.cpp b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.cpp --- a/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.cpp +++ b/llvm/lib/ExecutionEngine/Orc/OrcMCJITReplacement.cpp @@ -127,7 +127,7 @@ auto &CtorDtorsMap = isDtors ? UnexecutedDestructors : UnexecutedConstructors; for (auto &KV : CtorDtorsMap) - cantFail(LegacyCtorDtorRunner( + llvm_cantFail(LegacyCtorDtorRunner( AcknowledgeORCv1Deprecation, std::move(KV.second), KV.first) .runViaLayer(LazyEmitLayer)); diff --git a/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp b/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp --- a/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ThreadSafeModule.cpp @@ -53,7 +53,7 @@ "cloned module buffer"); ThreadSafeContext NewTSCtx(std::make_unique()); - auto ClonedModule = cantFail( + auto ClonedModule = llvm_cantFail( parseBitcodeFile(ClonedModuleBufferRef, *NewTSCtx.getContext())); ClonedModule->setModuleIdentifier(M.getName()); return ThreadSafeModule(std::move(ClonedModule), std::move(NewTSCtx)); diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp --- a/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp +++ b/llvm/lib/ObjectYAML/CodeViewYAMLTypeHashing.cpp @@ -51,13 +51,13 @@ BinaryStreamReader Reader(DebugH, llvm::support::little); DebugHSection DHS; - cantFail(Reader.readInteger(DHS.Magic)); - cantFail(Reader.readInteger(DHS.Version)); - cantFail(Reader.readInteger(DHS.HashAlgorithm)); + llvm_cantFail(Reader.readInteger(DHS.Magic)); + llvm_cantFail(Reader.readInteger(DHS.Version)); + llvm_cantFail(Reader.readInteger(DHS.HashAlgorithm)); while (Reader.bytesRemaining() != 0) { ArrayRef S; - cantFail(Reader.readBytes(S, 8)); + llvm_cantFail(Reader.readBytes(S, 8)); DHS.Hashes.emplace_back(S); } assert(Reader.bytesRemaining() == 0); @@ -71,16 +71,16 @@ MutableArrayRef Buffer(Data, Size); BinaryStreamWriter Writer(Buffer, llvm::support::little); - cantFail(Writer.writeInteger(DebugH.Magic)); - cantFail(Writer.writeInteger(DebugH.Version)); - cantFail(Writer.writeInteger(DebugH.HashAlgorithm)); + llvm_cantFail(Writer.writeInteger(DebugH.Magic)); + llvm_cantFail(Writer.writeInteger(DebugH.Version)); + llvm_cantFail(Writer.writeInteger(DebugH.HashAlgorithm)); SmallString<8> Hash; for (const auto &H : DebugH.Hashes) { Hash.clear(); raw_svector_ostream OS(Hash); H.Hash.writeAsBinary(OS); assert((Hash.size() == 8) && "Invalid hash size!"); - cantFail(Writer.writeFixedString(Hash)); + llvm_cantFail(Writer.writeFixedString(Hash)); } assert(Writer.bytesRemaining() == 0); return Buffer; diff --git a/llvm/lib/Remarks/RemarkParser.cpp b/llvm/lib/Remarks/RemarkParser.cpp --- a/llvm/lib/Remarks/RemarkParser.cpp +++ b/llvm/lib/Remarks/RemarkParser.cpp @@ -114,7 +114,7 @@ CParser(Format ParserFormat, StringRef Buf, Optional StrTab = None) - : TheParser(cantFail( + : TheParser(llvm_cantFail( StrTab ? createRemarkParser(ParserFormat, Buf, std::move(*StrTab)) : createRemarkParser(ParserFormat, Buf))) {} diff --git a/llvm/lib/XRay/Profile.cpp b/llvm/lib/XRay/Profile.cpp --- a/llvm/lib/XRay/Profile.cpp +++ b/llvm/lib/XRay/Profile.cpp @@ -29,7 +29,7 @@ Blocks.push_back({Block.Thread, {}}); auto &B = Blocks.back(); for (const auto &PathData : Block.PathData) - B.PathData.push_back({internPath(cantFail(O.expandPath(PathData.first))), + B.PathData.push_back({internPath(llvm_cantFail(O.expandPath(PathData.first))), PathData.second}); } } @@ -207,7 +207,7 @@ auto &PathID = PathAndData.first; auto &Data = PathAndData.second; auto NewPathID = - Merged.internPath(cantFail(P.get().expandPath(PathID))); + Merged.internPath(llvm_cantFail(P.get().expandPath(PathID))); PathDataMap::iterator PathDataIt; bool Inserted; std::tie(PathDataIt, Inserted) = It->second->insert({NewPathID, Data}); @@ -223,7 +223,7 @@ PathDataVector PathAndData; PathAndData.reserve(IndexedThreadBlock.second->size()); copy(*IndexedThreadBlock.second, std::back_inserter(PathAndData)); - cantFail( + llvm_cantFail( Merged.addBlock({IndexedThreadBlock.first, std::move(PathAndData)})); } return Merged; @@ -240,7 +240,7 @@ auto &PathId = PathAndData.first; auto &Data = PathAndData.second; auto NewPathID = - Merged.internPath(cantFail(P.get().expandPath(PathId))); + Merged.internPath(llvm_cantFail(P.get().expandPath(PathId))); PathDataMap::iterator PathDataIt; bool Inserted; std::tie(PathDataIt, Inserted) = PathData.insert({NewPathID, Data}); @@ -255,7 +255,7 @@ PathDataVector Block; Block.reserve(PathData.size()); copy(PathData, std::back_inserter(Block)); - cantFail(Merged.addBlock({0, std::move(Block)})); + llvm_cantFail(Merged.addBlock({0, std::move(Block)})); return Merged; } diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp --- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp +++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp @@ -252,14 +252,14 @@ MemoryBuffer::getMemBufferCopy(InputData); // Create the ObjectFile from the MemoryBuffer. std::unique_ptr Obj = - cantFail(object::ObjectFile::createObjectFile(Buffer->getMemBufferRef())); + llvm_cantFail(object::ObjectFile::createObjectFile(Buffer->getMemBufferRef())); // Returning both the MemoryBuffer and the ObjectFile. return object::OwningBinary(std::move(Obj), std::move(Buffer)); } object::OwningBinary getObjectFromFile(StringRef Filename) { - return cantFail(object::ObjectFile::createObjectFile(Filename)); + return llvm_cantFail(object::ObjectFile::createObjectFile(Filename)); } namespace { diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp --- a/llvm/tools/llvm-objdump/COFFDump.cpp +++ b/llvm/tools/llvm-objdump/COFFDump.cpp @@ -641,7 +641,7 @@ std::string Name; raw_string_ostream NS(Name); - cantFail(Sym.printName(NS)); + llvm_cantFail(Sym.printName(NS)); NS.flush(); outs() << "[" << format("%2d", Index) << "]" diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -288,7 +288,7 @@ continue; DebugSymbolsSubsectionRef Symbols; BinaryStreamReader Reader(SS.getRecordData()); - cantFail(Symbols.initialize(Reader)); + llvm_cantFail(Symbols.initialize(Reader)); for (const auto &S : Symbols) { Stats.update(S.kind(), S.length()); CumulativeStats.update(S.kind(), S.length()); @@ -504,7 +504,7 @@ "Section headers require a DBI Stream, which could not be loaded", inconvertibleErrorCode()); - auto &Dbi = cantFail(File.getPDBDbiStream()); + auto &Dbi = llvm_cantFail(File.getPDBDbiStream()); uint32_t SI = Dbi.getDebugStreamIndex(Type); if (SI == kInvalidStreamIndex) @@ -525,7 +525,7 @@ uint32_t NumHeaders = Stream->getLength() / sizeof(object::coff_section); BinaryStreamReader Reader(*Stream); - cantFail(Reader.readArray(Headers, NumHeaders)); + llvm_cantFail(Reader.readArray(Headers, NumHeaders)); return std::make_pair(std::move(Stream), Headers); } @@ -667,7 +667,7 @@ if (SG.getFile().isPdb()) { AutoIndent Indent(P); - auto Modules = cantFail(File.pdb().getPDBDbiStream()).modules(); + auto Modules = llvm_cantFail(File.pdb().getPDBDbiStream()).modules(); uint32_t ModCount = Modules.getModuleCount(); DbiModuleDescriptor Desc = Modules.getModuleDescriptor(Modi); uint32_t StreamIdx = Desc.getModuleStreamIndex(); @@ -789,7 +789,7 @@ return; UdtStats.update(SymbolKind::S_UDT, Sym.length()); - UDTSym UDT = cantFail(SymbolDeserializer::deserializeAs(Sym)); + UDTSym UDT = llvm_cantFail(SymbolDeserializer::deserializeAs(Sym)); uint32_t Kind = 0; uint32_t RecordSize = 0; @@ -821,7 +821,7 @@ P.NewLine(); if (File.isPdb()) { - auto &SymbolRecords = cantFail(getPdb().getPDBSymbolStream()); + auto &SymbolRecords = llvm_cantFail(getPdb().getPDBSymbolStream()); auto ExpGlobals = getPdb().getPDBGlobalsStream(); if (!ExpGlobals) return ExpGlobals.takeError(); @@ -838,7 +838,7 @@ DebugSymbolsSubsectionRef Symbols; BinaryStreamReader Reader(SS.getRecordData()); - cantFail(Symbols.initialize(Reader)); + llvm_cantFail(Symbols.initialize(Reader)); for (const auto &S : Symbols) HandleOneSymbol(S); } @@ -1220,7 +1220,7 @@ BinaryStreamRef NameBuffer = IS->getStringTable().getBuffer(); ArrayRef Contents; - cantFail(NameBuffer.readBytes(0, NameBuffer.getLength(), Contents)); + llvm_cantFail(NameBuffer.readBytes(0, NameBuffer.getLength(), Contents)); P.formatBinary("Name Buffer", Contents, 0); P.NewLine(); { @@ -1246,7 +1246,7 @@ while (Reader.bytesRemaining() > 0) { StringRef Str; uint32_t Offset = Reader.getOffset(); - cantFail(Reader.readCString(Str)); + llvm_cantFail(Reader.readCString(Str)); if (Str.empty()) continue; @@ -1651,7 +1651,7 @@ AutoIndent Indent(P); - auto &Records = cantFail(getPdb().getPDBSymbolStream()); + auto &Records = llvm_cantFail(getPdb().getPDBSymbolStream()); auto &Types = File.types(); auto &Ids = File.ids(); @@ -1691,7 +1691,7 @@ const GSIHashTable &Table = Globals.getGlobalsTable(); Err(dumpSymbolsFromGSI(Table, opts::dump::DumpGlobalExtras)); } else { - SymbolStream &SymRecords = cantFail(getPdb().getPDBSymbolStream()); + SymbolStream &SymRecords = llvm_cantFail(getPdb().getPDBSymbolStream()); auto &Types = File.types(); auto &Ids = File.ids(); diff --git a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp --- a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp @@ -216,7 +216,7 @@ P.formatLine("Address describes the allocation status of blocks [{0},{1})", DescribedBlockStart, DescribedBlockStart + 8); ArrayRef Bytes; - cantFail(File.pdb().getMsfBuffer().readBytes(FileOffset, 1, Bytes)); + llvm_cantFail(File.pdb().getMsfBuffer().readBytes(FileOffset, 1, Bytes)); P.formatLine("Status = {0} (Note: 0 = allocated, 1 = free)", toBinaryString(Bytes[0])); } @@ -253,12 +253,12 @@ (StreamOff > Layout.Length) ? " in unused space" : ""); switch (S.getPurpose()) { case StreamPurpose::DBI: { - DbiStream &Dbi = cantFail(File.pdb().getPDBDbiStream()); + DbiStream &Dbi = llvm_cantFail(File.pdb().getPDBDbiStream()); explainStreamOffset(Dbi, StreamOff); break; } case StreamPurpose::PDB: { - InfoStream &Info = cantFail(File.pdb().getPDBInfoStream()); + InfoStream &Info = llvm_cantFail(File.pdb().getPDBInfoStream()); explainStreamOffset(Info, StreamOff); break; } @@ -360,7 +360,7 @@ BinaryStreamRef ModiSubstreamData = Dbi.getModiSubstreamData().StreamData; BinaryStreamReader Reader(ModiSubstreamData); - cantFail(Reader.readArray(ModuleDescriptors, ModiSubstreamData.getLength())); + llvm_cantFail(Reader.readArray(ModuleDescriptors, ModiSubstreamData.getLength())); auto Prev = ModuleDescriptors.begin(); assert(Prev.offset() == 0); auto Current = Prev; diff --git a/llvm/tools/llvm-pdbutil/InputFile.cpp b/llvm/tools/llvm-pdbutil/InputFile.cpp --- a/llvm/tools/llvm-pdbutil/InputFile.cpp +++ b/llvm/tools/llvm-pdbutil/InputFile.cpp @@ -84,7 +84,7 @@ uint32_t Magic; if (Reader.bytesRemaining() < sizeof(uint32_t)) return false; - cantFail(Reader.readInteger(Magic)); + llvm_cantFail(Reader.readInteger(Magic)); if (Magic != COFF::DEBUG_SECTION_MAGIC) return false; return true; @@ -96,7 +96,7 @@ if (!isCodeViewDebugSubsection(Section, ".debug$S", Reader)) return false; - cantFail(Reader.readArray(Subsections, Reader.bytesRemaining())); + llvm_cantFail(Reader.readArray(Subsections, Reader.bytesRemaining())); return true; } @@ -105,7 +105,7 @@ if (!isCodeViewDebugSubsection(Section, ".debug$T", Reader) && !isCodeViewDebugSubsection(Section, ".debug$P", Reader)) return false; - cantFail(Reader.readArray(Types, Reader.bytesRemaining())); + llvm_cantFail(Reader.readArray(Types, Reader.bytesRemaining())); return true; } @@ -378,7 +378,7 @@ // in step 1. if (isPdb()) { TypeCollectionPtr &Collection = (Kind == kIds) ? Ids : Types; - auto &Stream = cantFail((Kind == kIds) ? pdb().getPDBIpiStream() + auto &Stream = llvm_cantFail((Kind == kIds) ? pdb().getPDBIpiStream() : pdb().getPDBTpiStream()); auto &Array = Stream.typeArray(); @@ -498,7 +498,7 @@ if (!Value.File) return true; if (Value.File->isPdb()) { - auto &Dbi = cantFail(Value.File->pdb().getPDBDbiStream()); + auto &Dbi = llvm_cantFail(Value.File->pdb().getPDBDbiStream()); uint32_t Count = Dbi.modules().getModuleCount(); assert(Index <= Count); return Index == Count; diff --git a/llvm/tools/llvm-pdbutil/LinePrinter.cpp b/llvm/tools/llvm-pdbutil/LinePrinter.cpp --- a/llvm/tools/llvm-pdbutil/LinePrinter.cpp +++ b/llvm/tools/llvm-pdbutil/LinePrinter.cpp @@ -254,7 +254,7 @@ OS << formatv("Block {0} (\n", uint32_t(Blocks.front())); uint32_t UsedBytes = std::min(L, File.getBlockSize()); ArrayRef BlockData = - cantFail(File.getBlockData(Blocks.front(), File.getBlockSize())); + llvm_cantFail(File.getBlockData(Blocks.front(), File.getBlockSize())); uint64_t BaseOffset = Blocks.front(); BaseOffset *= File.getBlockSize(); OS << format_bytes_with_ascii(BlockData, BaseOffset, 32, 4, diff --git a/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp b/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp --- a/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp +++ b/llvm/tools/llvm-pdbutil/TypeReferenceTracker.cpp @@ -42,7 +42,7 @@ // Get the TpiStream pointer for forward decl resolution if this is a pdb. // Build the hash map to enable resolving forward decls. if (File.isPdb()) { - Tpi = &cantFail(File.pdb().getPDBTpiStream()); + Tpi = &llvm_cantFail(File.pdb().getPDBTpiStream()); Tpi->buildHashMap(); } } @@ -62,7 +62,7 @@ CVSymbolArray Symbols; BinaryStreamReader Reader(SS.getRecordData()); - cantFail(Reader.readArray(Symbols, Reader.getLength())); + llvm_cantFail(Reader.readArray(Symbols, Reader.getLength())); for (const CVSymbol &S : Symbols) addTypeRefsFromSymbol(S); } @@ -74,8 +74,8 @@ // Walk globals and mark types referenced from globals. if (File.isPdb() && File.pdb().hasPDBGlobalsStream()) { - SymbolStream &SymStream = cantFail(File.pdb().getPDBSymbolStream()); - GlobalsStream &GS = cantFail(File.pdb().getPDBGlobalsStream()); + SymbolStream &SymStream = llvm_cantFail(File.pdb().getPDBSymbolStream()); + GlobalsStream &GS = llvm_cantFail(File.pdb().getPDBGlobalsStream()); for (uint32_t PubSymOff : GS.getGlobalsTable()) { CVSymbol Sym = SymStream.readRecord(PubSymOff); addTypeRefsFromSymbol(Sym); @@ -152,7 +152,7 @@ case LF_UNION: case LF_ENUM: addOneTypeRef(TiRefKind::TypeRef, - cantFail(Tpi->findFullDeclForForwardRef(RefTI))); + llvm_cantFail(Tpi->findFullDeclForForwardRef(RefTI))); break; } } diff --git a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp --- a/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -1377,7 +1377,7 @@ } if (!Success) { - InfoStream &IS = cantFail(File.getPDBInfoStream()); + InfoStream &IS = llvm_cantFail(File.getPDBInfoStream()); Index = ExitOnErr(IS.getNamedStreamIndex(opts::exportstream::Stream)); outs() << "Dumping contents of stream '" << opts::exportstream::Stream << "' (index " << Index << ") to file " << OutFileName << ".\n"; diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp --- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp +++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp @@ -1461,7 +1461,7 @@ auto LengthLoc = writeInt(0); writeInt(sizeof(FixedInfo)); writeInt(0); - cantFail(writeCString("VS_VERSION_INFO")); + llvm_cantFail(writeCString("VS_VERSION_INFO")); padStream(sizeof(uint32_t)); using VersionInfoFixed = VersionInfoResource::VersionInfoFixed; diff --git a/llvm/tools/llvm-readobj/COFFImportDumper.cpp b/llvm/tools/llvm-readobj/COFFImportDumper.cpp --- a/llvm/tools/llvm-readobj/COFFImportDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFImportDumper.cpp @@ -50,7 +50,7 @@ for (const object::BasicSymbolRef &Sym : File->symbols()) { raw_ostream &OS = Writer.startLine(); OS << "Symbol: "; - cantFail(Sym.printName(OS)); + llvm_cantFail(Sym.printName(OS)); OS << "\n"; } } diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -561,7 +561,7 @@ template void DumpStyle::reportUniqueWarning(Error Err) const { handleAllErrors(std::move(Err), [&](const ErrorInfoBase &EI) { - cantFail(WarningHandler(EI.message()), + llvm_cantFail(WarningHandler(EI.message()), "WarningHandler should always return ErrorSuccess"); }); } diff --git a/llvm/tools/obj2yaml/coff2yaml.cpp b/llvm/tools/obj2yaml/coff2yaml.cpp --- a/llvm/tools/obj2yaml/coff2yaml.cpp +++ b/llvm/tools/obj2yaml/coff2yaml.cpp @@ -119,7 +119,7 @@ const object::coff_section *COFFSection = Obj.getCOFFSection(S); - cantFail(Obj.getSectionContents(COFFSection, sectionData)); + llvm_cantFail(Obj.getSectionContents(COFFSection, sectionData)); BinaryStreamReader Reader(sectionData, support::little); uint32_t Magic; @@ -179,7 +179,7 @@ ArrayRef sectionData; if (!ObjSection.isBSS()) - cantFail(Obj.getSectionContents(COFFSection, sectionData)); + llvm_cantFail(Obj.getSectionContents(COFFSection, sectionData)); NewYAMLSection.SectionData = yaml::BinaryRef(sectionData); if (NewYAMLSection.Name == ".debug$S") diff --git a/llvm/unittests/ADT/FallibleIteratorTest.cpp b/llvm/unittests/ADT/FallibleIteratorTest.cpp --- a/llvm/unittests/ADT/FallibleIteratorTest.cpp +++ b/llvm/unittests/ADT/FallibleIteratorTest.cpp @@ -121,7 +121,7 @@ for (auto &Elem : make_fallible_range(begin, end, Err)) EXPECT_TRUE(Elem.isValid()); - cantFail(std::move(Err)); + llvm_cantFail(std::move(Err)); } TEST(FallibleIteratorTest, BasicFailure) { @@ -246,14 +246,14 @@ Error Err = Error::success(); auto I = make_fallible_itr(begin, Err); EXPECT_TRUE(I->isValid()); - cantFail(std::move(Err)); + llvm_cantFail(std::move(Err)); } { Error Err = Error::success(); const auto I = make_fallible_itr(begin, Err); EXPECT_TRUE(I->isValid()); - cantFail(std::move(Err)); + llvm_cantFail(std::move(Err)); } } @@ -285,7 +285,7 @@ EXPECT_THAT_ERROR(V3.takeError(), Succeeded()); ++I; EXPECT_EQ(I, E); - cantFail(std::move(Err)); + llvm_cantFail(std::move(Err)); } } // namespace diff --git a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/CoreAPIsTest.cpp @@ -37,7 +37,7 @@ std::shared_ptr FooMR; - cantFail(JD.define(std::make_unique( + llvm_cantFail(JD.define(std::make_unique( SymbolFlagsMap({{Foo, FooSym.getFlags()}}), [&](MaterializationResponsibility R) { FooMR = std::make_shared(std::move(R)); @@ -48,11 +48,11 @@ EXPECT_FALSE(OnCompletionRun) << "Should not have been resolved yet"; - cantFail(FooMR->notifyResolved({{Foo, FooSym}})); + llvm_cantFail(FooMR->notifyResolved({{Foo, FooSym}})); EXPECT_FALSE(OnCompletionRun) << "Should not be ready yet"; - cantFail(FooMR->notifyEmitted()); + llvm_cantFail(FooMR->notifyEmitted()); EXPECT_TRUE(OnCompletionRun) << "Should have been marked ready"; } @@ -80,7 +80,7 @@ bool OnCompletionRun = false; auto OnCompletion = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); OnCompletionRun = true; }; @@ -100,17 +100,17 @@ // (5) Removal of materialized symbols works. // Foo will be fully materialized. - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); // Bar will be unmaterialized. bool BarDiscarded = false; bool BarMaterializerDestructed = false; - cantFail(JD.define(std::make_unique( + llvm_cantFail(JD.define(std::make_unique( SymbolFlagsMap({{Bar, BarSym.getFlags()}}), [this](MaterializationResponsibility R) { ADD_FAILURE() << "Unexpected materialization of \"Bar\""; - cantFail(R.notifyResolved({{Bar, BarSym}})); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved({{Bar, BarSym}})); + llvm_cantFail(R.notifyEmitted()); }, [&](const JITDylib &JD, const SymbolStringPtr &Name) { EXPECT_EQ(Name, Bar) << "Expected \"Bar\" to be discarded"; @@ -122,7 +122,7 @@ // Baz will be in the materializing state initially, then // materialized for the final removal attempt. Optional BazR; - cantFail(JD.define(std::make_unique( + llvm_cantFail(JD.define(std::make_unique( SymbolFlagsMap({{Baz, BazSym.getFlags()}}), [&](MaterializationResponsibility R) { BazR.emplace(std::move(R)); }, [](const JITDylib &JD, const SymbolStringPtr &Name) { @@ -133,7 +133,7 @@ ES.lookup( JITDylibSearchList({{&JD, false}}), {Foo, Baz}, SymbolState::Ready, [&](Expected Result) { - cantFail(Result.takeError()); + llvm_cantFail(Result.takeError()); OnCompletionRun = true; }, NoDependenciesToRegister); @@ -156,8 +156,8 @@ consumeError(std::move(Err)); } - cantFail(BazR->notifyResolved({{Baz, BazSym}})); - cantFail(BazR->notifyEmitted()); + llvm_cantFail(BazR->notifyResolved({{Baz, BazSym}})); + llvm_cantFail(BazR->notifyEmitted()); { // Attempt 3: Search now that all symbols are fully materialized // (Foo, Baz), or not yet materialized (Bar). @@ -172,7 +172,7 @@ } TEST_F(CoreAPIsStandardTest, ChainedJITDylibLookup) { - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); auto &JD2 = ES.createJITDylib("JD2"); @@ -181,11 +181,11 @@ auto Q = std::make_shared( SymbolNameSet({Foo}), SymbolState::Ready, [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); OnCompletionRun = true; }); - cantFail(JD2.legacyLookup(Q, cantFail(JD.legacyLookup(Q, {Foo})))); + llvm_cantFail(JD2.legacyLookup(Q, cantFail(JD.legacyLookup(Q, {Foo})))); EXPECT_TRUE(OnCompletionRun) << "OnCompletion was not run for empty query"; } @@ -194,13 +194,13 @@ auto BarHiddenFlags = BarSym.getFlags() & ~JITSymbolFlags::Exported; auto BarHiddenSym = JITEvaluatedSymbol(BarSym.getAddress(), BarHiddenFlags); - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarHiddenSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarHiddenSym}}))); auto &JD2 = ES.createJITDylib("JD2"); - cantFail(JD2.define(absoluteSymbols({{Bar, QuxSym}}))); + llvm_cantFail(JD2.define(absoluteSymbols({{Bar, QuxSym}}))); /// Try a blocking lookup. - auto Result = cantFail( + auto Result = llvm_cantFail( ES.lookup(JITDylibSearchList({{&JD, false}, {&JD2, false}}), {Foo, Bar})); EXPECT_EQ(Result.size(), 2U) << "Unexpected number of results"; @@ -223,12 +223,12 @@ llvm_unreachable("Symbol materialized on flags lookup"); }); - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); - cantFail(JD.define(std::move(MU))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(std::move(MU))); SymbolNameSet Names({Foo, Bar, Baz}); - auto SymbolFlags = cantFail(JD.lookupFlags(Names)); + auto SymbolFlags = llvm_cantFail(JD.lookupFlags(Names)); EXPECT_EQ(SymbolFlags.size(), 2U) << "Returned symbol flags contains unexpected results"; @@ -264,10 +264,10 @@ } TEST_F(CoreAPIsStandardTest, TestBasicAliases) { - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); - cantFail(JD.define(symbolAliases({{Baz, {Foo, JITSymbolFlags::Exported}}, + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); + llvm_cantFail(JD.define(symbolAliases({{Baz, {Foo, JITSymbolFlags::Exported}}, {Qux, {Bar, JITSymbolFlags::Weak}}}))); - cantFail(JD.define(absoluteSymbols({{Qux, QuxSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Qux, QuxSym}}))); auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), {Baz, Qux}); EXPECT_TRUE(!!Result) << "Unexpected lookup failure"; @@ -280,8 +280,8 @@ } TEST_F(CoreAPIsStandardTest, TestChainedAliases) { - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); - cantFail(JD.define(symbolAliases( + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(symbolAliases( {{Baz, {Bar, BazSym.getFlags()}}, {Bar, {Foo, BarSym.getFlags()}}}))); auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), {Bar, Baz}); @@ -297,13 +297,13 @@ TEST_F(CoreAPIsStandardTest, TestBasicReExports) { // Test that the basic use case of re-exporting a single symbol from another // JITDylib works. - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); auto &JD2 = ES.createJITDylib("JD2"); - cantFail(JD2.define(reexports(JD, {{Bar, {Foo, BarSym.getFlags()}}}))); + llvm_cantFail(JD2.define(reexports(JD, {{Bar, {Foo, BarSym.getFlags()}}}))); - auto Result = cantFail(ES.lookup(JITDylibSearchList({{&JD2, false}}), Bar)); + auto Result = llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD2, false}}), Bar)); EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) << "Re-export Bar for symbol Foo should match FooSym's address"; } @@ -311,25 +311,25 @@ TEST_F(CoreAPIsStandardTest, TestThatReExportsDontUnnecessarilyMaterialize) { // Test that re-exports do not materialize symbols that have not been queried // for. - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); bool BarMaterialized = false; auto BarMU = std::make_unique( SymbolFlagsMap({{Bar, BarSym.getFlags()}}), [&](MaterializationResponsibility R) { BarMaterialized = true; - cantFail(R.notifyResolved({{Bar, BarSym}})); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved({{Bar, BarSym}})); + llvm_cantFail(R.notifyEmitted()); }); - cantFail(JD.define(BarMU)); + llvm_cantFail(JD.define(BarMU)); auto &JD2 = ES.createJITDylib("JD2"); - cantFail(JD2.define(reexports( + llvm_cantFail(JD2.define(reexports( JD, {{Baz, {Foo, BazSym.getFlags()}}, {Qux, {Bar, QuxSym.getFlags()}}}))); - auto Result = cantFail(ES.lookup(JITDylibSearchList({{&JD2, false}}), Baz)); + auto Result = llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD2, false}}), Baz)); EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) << "Re-export Baz for symbol Foo should match FooSym's address"; @@ -340,17 +340,17 @@ // Test that a re-exports generator can dynamically generate reexports. auto &JD2 = ES.createJITDylib("JD2"); - cantFail(JD2.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); + llvm_cantFail(JD2.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); auto Filter = [this](SymbolStringPtr Name) { return Name != Bar; }; JD.addGenerator(std::make_unique(JD2, false, Filter)); - auto Flags = cantFail(JD.lookupFlags({Foo, Bar, Baz})); + auto Flags = llvm_cantFail(JD.lookupFlags({Foo, Bar, Baz})); EXPECT_EQ(Flags.size(), 1U) << "Unexpected number of results"; EXPECT_EQ(Flags[Foo], FooSym.getFlags()) << "Unexpected flags for Foo"; - auto Result = cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); + auto Result = llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); EXPECT_EQ(Result.getAddress(), FooSym.getAddress()) << "Incorrect reexported symbol address"; @@ -362,11 +362,11 @@ SymbolFlagsMap({{Foo, FooSym.getFlags()}}), [&](MaterializationResponsibility R) { FooR.emplace(std::move(R)); }); - cantFail(JD.define(FooMU)); + llvm_cantFail(JD.define(FooMU)); bool FooReady = false; auto OnCompletion = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); FooReady = true; }; @@ -410,21 +410,21 @@ [&](MaterializationResponsibility R) { BazR.emplace(std::move(R)); }); // Define the symbols. - cantFail(JD.define(FooMU)); - cantFail(JD.define(BarMU)); - cantFail(JD.define(BazMU)); + llvm_cantFail(JD.define(FooMU)); + llvm_cantFail(JD.define(BarMU)); + llvm_cantFail(JD.define(BazMU)); // Query each of the symbols to trigger materialization. bool FooResolved = false; bool FooReady = false; auto OnFooResolution = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); FooResolved = true; }; auto OnFooReady = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); FooReady = true; }; @@ -439,12 +439,12 @@ bool BarResolved = false; bool BarReady = false; auto OnBarResolution = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); BarResolved = true; }; auto OnBarReady = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); BarReady = true; }; @@ -458,12 +458,12 @@ bool BazReady = false; auto OnBazResolution = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); BazResolved = true; }; auto OnBazReady = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); BazReady = true; }; @@ -542,8 +542,8 @@ [&](MaterializationResponsibility R) { BarR.emplace(std::move(R)); }); // Define the symbols. - cantFail(JD.define(FooMU)); - cantFail(JD.define(BarMU)); + llvm_cantFail(JD.define(FooMU)); + llvm_cantFail(JD.define(BarMU)); bool OnFooReadyRun = false; auto OnFooReady = [&](Expected Result) { @@ -605,8 +605,8 @@ [&](MaterializationResponsibility R) { BarR.emplace(std::move(R)); }); // Define the symbols. - cantFail(JD.define(FooMU)); - cantFail(JD.define(BarMU)); + llvm_cantFail(JD.define(FooMU)); + llvm_cantFail(JD.define(BarMU)); bool OnFooReadyRun = false; auto OnFooReady = [&](Expected Result) { @@ -669,8 +669,8 @@ [&](MaterializationResponsibility R) { BarR.emplace(std::move(R)); }); // Define the symbols. - cantFail(JD.define(FooMU)); - cantFail(JD.define(BarMU)); + llvm_cantFail(JD.define(FooMU)); + llvm_cantFail(JD.define(BarMU)); bool OnFooReadyRun = false; auto OnFooReady = [&](Expected Result) { @@ -733,8 +733,8 @@ [&](MaterializationResponsibility R) { BarR.emplace(std::move(R)); }); // Define the symbols. - cantFail(JD.define(FooMU)); - cantFail(JD.define(BarMU)); + llvm_cantFail(JD.define(FooMU)); + llvm_cantFail(JD.define(BarMU)); bool OnFooReadyRun = false; auto OnFooReady = [&](Expected Result) { @@ -785,7 +785,7 @@ R.failMaterialization(); }); - cantFail(JD.define(std::move(MU))); + llvm_cantFail(JD.define(std::move(MU))); // Issue a query for Foo, but not bar. EXPECT_THAT_EXPECTED(ES.lookup({&JD}, {Foo}), Failed()) @@ -818,14 +818,14 @@ }, [&]() { DestructorRun = true; }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); EXPECT_FALSE(DestructorRun) << "MaterializationUnit should not have been destroyed yet"; - cantFail(JD.define(absoluteSymbols({{Bar, BarSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Bar, BarSym}}))); EXPECT_TRUE(DestructorRun) << "MaterializationUnit should have been destroyed"; @@ -842,8 +842,8 @@ SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}, {Bar, WeakExported}}), [&](MaterializationResponsibility R) { assert(BarDiscarded && "Bar should have been discarded by this point"); - cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}}))); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}}))); + llvm_cantFail(R.notifyEmitted()); FooMaterialized = true; }, [&](const JITDylib &JD, SymbolStringPtr Name) { @@ -851,8 +851,8 @@ BarDiscarded = true; }); - cantFail(JD.define(MU)); - cantFail(JD.define(absoluteSymbols({{Bar, BarSym}}))); + llvm_cantFail(JD.define(MU)); + llvm_cantFail(JD.define(absoluteSymbols({{Bar, BarSym}}))); SymbolNameSet Names({Foo}); @@ -883,8 +883,8 @@ auto MU1 = std::make_unique( SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}), [&](MaterializationResponsibility R) { - cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}))); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}))); + llvm_cantFail(R.notifyEmitted()); BarMaterialized = true; }); @@ -900,13 +900,13 @@ DuplicateBarDiscarded = true; }); - cantFail(JD.define(MU1)); - cantFail(JD.define(MU2)); + llvm_cantFail(JD.define(MU1)); + llvm_cantFail(JD.define(MU2)); bool OnCompletionRun = false; auto OnCompletion = [&](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); OnCompletionRun = true; }; @@ -931,26 +931,26 @@ auto MU = std::make_unique( SymbolFlagsMap({{Foo, FooSym.getFlags()}}), [&](MaterializationResponsibility R) { - cantFail( + llvm_cantFail( R.defineMaterializing(SymbolFlagsMap({{Bar, BarSym.getFlags()}}))); - cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}))); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}))); + llvm_cantFail(R.notifyEmitted()); }); - cantFail(JD.define(MU)); - cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); + llvm_cantFail(JD.define(MU)); + llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); // Assert that materialization is complete by now. ExpectNoMoreMaterialization = true; // Look up bar to verify that no further materialization happens. - auto BarResult = cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Bar)); + auto BarResult = llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Bar)); EXPECT_EQ(BarResult.getAddress(), BarSym.getAddress()) << "Expected Bar == BarSym"; } TEST_F(CoreAPIsStandardTest, GeneratorTest) { - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); class TestGenerator : public JITDylib::DefinitionGenerator { public: @@ -966,7 +966,7 @@ NewNames.insert(Name); } } - cantFail(JD.define(absoluteSymbols(std::move(NewDefs)))); + llvm_cantFail(JD.define(absoluteSymbols(std::move(NewDefs)))); return NewNames; }; @@ -977,7 +977,7 @@ JD.addGenerator(std::make_unique(SymbolMap({{Bar, BarSym}}))); auto Result = - cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Bar})); + llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Bar})); EXPECT_EQ(Result.count(Bar), 1U) << "Expected to find fallback def for 'bar'"; EXPECT_EQ(Result[Bar].getAddress(), BarSym.getAddress()) @@ -992,7 +992,7 @@ R.failMaterialization(); }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); SymbolNameSet Names({Foo, Bar}); auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), Names); @@ -1020,12 +1020,12 @@ TEST_F(CoreAPIsStandardTest, FailEmissionAfterResolution) { - cantFail(JD.define(absoluteSymbols({{Baz, BazSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Baz, BazSym}}))); auto MU = std::make_unique( SymbolFlagsMap({{Foo, FooSym.getFlags()}, {Bar, BarSym.getFlags()}}), [&](MaterializationResponsibility R) { - cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}))); + llvm_cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}, {Bar, BarSym}}))); ES.lookup( JITDylibSearchList({{&JD, false}}), SymbolNameSet({Baz}), @@ -1036,7 +1036,7 @@ // this materialization before Baz has been finalized in // order to test that error propagation is correct in this // scenario. - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); R.failMaterialization(); }, [&](const SymbolDependenceMap &Deps) { @@ -1044,7 +1044,7 @@ }); }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); SymbolNameSet Names({Foo, Bar}); auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), Names); @@ -1055,14 +1055,14 @@ TEST_F(CoreAPIsStandardTest, FailAfterPartialResolution) { - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); // Fail materialization of bar. auto BarMU = std::make_unique( SymbolFlagsMap({{Bar, BarSym.getFlags()}}), [&](MaterializationResponsibility R) { R.failMaterialization(); }); - cantFail(JD.define(std::move(BarMU))); + llvm_cantFail(JD.define(std::move(BarMU))); bool QueryHandlerRun = false; ES.lookup( @@ -1081,14 +1081,14 @@ auto MU = std::make_unique( SymbolFlagsMap({{Foo, JITSymbolFlags::Exported}}), [&](MaterializationResponsibility R) { - cantFail(R.notifyResolved({{Foo, FooSym}})); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved({{Foo, FooSym}})); + llvm_cantFail(R.notifyEmitted()); }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); auto FooLookupResult = - cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); + llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress()) << "lookup returned an incorrect address"; @@ -1106,10 +1106,10 @@ std::thread([MU = std::move(MU), &JD] { MU->doMaterialize(JD); }); }); - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}}))); auto FooLookupResult = - cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); + llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress()) << "lookup returned an incorrect address"; @@ -1139,26 +1139,26 @@ auto NewMU = std::make_unique( SymbolFlagsMap({{Bar, BarSym.getFlags()}}), [&](MaterializationResponsibility R2) { - cantFail(R2.notifyResolved(SymbolMap({{Bar, BarSym}}))); - cantFail(R2.notifyEmitted()); + llvm_cantFail(R2.notifyResolved(SymbolMap({{Bar, BarSym}}))); + llvm_cantFail(R2.notifyEmitted()); BarMaterialized = true; }); R.replace(std::move(NewMU)); - cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}}))); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyResolved(SymbolMap({{Foo, FooSym}}))); + llvm_cantFail(R.notifyEmitted()); FooMaterialized = true; }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); EXPECT_FALSE(FooMaterialized) << "Foo should not be materialized yet"; EXPECT_FALSE(BarMaterialized) << "Bar should not be materialized yet"; auto FooSymResult = - cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); + llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Foo)); EXPECT_EQ(FooSymResult.getAddress(), FooSym.getAddress()) << "Address mismatch for Foo"; @@ -1166,7 +1166,7 @@ EXPECT_FALSE(BarMaterialized) << "Bar still should not be materialized"; auto BarSymResult = - cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Bar)); + llvm_cantFail(ES.lookup(JITDylibSearchList({{&JD, false}}), Bar)); EXPECT_EQ(BarSymResult.getAddress(), BarSym.getAddress()) << "Address mismatch for Bar"; EXPECT_TRUE(BarMaterialized) << "Bar should be materialized now"; @@ -1178,13 +1178,13 @@ [&](MaterializationResponsibility R) { auto R2 = R.delegate({Bar}); - cantFail(R.notifyResolved({{Foo, FooSym}})); - cantFail(R.notifyEmitted()); - cantFail(R2.notifyResolved({{Bar, BarSym}})); - cantFail(R2.notifyEmitted()); + llvm_cantFail(R.notifyResolved({{Foo, FooSym}})); + llvm_cantFail(R.notifyEmitted()); + llvm_cantFail(R2.notifyResolved({{Bar, BarSym}})); + llvm_cantFail(R2.notifyEmitted()); }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); auto Result = ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo, Bar}); @@ -1211,9 +1211,9 @@ std::make_unique(std::move(R)); }); - cantFail(JD.define(MU)); + llvm_cantFail(JD.define(MU)); auto OnCompletion = [](Expected Result) { - cantFail(std::move(Result)); + llvm_cantFail(std::move(Result)); }; ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, SymbolState::Ready, @@ -1232,8 +1232,8 @@ consumeError(std::move(Err)); // No dependencies registered, can't fail: - cantFail(FooResponsibility->notifyResolved(SymbolMap({{Foo, FooSym}}))); - cantFail(FooResponsibility->notifyEmitted()); + llvm_cantFail(FooResponsibility->notifyResolved(SymbolMap({{Foo, FooSym}}))); + llvm_cantFail(FooResponsibility->notifyEmitted()); } } // namespace diff --git a/llvm/unittests/ExecutionEngine/Orc/GlobalMappingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/GlobalMappingLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/GlobalMappingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/GlobalMappingLayerTest.cpp @@ -33,7 +33,7 @@ GlobalMappingLayer L(TestBaseLayer); // Test addModule interface. - int H = cantFail(L.addModule(nullptr, nullptr)); + int H = llvm_cantFail(L.addModule(nullptr, nullptr)); EXPECT_EQ(H, 42) << "Incorrect result from addModule"; // Test fall-through for missing symbol. @@ -42,14 +42,14 @@ // Test fall-through for symbol in base layer. auto BarSym = L.findSymbol("bar", true); - EXPECT_EQ(cantFail(BarSym.getAddress()), + EXPECT_EQ(llvm_cantFail(BarSym.getAddress()), static_cast(0x4567)) << "Symbol lookup fall-through failed."; // Test setup of a global mapping. L.setGlobalMapping("foo", 0x0123); auto FooSym2 = L.findSymbol("foo", true); - EXPECT_EQ(cantFail(FooSym2.getAddress()), + EXPECT_EQ(llvm_cantFail(FooSym2.getAddress()), static_cast(0x0123)) << "Symbol mapping setup failed."; diff --git a/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp b/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp @@ -22,7 +22,7 @@ // Make sure LLVM has been initialized. OrcNativeTarget::initialize(); - auto JTMB = cantFail(JITTargetMachineBuilder::detectHost()); + auto JTMB = llvm_cantFail(JITTargetMachineBuilder::detectHost()); // Test API by performing a bunch of no-ops. JTMB.setCPU(""); diff --git a/llvm/unittests/ExecutionEngine/Orc/LazyCallThroughAndReexportsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LazyCallThroughAndReexportsTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/LazyCallThroughAndReexportsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/LazyCallThroughAndReexportsTest.cpp @@ -37,17 +37,17 @@ bool DummyTargetMaterialized = false; - cantFail(JD.define(std::make_unique( + llvm_cantFail(JD.define(std::make_unique( SymbolFlagsMap({{DummyTarget, JITSymbolFlags::Exported}}), [&](MaterializationResponsibility R) { DummyTargetMaterialized = true; // No dependencies registered, can't fail. - cantFail(R.notifyResolved( + llvm_cantFail(R.notifyResolved( {{DummyTarget, JITEvaluatedSymbol(static_cast( reinterpret_cast(&dummyTarget)), JITSymbolFlags::Exported)}})); - cantFail(R.notifyEmitted()); + llvm_cantFail(R.notifyEmitted()); }))); unsigned NotifyResolvedCount = 0; @@ -58,7 +58,7 @@ return Error::success(); }); - auto CallThroughTrampoline = cantFail((*LCTM)->getCallThroughTrampoline( + auto CallThroughTrampoline = llvm_cantFail((*LCTM)->getCallThroughTrampoline( JD, DummyTarget, std::move(NotifyResolved))); auto CTTPtr = reinterpret_cast( diff --git a/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp @@ -24,7 +24,7 @@ MockBaseLayer M; llvm::orc::LazyEmittingLayer L( llvm::AcknowledgeORCv1Deprecation, M); - cantFail( + llvm_cantFail( L.addModule(llvm::orc::VModuleKey(), std::unique_ptr())); } diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/LegacyAPIInteropTest.cpp @@ -20,11 +20,11 @@ TEST_F(LegacyAPIsStandardTest, TestLambdaSymbolResolver) { BarSym.setFlags(BarSym.getFlags() | JITSymbolFlags::Weak); - cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); + llvm_cantFail(JD.define(absoluteSymbols({{Foo, FooSym}, {Bar, BarSym}}))); auto Resolver = createSymbolResolver( [&](const SymbolNameSet &Symbols) { - auto FlagsMap = cantFail(JD.lookupFlags(Symbols)); + auto FlagsMap = llvm_cantFail(JD.lookupFlags(Symbols)); SymbolNameSet Result; for (auto &KV : FlagsMap) if (!KV.second.isStrong()) @@ -32,7 +32,7 @@ return Result; }, [&](std::shared_ptr Q, SymbolNameSet Symbols) { - return cantFail(JD.legacyLookup(std::move(Q), Symbols)); + return llvm_cantFail(JD.legacyLookup(std::move(Q), Symbols)); }); auto RS = Resolver->getResponsibilitySet(SymbolNameSet({Bar, Baz})); diff --git a/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/LegacyRTDyldObjectLinkingLayerTest.cpp @@ -99,23 +99,23 @@ { // Test with ProcessAllSections = false (the default). auto K = ES.allocateVModule(); - cantFail(ObjLayer.addObject( + llvm_cantFail(ObjLayer.addObject( K, MemoryBuffer::getMemBufferCopy(Obj->getBuffer()))); - cantFail(ObjLayer.emitAndFinalize(K)); + llvm_cantFail(ObjLayer.emitAndFinalize(K)); EXPECT_EQ(DebugSectionSeen, false) << "Unexpected debug info section"; - cantFail(ObjLayer.removeObject(K)); + llvm_cantFail(ObjLayer.removeObject(K)); } { // Test with ProcessAllSections = true. ObjLayer.setProcessAllSections(true); auto K = ES.allocateVModule(); - cantFail(ObjLayer.addObject(K, std::move(Obj))); - cantFail(ObjLayer.emitAndFinalize(K)); + llvm_cantFail(ObjLayer.addObject(K, std::move(Obj))); + llvm_cantFail(ObjLayer.emitAndFinalize(K)); EXPECT_EQ(DebugSectionSeen, true) << "Expected debug info section not seen"; - cantFail(ObjLayer.removeObject(K)); + llvm_cantFail(ObjLayer.removeObject(K)); } } @@ -182,7 +182,7 @@ auto K1 = ES.allocateVModule(); Resolvers[K1] = std::make_shared(); - cantFail(ObjLayer.addObject(K1, std::move(Obj1))); + llvm_cantFail(ObjLayer.addObject(K1, std::move(Obj1))); auto K2 = ES.allocateVModule(); auto LegacyLookup = [&](const std::string &Name) { @@ -191,7 +191,7 @@ Resolvers[K2] = createSymbolResolver( [&](const SymbolNameSet &Symbols) { - return cantFail( + return llvm_cantFail( getResponsibilitySetWithLegacyFn(Symbols, LegacyLookup)); }, [&](std::shared_ptr Query, @@ -199,9 +199,9 @@ return lookupWithLegacyFn(ES, *Query, Symbols, LegacyLookup); }); - cantFail(ObjLayer.addObject(K2, std::move(Obj2))); - cantFail(ObjLayer.emitAndFinalize(K2)); - cantFail(ObjLayer.removeObject(K2)); + llvm_cantFail(ObjLayer.addObject(K2, std::move(Obj2))); + llvm_cantFail(ObjLayer.emitAndFinalize(K2)); + llvm_cantFail(ObjLayer.removeObject(K2)); // Finalization of module 2 should trigger finalization of module 1. // Verify that finalize on SMMW is only called once. @@ -267,10 +267,10 @@ auto Obj2 = Compile(*MB2.getModule()); auto K = ES.allocateVModule(); - cantFail(ObjLayer.addObject(K, std::move(Obj1))); - cantFail(ObjLayer.addObject(ES.allocateVModule(), std::move(Obj2))); - cantFail(ObjLayer.emitAndFinalize(K)); - cantFail(ObjLayer.removeObject(K)); + llvm_cantFail(ObjLayer.addObject(K, std::move(Obj1))); + llvm_cantFail(ObjLayer.addObject(ES.allocateVModule(), std::move(Obj2))); + llvm_cantFail(ObjLayer.emitAndFinalize(K)); + llvm_cantFail(ObjLayer.removeObject(K)); // Only one call to needsToReserveAllocationSpace should have been made. EXPECT_EQ(MM->NeedsToReserveAllocationSpaceCount, 1) diff --git a/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp @@ -89,8 +89,8 @@ } void verifyFindSymbol(llvm::JITSymbol Returned) { EXPECT_EQ("findSymbol", LastCalled); - EXPECT_EQ(cantFail(MockSymbol.getAddress()), - cantFail(Returned.getAddress())) + EXPECT_EQ(llvm_cantFail(MockSymbol.getAddress()), + llvm_cantFail(Returned.getAddress())) << "Return should pass through"; resetExpectations(); } @@ -112,8 +112,8 @@ } void verifyFindSymbolIn(llvm::JITSymbol Returned) { EXPECT_EQ("findSymbolIn", LastCalled); - EXPECT_EQ(cantFail(MockSymbol.getAddress()), - cantFail(Returned.getAddress())) + EXPECT_EQ(llvm_cantFail(MockSymbol.getAddress()), + llvm_cantFail(Returned.getAddress())) << "Return should pass through"; resetExpectations(); } @@ -200,20 +200,20 @@ auto K1 = ES.allocateVModule(); auto Obj1 = std::make_shared(211); M.expectAddObject(K1, Obj1); - cantFail(T1.addObject(K1, std::move(Obj1))); + llvm_cantFail(T1.addObject(K1, std::move(Obj1))); M.verifyAddObject(); // Test addObjectSet with T2 (mutating) auto K2 = ES.allocateVModule(); auto Obj2 = std::make_shared(222); M.expectAddObject(K2, Obj2); - cantFail(T2.addObject(K2, Obj2)); + llvm_cantFail(T2.addObject(K2, Obj2)); M.verifyAddObject(); EXPECT_EQ(223, *Obj2) << "Expected mutation"; // Test removeObjectSet M.expectRemoveObject(K2); - cantFail(T1.removeObject(K2)); + llvm_cantFail(T1.removeObject(K2)); M.verifyRemoveObject(); // Test findSymbol @@ -232,7 +232,7 @@ // Test emitAndFinalize M.expectEmitAndFinalize(K1); - cantFail(T2.emitAndFinalize(K1)); + llvm_cantFail(T2.emitAndFinalize(K1)); M.verifyEmitAndFinalize(); // Test mapSectionAddress @@ -305,16 +305,16 @@ // Make sure that the calls from LegacyIRCompileLayer to LegacyObjectTransformLayer // compile. - cantFail(CompileLayer.addModule(ES.allocateVModule(), + llvm_cantFail(CompileLayer.addModule(ES.allocateVModule(), std::unique_ptr())); // Make sure that the calls from LegacyObjectTransformLayer to ObjectLinkingLayer // compile. VModuleKey DummyKey = ES.allocateVModule(); - cantFail(TransformLayer.emitAndFinalize(DummyKey)); + llvm_cantFail(TransformLayer.emitAndFinalize(DummyKey)); TransformLayer.findSymbolIn(DummyKey, Name, false); TransformLayer.findSymbol(Name, true); TransformLayer.mapSectionAddress(DummyKey, nullptr, 0); - cantFail(TransformLayer.removeObject(DummyKey)); + llvm_cantFail(TransformLayer.removeObject(DummyKey)); } } diff --git a/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp @@ -283,7 +283,7 @@ [](std::function SendResult, bool B) { EXPECT_EQ(B, true) << "Server void(bool) receieved unexpected result"; - cantFail(SendResult(Error::success())); + llvm_cantFail(SendResult(Error::success())); return Error::success(); }); @@ -628,16 +628,16 @@ // Handle the negotiate plus one call. for (unsigned I = 0; I != 2; ++I) - cantFail(Server.handleOne()); + llvm_cantFail(Server.handleOne()); }); - cantFail(Client.callAsync( + llvm_cantFail(Client.callAsync( [&](Error Err) { EXPECT_FALSE(!!Err) << "Expected success value"; return Error::success(); })); - cantFail(Client.handleOne()); + llvm_cantFail(Client.handleOne()); ServerThread.join(); } @@ -657,10 +657,10 @@ // Handle the negotiate plus one call. for (unsigned I = 0; I != 2; ++I) - cantFail(Server.handleOne()); + llvm_cantFail(Server.handleOne()); }); - cantFail(Client.callAsync( + llvm_cantFail(Client.callAsync( [&](Error Err) { EXPECT_TRUE(Err.isA()) << "Incorrect error type"; @@ -672,7 +672,7 @@ }); })); - cantFail(Client.handleOne()); + llvm_cantFail(Client.handleOne()); ServerThread.join(); } @@ -692,10 +692,10 @@ // Handle the negotiate plus one call. for (unsigned I = 0; I != 2; ++I) - cantFail(Server.handleOne()); + llvm_cantFail(Server.handleOne()); }); - cantFail(Client.callAsync( + llvm_cantFail(Client.callAsync( [&](Expected ValOrErr) { EXPECT_TRUE(!!ValOrErr) << "Expected success value"; @@ -704,7 +704,7 @@ return Error::success(); })); - cantFail(Client.handleOne()); + llvm_cantFail(Client.handleOne()); ServerThread.join(); } @@ -724,10 +724,10 @@ // Handle the negotiate plus one call. for (unsigned I = 0; I != 2; ++I) - cantFail(Server.handleOne()); + llvm_cantFail(Server.handleOne()); }); - cantFail(Client.callAsync( + llvm_cantFail(Client.callAsync( [&](Expected ValOrErr) { EXPECT_FALSE(!!ValOrErr) << "Expected failure value"; @@ -742,7 +742,7 @@ }); })); - cantFail(Client.handleOne()); + llvm_cantFail(Client.handleOne()); ServerThread.join(); } diff --git a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp @@ -58,11 +58,11 @@ }); auto OnResolveDoNothing = [](Expected R) { - cantFail(std::move(R)); + llvm_cantFail(std::move(R)); }; ObjLayer.setProcessAllSections(ProcessAllSections); - cantFail(ObjLayer.add(JD, std::move(Obj), ES.allocateVModule())); + llvm_cantFail(ObjLayer.add(JD, std::move(Obj), ES.allocateVModule())); ES.lookup(JITDylibSearchList({{&JD, false}}), {Foo}, SymbolState::Resolved, OnResolveDoNothing, NoDependenciesToRegister); @@ -158,10 +158,10 @@ ObjLayer.setOverrideObjectFlagsWithResponsibilityFlags(true); - cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule())); + llvm_cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule())); ES.lookup( JITDylibSearchList({{&JD, false}}), {Foo}, SymbolState::Resolved, - [](Expected R) { cantFail(std::move(R)); }, + [](Expected R) { llvm_cantFail(std::move(R)); }, NoDependenciesToRegister); } @@ -223,10 +223,10 @@ ObjLayer.setAutoClaimResponsibilityForObjectSymbols(true); - cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule())); + llvm_cantFail(CompileLayer.add(JD, std::move(M), ES.allocateVModule())); ES.lookup( JITDylibSearchList({{&JD, false}}), {Foo}, SymbolState::Resolved, - [](Expected R) { cantFail(std::move(R)); }, + [](Expected R) { llvm_cantFail(std::move(R)); }, NoDependenciesToRegister); } diff --git a/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp b/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp --- a/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/RemoteObjectLayerTest.cpp @@ -156,12 +156,12 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - cantFail(Client.addObject(std::move(TestObject), + llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -203,7 +203,7 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); auto HandleOrErr = Client.addObject(std::move(TestObject), @@ -215,7 +215,7 @@ EXPECT_EQ(ErrMsg, "AddObjectFailure - Test Message") << "Expected error string to be \"AddObjectFailure - Test Message\""; - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -255,15 +255,15 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - auto H = cantFail(Client.addObject(std::move(TestObject), + auto H = llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); - cantFail(Client.removeObject(H)); + llvm_cantFail(Client.removeObject(H)); - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -306,10 +306,10 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - auto H = cantFail(Client.addObject(std::move(TestObject), + auto H = llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); auto Err = Client.removeObject(H); @@ -319,7 +319,7 @@ EXPECT_EQ(ErrMsg, "Object handle 42 not found") << "Expected error string to be \"Object handle 42 not found\""; - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -370,16 +370,16 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - cantFail(Client.addObject(std::move(TestObject), + llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); // Check that we can find and materialize a valid symbol. auto Sym1 = Client.findSymbol("foobar", true); EXPECT_TRUE(!!Sym1) << "Symbol 'foobar' should be findable"; - EXPECT_EQ(cantFail(Sym1.getAddress()), 0x12348765ULL) + EXPECT_EQ(llvm_cantFail(Sym1.getAddress()), 0x12348765ULL) << "Symbol 'foobar' does not return the correct address"; { @@ -401,7 +401,7 @@ EXPECT_FALSE(!!Err) << "Symbol 'baz' should not contain an error"; } - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -459,16 +459,16 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - auto H = cantFail(Client.addObject(std::move(TestObject), + auto H = llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); auto Sym1 = Client.findSymbolIn(H, "foobar", true); EXPECT_TRUE(!!Sym1) << "Symbol 'foobar' should be findable"; - EXPECT_EQ(cantFail(Sym1.getAddress()), 0x12348765ULL) + EXPECT_EQ(llvm_cantFail(Sym1.getAddress()), 0x12348765ULL) << "Symbol 'foobar' does not return the correct address"; auto Sym2 = Client.findSymbolIn(H, "barbaz", true); @@ -479,7 +479,7 @@ EXPECT_EQ(ErrMsg, "Could not find symbol 'barbaz'") << "Expected symbol-not-found error for Sym2"; - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -518,16 +518,16 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - auto H = cantFail(Client.addObject(std::move(TestObject), + auto H = llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); auto Err = Client.emitAndFinalize(H); EXPECT_FALSE(!!Err) << "emitAndFinalize should work"; - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } @@ -568,10 +568,10 @@ auto ServerThread = std::thread([&]() { while (!Finished) - cantFail(ServerEP.handleOne()); + llvm_cantFail(ServerEP.handleOne()); }); - auto H = cantFail(Client.addObject(std::move(TestObject), + auto H = llvm_cantFail(Client.addObject(std::move(TestObject), std::make_shared())); auto Err = Client.emitAndFinalize(H); @@ -581,7 +581,7 @@ EXPECT_EQ(ErrMsg, "Object handle 1 not found") << "emitAndFinalize returned incorrect error"; - cantFail(ClientEP.callB()); + llvm_cantFail(ClientEP.callB()); ServerThread.join(); } diff --git a/llvm/unittests/Support/ErrorTest.cpp b/llvm/unittests/Support/ErrorTest.cpp --- a/llvm/unittests/Support/ErrorTest.cpp +++ b/llvm/unittests/Support/ErrorTest.cpp @@ -390,8 +390,8 @@ }; EXPECT_DEATH(FailToHandle(), - "Failure value returned from cantFail wrapped call\n" - "CustomError \\{7\\}") + "CustomError \\{7\\}\n" + "Failure value returned from cantFail wrapped call") << "Unhandled Error in handleAllErrors call did not cause an " "abort()"; } @@ -410,8 +410,8 @@ }; EXPECT_DEATH(ReturnErrorFromHandler(), - "Failure value returned from cantFail wrapped call\n" - "CustomError \\{7\\}") + "CustomError \\{7\\}\n" + "Failure value returned from cantFail wrapped call") << " Error returned from handler in handleAllErrors call did not " "cause abort()"; } @@ -499,37 +499,55 @@ // Test that the ExitOnError utility works as expected. TEST(Error, CantFailSuccess) { - cantFail(Error::success()); + llvm_cantFail(Error::success()); - int X = cantFail(Expected(42)); - EXPECT_EQ(X, 42) << "Expected value modified by cantFail"; + int X = llvm_cantFail(Expected(42)); + EXPECT_EQ(X, 42) << "Expected value modified by llvm_cantFail"; int Dummy = 42; - int &Y = cantFail(Expected(Dummy)); - EXPECT_EQ(&Dummy, &Y) << "Reference mangled by cantFail"; + int &Y = llvm_cantFail(Expected(Dummy)); + EXPECT_EQ(&Dummy, &Y) << "Reference mangled by llvm_cantFail"; } -// Test that cantFail results in a crash if you pass it a failure value. +// Test that llvm_cantFail results in a crash if you pass it a failure value. #if LLVM_ENABLE_ABI_BREAKING_CHECKS && !defined(NDEBUG) TEST(Error, CantFailDeath) { - EXPECT_DEATH(cantFail(make_error("Original error message", + EXPECT_DEATH(llvm_cantFail(make_error("Original error message", inconvertibleErrorCode()), "Cantfail call failed"), - "Cantfail call failed\n" - "Original error message") - << "cantFail(Error) did not cause an abort for failure value"; + "Original error message\n" + "Cantfail call failed") + << "llvm_cantFail(Error) did not cause an abort for failure value"; EXPECT_DEATH( { auto IEC = inconvertibleErrorCode(); - int X = cantFail(Expected(make_error("foo", IEC))); + int X = llvm_cantFail(Expected(make_error("foo", IEC))); (void)X; }, "Failure value returned from cantFail wrapped call") - << "cantFail(Expected) did not cause an abort for failure value"; + << "llvm_cantFail(Expected) did not cause an abort for failure value"; } #endif +TEST(Error, CantFailSourceLocation) { + std::string ErrStr; + raw_string_ostream OS(ErrStr); + OS << "\nFailure value returned from cantFail wrapped call"; + +#if defined(NDEBUG) + // __FILE__ and __LINE_ not added + OS << "\n"; + EXPECT_DEATH(llvm_cantFail(make_error(1)), OS.str()) + << "llvm_cantFail(Error) did not cause an abort for failure value"; +#else + // __FILE__ and __LINE__ added + int Line = __LINE__; + OS << " at " << __FILE__ << ":" << (Line + 2) << "\n"; + EXPECT_DEATH(llvm_cantFail(make_error(1)), OS.str()) + << "llvm_cantFail(Error) did not cause an abort for failure value"; +#endif +} // Test Checked Expected in success mode. TEST(Error, CheckedExpectedInSuccessMode) { diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -727,7 +727,7 @@ EXPECT_EQ(Successes, 16); for (fs::TempFile &T : TempFiles) - cantFail(T.discard()); + llvm_cantFail(T.discard()); } TEST_F(FileSystemTest, CreateDir) {