summaryrefslogtreecommitdiff
path: root/lib/Linker/LinkModules.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Linker/LinkModules.cpp')
-rw-r--r--lib/Linker/LinkModules.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 630289b2bd..7293f3d0e8 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -25,6 +25,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
+#include "llvm-c/Linker.h"
#include <cctype>
using namespace llvm;
@@ -1335,3 +1336,17 @@ bool Linker::LinkModules(Module *Dest, Module *Src, unsigned Mode,
return false;
}
+
+//===----------------------------------------------------------------------===//
+// C API.
+//===----------------------------------------------------------------------===//
+
+LLVMBool LLVMLinkModules(LLVMModuleRef Dest, LLVMModuleRef Src,
+ LLVMLinkerMode Mode, char **OutMessages) {
+ std::string Messages;
+ LLVMBool Result = Linker::LinkModules(unwrap(Dest), unwrap(Src),
+ Mode, OutMessages? &Messages : 0);
+ if (OutMessages)
+ *OutMessages = strdup(Messages.c_str());
+ return Result;
+}