summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/Bitcode/Reader
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-02-14 14:13:00 +0000
committerdim <dim@FreeBSD.org>2015-02-14 14:13:00 +0000
commit9377b5ad0feb5dd018ed6cfc6378ac19c1252dfe (patch)
treea7bc5b362ad6182396e88b223352f75d52966813 /contrib/llvm/lib/Bitcode/Reader
parentff34755926ad8a77e4498e82a23c847d33c6c72d (diff)
downloadFreeBSD-src-9377b5ad0feb5dd018ed6cfc6378ac19c1252dfe.zip
FreeBSD-src-9377b5ad0feb5dd018ed6cfc6378ac19c1252dfe.tar.gz
Merge llvm 3.6.0rc3 from ^/vendor/llvm/dist, merge clang 3.6.0rc3 from
^/vendor/clang/dist, resolve conflicts, and update patches README.
Diffstat (limited to 'contrib/llvm/lib/Bitcode/Reader')
-rw-r--r--contrib/llvm/lib/Bitcode/Reader/BitReader.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/contrib/llvm/lib/Bitcode/Reader/BitReader.cpp b/contrib/llvm/lib/Bitcode/Reader/BitReader.cpp
index 9b3acb5..868fbf0 100644
--- a/contrib/llvm/lib/Bitcode/Reader/BitReader.cpp
+++ b/contrib/llvm/lib/Bitcode/Reader/BitReader.cpp
@@ -9,9 +9,11 @@
#include "llvm-c/BitReader.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
#include <cstring>
#include <string>
@@ -30,11 +32,20 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,
LLVMMemoryBufferRef MemBuf,
LLVMModuleRef *OutModule,
char **OutMessage) {
- ErrorOr<Module *> ModuleOrErr =
- parseBitcodeFile(unwrap(MemBuf)->getMemBufferRef(), *unwrap(ContextRef));
- if (std::error_code EC = ModuleOrErr.getError()) {
- if (OutMessage)
- *OutMessage = strdup(EC.message().c_str());
+ MemoryBufferRef Buf = unwrap(MemBuf)->getMemBufferRef();
+ LLVMContext &Ctx = *unwrap(ContextRef);
+
+ std::string Message;
+ raw_string_ostream Stream(Message);
+ DiagnosticPrinterRawOStream DP(Stream);
+
+ ErrorOr<Module *> ModuleOrErr = parseBitcodeFile(
+ Buf, Ctx, [&](const DiagnosticInfo &DI) { DI.print(DP); });
+ if (ModuleOrErr.getError()) {
+ if (OutMessage) {
+ Stream.flush();
+ *OutMessage = strdup(Message.c_str());
+ }
*OutModule = wrap((Module*)nullptr);
return 1;
}
OpenPOWER on IntegriCloud