klee/0010-llvm50-avoid-on-function-arg_begin.patch

51 lines
1.8 KiB
Diff

From: Jiri Slaby <jirislaby@gmail.com>
Date: Mon, 15 Jan 2018 10:35:19 +0100
Subject: llvm50: avoid ++ on function->arg_begin()
Patch-mainline: no
Starting with llvm 5, arguments of a function are not an iterator, but
an array. So they cannot be incremented in-place. Use +1 to construct a
new one instead.
Otherwise we see:
../tools/klee/main.cpp:661:23: error: expression is not assignable
Value *oldArgv = &*(++mainFn->arg_begin());
^ ~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
tools/klee/main.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index c7dc517a8eee..883be83a4130 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -655,7 +655,11 @@ static void initEnv(Module *mainModule) {
Instruction *firstInst = &*(mainFn->begin()->begin());
Value *oldArgc = &*(mainFn->arg_begin());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
+ Value *oldArgv = &*(mainFn->arg_begin() + 1);
+#else
Value *oldArgv = &*(++mainFn->arg_begin());
+#endif
AllocaInst* argcPtr =
new AllocaInst(oldArgc->getType(), "argcPtr", firstInst);
@@ -1057,7 +1061,11 @@ createLibCWrapper(std::vector<std::unique_ptr<llvm::Module>> &modules,
args.push_back(
llvm::ConstantExpr::getBitCast(inModuleRefernce, ft->getParamType(0)));
args.push_back(&*(stub->arg_begin())); // argc
+#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
+ args.push_back(&*(stub->arg_begin() + 1)); // argv
+#else
args.push_back(&*(++stub->arg_begin())); // argv
+#endif
args.push_back(Constant::getNullValue(ft->getParamType(3))); // app_init
args.push_back(Constant::getNullValue(ft->getParamType(4))); // app_fini
args.push_back(Constant::getNullValue(ft->getParamType(5))); // rtld_fini
--
2.18.0