From cbc31d699b75b6d14ac50117386814270cd6a859 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 12 Feb 2016 15:28:45 +0000 Subject: [PATCH] Delete the deprecated LLVMLinkModules. llvm-svn: 260683 --- llvm/docs/ReleaseNotes.rst | 4 +++- llvm/include/llvm-c/Linker.h | 14 ------------- llvm/include/llvm/Linker/Linker.h | 4 ---- llvm/lib/Linker/LinkModules.cpp | 34 ------------------------------- llvm/unittests/Linker/LinkModulesTest.cpp | 24 ---------------------- 5 files changed, 3 insertions(+), 77 deletions(-) diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index b712b95..cf86f44 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -35,11 +35,13 @@ Non-comprehensive list of changes in this release ================================================= * .. note about autoconf build having been removed. -* .. note about C API functions LLVMLinkModules, LLVMParseBitcode, +* .. note about C API functions LLVMParseBitcode, LLVMParseBitcodeInContext, LLVMGetBitcodeModuleInContext and LLVMGetBitcodeModule having been removed. LLVMGetTargetMachineData has been removed (use LLVMGetDataLayout instead). +* The C API function LLVMLinkModules has been removed. + .. NOTE For small 1-3 sentence descriptions, just add an entry at the end of this list. If your description won't fit comfortably in one bullet diff --git a/llvm/include/llvm-c/Linker.h b/llvm/include/llvm-c/Linker.h index 4d9bd46..d02c37f 100644 --- a/llvm/include/llvm-c/Linker.h +++ b/llvm/include/llvm-c/Linker.h @@ -28,20 +28,6 @@ typedef enum { } LLVMLinkerMode; /* Links the source module into the destination module. The source module is - * damaged. The only thing that can be done is destroy it. Optionally returns a - * human-readable description of any errors that occurred in linking. OutMessage - * must be disposed with LLVMDisposeMessage. The return value is true if an - * error occurred, false otherwise. - * - * Note that the linker mode parameter \p Unused is no longer used, and has - * no effect. - * - * This function is deprecated. Use LLVMLinkModules2 instead. - */ -LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, - LLVMLinkerMode Unused, char **OutMessage); - -/* Links the source module into the destination module. The source module is * destroyed. * The return value is true if an error occurred, false otherwise. * Use the diagnostic handler to get any diagnostic message. diff --git a/llvm/include/llvm/Linker/Linker.h b/llvm/include/llvm/Linker/Linker.h index 7aa4cb6..c83298c 100644 --- a/llvm/include/llvm/Linker/Linker.h +++ b/llvm/include/llvm/Linker/Linker.h @@ -51,10 +51,6 @@ public: DenseSet *FunctionsToImport = nullptr, DenseMap *ValIDToTempMDMap = nullptr); - /// This exists to implement the deprecated LLVMLinkModules C api. Don't use - /// for anything else. - bool linkInModuleForCAPI(Module &Src); - static bool linkModules(Module &Dest, std::unique_ptr Src, unsigned Flags = Flags::None); diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index b96a6f4..f17d537 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -557,11 +557,6 @@ bool Linker::linkInModule(std::unique_ptr Src, unsigned Flags, return ModLinker.run(); } -bool Linker::linkInModuleForCAPI(Module &Src) { - ModuleLinker ModLinker(Mover, Src, 0, nullptr, nullptr); - return ModLinker.run(); -} - bool Linker::linkInMetadata(Module &Src, DenseMap *ValIDToTempMDMap) { SetVector ValuesToLink; @@ -592,35 +587,6 @@ bool Linker::linkModules(Module &Dest, std::unique_ptr Src, // C API. //===----------------------------------------------------------------------===// -static void diagnosticHandler(const DiagnosticInfo &DI, void *C) { - auto *Message = reinterpret_cast(C); - raw_string_ostream Stream(*Message); - DiagnosticPrinterRawOStream DP(Stream); - DI.print(DP); -} - -LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, - LLVMLinkerMode Unused, char **OutMessages) { - Module *D = unwrap(Dest); - LLVMContext &Ctx = D->getContext(); - - LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = - Ctx.getDiagnosticHandler(); - void *OldDiagnosticContext = Ctx.getDiagnosticContext(); - std::string Message; - Ctx.setDiagnosticHandler(diagnosticHandler, &Message, true); - - Linker L(*D); - Module *M = unwrap(Src); - LLVMBool Result = L.linkInModuleForCAPI(*M); - - Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext, true); - - if (OutMessages && Result) - *OutMessages = strdup(Message.c_str()); - return Result; -} - LLVMBool LLVMLinkModules2(LLVMModuleRef Dest, LLVMModuleRef Src) { Module *D = unwrap(Dest); std::unique_ptr M(unwrap(Src)); diff --git a/llvm/unittests/Linker/LinkModulesTest.cpp b/llvm/unittests/Linker/LinkModulesTest.cpp index 322a44f..10a89f3 100644 --- a/llvm/unittests/Linker/LinkModulesTest.cpp +++ b/llvm/unittests/Linker/LinkModulesTest.cpp @@ -202,30 +202,6 @@ TEST_F(LinkModuleTest, TypeMerge) { M1->getNamedGlobal("t2")->getType()); } -TEST_F(LinkModuleTest, CAPISuccess) { - std::unique_ptr DestM(getExternal(Ctx, "foo")); - std::unique_ptr SourceM(getExternal(Ctx, "bar")); - char *errout = nullptr; - LLVMBool result = LLVMLinkModules(wrap(DestM.get()), wrap(SourceM.get()), - LLVMLinkerDestroySource, &errout); - EXPECT_EQ(0, result); - EXPECT_EQ(nullptr, errout); - // "bar" is present in destination module - EXPECT_NE(nullptr, DestM->getFunction("bar")); -} - -TEST_F(LinkModuleTest, CAPIFailure) { - // Symbol clash between two modules - std::unique_ptr DestM(getExternal(Ctx, "foo")); - std::unique_ptr SourceM(getExternal(Ctx, "foo")); - char *errout = nullptr; - LLVMBool result = LLVMLinkModules(wrap(DestM.get()), wrap(SourceM.get()), - LLVMLinkerDestroySource, &errout); - EXPECT_EQ(1, result); - EXPECT_STREQ("Linking globals named 'foo': symbol multiply defined!", errout); - LLVMDisposeMessage(errout); -} - TEST_F(LinkModuleTest, NewCAPISuccess) { std::unique_ptr DestM(getExternal(Ctx, "foo")); std::unique_ptr SourceM(getExternal(Ctx, "bar")); -- 2.7.4