[Patch] Delete deprecated C API

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 11 12:16:31 PST 2016


3.8 has branched. Is it safe to start removing deprecated C apis or
should we wait for it to be released?

If safe, the attached patch deletes one.

Cheers,
Rafael
-------------- next part --------------
diff --git a/include/llvm-c/Linker.h b/include/llvm-c/Linker.h
index 4d9bd46..d02c37f 100644
--- a/include/llvm-c/Linker.h
+++ b/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/include/llvm/Linker/Linker.h b/include/llvm/Linker/Linker.h
index 7aa4cb6..c83298c 100644
--- a/include/llvm/Linker/Linker.h
+++ b/include/llvm/Linker/Linker.h
@@ -51,10 +51,6 @@ public:
                     DenseSet<const GlobalValue *> *FunctionsToImport = nullptr,
                     DenseMap<unsigned, MDNode *> *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<Module> Src,
                           unsigned Flags = Flags::None);
 
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index b96a6f4..f17d537 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -557,11 +557,6 @@ bool Linker::linkInModule(std::unique_ptr<Module> 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<unsigned, MDNode *> *ValIDToTempMDMap) {
   SetVector<GlobalValue *> ValuesToLink;
@@ -592,35 +587,6 @@ bool Linker::linkModules(Module &Dest, std::unique_ptr<Module> Src,
 // C API.
 //===----------------------------------------------------------------------===//
 
-static void diagnosticHandler(const DiagnosticInfo &DI, void *C) {
-  auto *Message = reinterpret_cast<std::string *>(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<Module> M(unwrap(Src));
diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp
index 322a44f..10a89f3 100644
--- a/unittests/Linker/LinkModulesTest.cpp
+++ b/unittests/Linker/LinkModulesTest.cpp
@@ -202,30 +202,6 @@ TEST_F(LinkModuleTest, TypeMerge) {
             M1->getNamedGlobal("t2")->getType());
 }
 
-TEST_F(LinkModuleTest, CAPISuccess) {
-  std::unique_ptr<Module> DestM(getExternal(Ctx, "foo"));
-  std::unique_ptr<Module> 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<Module> DestM(getExternal(Ctx, "foo"));
-  std::unique_ptr<Module> 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<Module> DestM(getExternal(Ctx, "foo"));
   std::unique_ptr<Module> SourceM(getExternal(Ctx, "bar"));


More information about the llvm-commits mailing list