about summary refs log tree commit diff homepage
path: root/lib/Module
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2018-01-15 10:42:53 +0100
committerMartinNowack <martin.nowack@gmail.com>2018-10-26 13:31:07 +0100
commit85b2324dd54e63c49ce4936e6b6b0d4d6535fc05 (patch)
treee4dd68fefe0eb132b670805e39ee4b042d16181a /lib/Module
parent25f2ad1db36ed63acd08afa6bda60446c0fcf11d (diff)
downloadklee-85b2324dd54e63c49ce4936e6b6b0d4d6535fc05.tar.gz
llvm5: handle new file_magic's location
llvm 5, moved file_magic to BinaryFormat in commit
19ca2b0f9daed883c21730285d7f04424e5f5f88, so adapt to that.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/ModuleUtil.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index f903fbfe..399e5577 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -13,6 +13,9 @@
 #include "klee/Internal/Support/Debug.h"
 #include "klee/Internal/Support/ErrorHandling.h"
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
+#include "llvm/BinaryFormat/Magic.h"
+#endif
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
@@ -380,13 +383,19 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
   MemoryBuffer *Buffer = bufferErr->get();
 #endif
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
+  file_magic magic = identify_magic(Buffer.getBuffer());
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
   sys::fs::file_magic magic = sys::fs::identify_magic(Buffer.getBuffer());
 #else
   sys::fs::file_magic magic = sys::fs::identify_magic(Buffer->getBuffer());
 #endif
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
+  if (magic == file_magic::bitcode) {
+#else
   if (magic == sys::fs::file_magic::bitcode) {
+#endif
     SMDiagnostic Err;
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
     std::unique_ptr<llvm::Module> module(parseIR(Buffer, Err, context));
@@ -403,7 +412,11 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
     return true;
   }
 
+#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
+  if (magic == file_magic::archive) {
+#else
   if (magic == sys::fs::file_magic::archive) {
+#endif
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
     Expected<std::unique_ptr<object::Binary> > archOwner =
       object::createBinary(Buffer, &context);