From c9c90a0ecdce10172fd5318aea60a9ff4057679f Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Wed, 7 Jun 2017 14:30:54 +0200 Subject: llvm: get rid of static_casts from iterators In commit b7a6aec4eeb4 (convert iterators using static_cast), I switched all implicit casts to static_cast. It turned out that llvm 4.0 banned casting via static_cast. See e.g. 1e2bc42eb988 in the llvm repo what they do. So similarly to the above commit, change all the casts of iterators to "&*" which is what they do in LLVM. Signed-off-by: Jiri Slaby --- lib/Core/StatsTracker.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lib/Core/StatsTracker.cpp') diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index b93796ec..addb3de6 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -165,7 +165,7 @@ static bool instructionIsCoverable(Instruction *i) { if (it==bb->begin()) { return true; } else { - Instruction *prev = static_cast(--it); + Instruction *prev = &*(--it); if (isa(prev) || isa(prev)) { Function *target = getDirectCallTarget(CallSite(prev), /*moduleIsFullyLinked=*/true); @@ -542,7 +542,7 @@ void StatsTracker::writeIStats() { // Always try to write the filename before the function name, as otherwise // KCachegrind can create two entries for the function, one with an // unnamed file and one without. - Function *fn = static_cast(fnIt); + Function *fn = &*fnIt; const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fn); if (ii.file != sourceFile) { of << "fl=" << ii.file << "\n"; @@ -639,9 +639,9 @@ static std::vector getSuccs(Instruction *i) { if (i==bb->getTerminator()) { for (succ_iterator it = succ_begin(bb), ie = succ_end(bb); it != ie; ++it) - res.push_back(static_cast(it->begin())); + res.push_back(&*(it->begin())); } else { - res.push_back(static_cast(++BasicBlock::iterator(i))); + res.push_back(&*(++BasicBlock::iterator(i))); } return res; @@ -688,7 +688,7 @@ void StatsTracker::computeReachableUncovered() { bbIt != bb_ie; ++bbIt) { for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { - Instruction *inst = static_cast(it); + Instruction *inst = &*it; if (isa(inst) || isa(inst)) { CallSite cs(inst); if (isa(cs.getCalledValue())) { @@ -721,7 +721,7 @@ void StatsTracker::computeReachableUncovered() { std::vector instructions; for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); fnIt != fn_ie; ++fnIt) { - Function *fn = static_cast(fnIt); + Function *fn = &*fnIt; if (fnIt->isDeclaration()) { if (fnIt->doesNotReturn()) { functionShortestPath[fn] = 0; @@ -737,7 +737,7 @@ void StatsTracker::computeReachableUncovered() { bbIt != bb_ie; ++bbIt) { for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { - Instruction *inst = static_cast(it); + Instruction *inst = &*it; instructions.push_back(inst); unsigned id = infos.getInfo(inst).id; sm.setIndexedValue(stats::minDistToReturn, @@ -796,14 +796,13 @@ void StatsTracker::computeReachableUncovered() { // functionShortestPath, or it will remain 0 (erroneously indicating // that no return instructions are reachable) Function *f = inst->getParent()->getParent(); - if (best != cur - || (inst == static_cast(f->begin()->begin()) + if (best != cur || (inst == &*(f->begin()->begin()) && functionShortestPath[f] != best)) { sm.setIndexedValue(stats::minDistToReturn, id, best); changed = true; // Update shortest path if this is the entry point. - if (inst == static_cast(f->begin()->begin())) + if (inst == &*(f->begin()->begin())) functionShortestPath[f] = best; } } @@ -820,7 +819,7 @@ void StatsTracker::computeReachableUncovered() { bbIt != bb_ie; ++bbIt) { for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { - Instruction *inst = static_cast(it); + Instruction *inst = &*it; unsigned id = infos.getInfo(inst).id; instructions.push_back(inst); sm.setIndexedValue(stats::minDistToUncovered, -- cgit 1.4.1