From 3983b23eac93b0e6f28ffba4b626401c5280c10f Mon Sep 17 00:00:00 2001 From: Lukas Zaoral Date: Sat, 12 Sep 2020 11:02:29 +0200 Subject: Replace llvm::CallSite with llvm::CallBase on LLVM 8+ This is in preparation for LLVM 11 as the llvm:CallSite class has been removed. --- lib/Module/ModuleUtil.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'lib/Module/ModuleUtil.cpp') diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index f369258a..bce6de97 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -251,7 +251,13 @@ klee::linkModules(std::vector> &modules, return composite; } -Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { +Function *klee::getDirectCallTarget( +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + const CallBase &cs, +#else + const CallSite &cs, +#endif + bool moduleIsFullyLinked) { Value *v = cs.getCalledValue(); bool viaConstantExpr = false; // Walk through aliases and bitcasts to try to find @@ -287,11 +293,16 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { static bool valueIsOnlyCalled(const Value *v) { for (auto user : v->users()) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0) + // Make sure the instruction is a call or invoke. + if (const auto *cs_ptr = dyn_cast(user)) { + const CallBase &cs = *cs_ptr; +#else if (const auto *instr = dyn_cast(user)) { // Make sure the instruction is a call or invoke. - CallSite cs(const_cast(instr)); + const CallSite cs(const_cast(instr)); if (!cs) return false; - +#endif // Make sure that the value is only the target of this call and // not an argument. if (cs.hasArgument(v)) -- cgit 1.4.1