about summary refs log tree commit diff homepage
path: root/include
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2017-06-14 14:19:39 +0100
committerDan Liew <delcypher@gmail.com>2017-06-16 15:44:25 +0100
commit7c4fdd012317eb92352fc7ded53a553ed762719f (patch)
tree3457164f5b5199149588679f818a3a991a3d0420 /include
parentc5059debfd910edabcbc2fc847d21c9e50c5afe1 (diff)
downloadklee-7c4fdd012317eb92352fc7ded53a553ed762719f.tar.gz
move module loading into external function
- having an explicit function which is defined for multiple llvm
  versions separately increases readability.
- also: error handling was simplified
- Personal motivation: being able to use this functionality in unit tests

fixes #561
related to #656
Diffstat (limited to 'include')
-rw-r--r--include/klee/Internal/Support/ModuleUtil.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/include/klee/Internal/Support/ModuleUtil.h b/include/klee/Internal/Support/ModuleUtil.h
index c85ba591..78998051 100644
--- a/include/klee/Internal/Support/ModuleUtil.h
+++ b/include/klee/Internal/Support/ModuleUtil.h
@@ -7,22 +7,37 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef KLEE_TRANSFORM_UTIL_H
-#define KLEE_TRANSFORM_UTIL_H
+#ifndef KLEE_MODULE_UTIL_H
+#define KLEE_MODULE_UTIL_H
+
+#include "klee/Config/Version.h"
+
+#if LLVM_VERSION_CODE > LLVM_VERSION(3, 2)
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#else
+#include "llvm/Module.h"
+#include "llvm/Function.h"
+#include "llvm/LLVMContext.h"
+#endif
 
-#include <string>
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#include "llvm/IR/CallSite.h"
+#else
+#include "llvm/Support/CallSite.h"
+#endif
 
-namespace llvm {
-  class Function;
-  class Instruction;
-  class Module; 
-  class CallSite; 
-}
+#include <string>
 
 namespace klee {
- 
+  /// Load llvm module from a bitcode archive file.
+  llvm::Module *loadModule(llvm::LLVMContext &ctx,
+                           const std::string &path,
+                           std::string &errorMsg);
+
   /// Link a module with a specified bitcode archive.
-  llvm::Module *linkWithLibrary(llvm::Module *module, 
+  llvm::Module *linkWithLibrary(llvm::Module *module,
                                 const std::string &libraryName);
 
   /// Return the Function* target of a Call or Invoke instruction, or