diff options
author | Julian Büning <julian.buening@rwth-aachen.de> | 2018-06-29 18:34:11 +0200 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2018-07-23 13:46:59 +0100 |
commit | 9358aa95f9ae94cbb4e1a9f638e953e0164da86c (patch) | |
tree | c8c0f9eeed281e504653ca480aabe4e2d368ad74 /lib/Module | |
parent | 29e349142a54f7bee17bd7ac7f81ba6423075bed (diff) | |
download | klee-9358aa95f9ae94cbb4e1a9f638e953e0164da86c.tar.gz |
fix: LLVM 3.5, begin_user() instead of begin_use()
With version 3.5, LLVM introduced a subtle semantic change in the API of `Value`. With that change, `use_begin()` is renamed to `user_begin()`. Additionally, a new method `use_begin()` with a different meaning was introduced. Now, `use_begin()` actually iterates over `Use`s, whereas before, dereferencing it would give a `User *`. For further details, please refer to https://reviews.llvm.org/rL203364. Due to the reintroduction of `use_begin()`, existing code may still compile, although the semantics have changed. In the code changed with this patch, all `dyn_cast`s for `Use` fail and the else branch is always taken.
Diffstat (limited to 'lib/Module')
-rw-r--r-- | lib/Module/ModuleUtil.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 4912ca94..deb5a3e2 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -306,9 +306,13 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { } static bool valueIsOnlyCalled(const Value *v) { - for (Value::const_use_iterator it = v->use_begin(), ie = v->use_end(); - it != ie; ++it) { - if (const Instruction *instr = dyn_cast<Instruction>(*it)) { +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5) + for (auto it = v->use_begin(), ie = v->use_end(); it != ie; ++it) { + auto user = *it; +#else + for (auto user : v->users()) { +#endif + if (const Instruction *instr = dyn_cast<Instruction>(user)) { if (instr->getOpcode()==0) continue; // XXX function numbering inst // Make sure the instruction is a call or invoke. @@ -320,12 +324,12 @@ static bool valueIsOnlyCalled(const Value *v) { if (cs.hasArgument(v)) return false; } else if (const llvm::ConstantExpr *ce = - dyn_cast<llvm::ConstantExpr>(*it)) { + dyn_cast<llvm::ConstantExpr>(user)) { if (ce->getOpcode()==Instruction::BitCast) if (valueIsOnlyCalled(ce)) continue; return false; - } else if (const GlobalAlias *ga = dyn_cast<GlobalAlias>(*it)) { + } else if (const GlobalAlias *ga = dyn_cast<GlobalAlias>(user)) { // XXX what about v is bitcast of aliasee? if (v==ga->getAliasee() && !valueIsOnlyCalled(ga)) return false; |