diff options
author | Andrea Mattavelli <andreamattavelli@users.noreply.github.com> | 2017-07-18 17:39:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-18 17:39:21 +0100 |
commit | 5e4f0b7c79d57b9a9908f6293a5936fa54e511e9 (patch) | |
tree | 8429e4cb0c60bec43621c4971626fea397ea108f /lib/Core | |
parent | 64f367ea9db4739b70414cba002bf25d28db6242 (diff) | |
parent | c9c90a0ecdce10172fd5318aea60a9ff4057679f (diff) | |
download | klee-5e4f0b7c79d57b9a9908f6293a5936fa54e511e9.tar.gz |
Merge pull request #672 from jirislaby/llvm40_static_casts
llvm: get rid of static_casts from iterators
Diffstat (limited to 'lib/Core')
-rw-r--r-- | lib/Core/Executor.cpp | 11 | ||||
-rw-r--r-- | lib/Core/StatsTracker.cpp | 21 |
2 files changed, 15 insertions, 17 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index c087b79b..dc2bca4e 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -546,7 +546,7 @@ void Executor::initializeGlobals(ExecutionState &state) { // ensures that we won't conflict. we don't need to allocate a memory object // since reading/writing via a function pointer is unsupported anyway. for (Module::iterator i = m->begin(), ie = m->end(); i != ie; ++i) { - Function *f = static_cast<Function *>(i); + Function *f = &*i; ref<ConstantExpr> addr(0); // If the symbol has external weak linkage then it is implicitly @@ -600,7 +600,7 @@ void Executor::initializeGlobals(ExecutionState &state) { for (Module::const_global_iterator i = m->global_begin(), e = m->global_end(); i != e; ++i) { - const GlobalVariable *v = static_cast<const GlobalVariable *>(i); + const GlobalVariable *v = &*i; size_t globalObjectAlignment = getAllocationAlignment(v); if (i->isDeclaration()) { // FIXME: We have no general way of handling unknown external @@ -678,8 +678,7 @@ void Executor::initializeGlobals(ExecutionState &state) { i != ie; ++i) { // Map the alias to its aliasee's address. This works because we have // addresses for everything, even undefined functions. - globalAddresses.insert(std::make_pair(static_cast<GlobalAlias *>(i), - evalConstant(i->getAliasee()))); + globalAddresses.insert(std::make_pair(&*i, evalConstant(i->getAliasee()))); } // once all objects are allocated, do the actual initialization @@ -687,7 +686,7 @@ void Executor::initializeGlobals(ExecutionState &state) { e = m->global_end(); i != e; ++i) { if (i->hasInitializer()) { - const GlobalVariable *v = static_cast<const GlobalVariable *>(i); + const GlobalVariable *v = &*i; MemoryObject *mo = globalObjects.find(v)->second; const ObjectState *os = state.addressSpace.findObject(mo); assert(os); @@ -3555,7 +3554,7 @@ void Executor::runFunctionAsMain(Function *f, if (ai!=ae) { arguments.push_back(ConstantExpr::alloc(argc, Expr::Int32)); if (++ai!=ae) { - Instruction *first = static_cast<Instruction *>(f->begin()->begin()); + Instruction *first = &*(f->begin()->begin()); argvMO = memory->allocate((argc + 1 + envc + 1 + 1) * NumPtrBytes, /*isLocal=*/false, /*isGlobal=*/true, 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<Instruction *>(--it); + Instruction *prev = &*(--it); if (isa<CallInst>(prev) || isa<InvokeInst>(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<Function *>(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<Instruction*> 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<Instruction *>(it->begin())); + res.push_back(&*(it->begin())); } else { - res.push_back(static_cast<Instruction *>(++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<Instruction *>(it); + Instruction *inst = &*it; if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) { CallSite cs(inst); if (isa<InlineAsm>(cs.getCalledValue())) { @@ -721,7 +721,7 @@ void StatsTracker::computeReachableUncovered() { std::vector<Instruction *> instructions; for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); fnIt != fn_ie; ++fnIt) { - Function *fn = static_cast<Function *>(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<Instruction *>(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<Instruction *>(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<Instruction *>(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<Instruction *>(it); + Instruction *inst = &*it; unsigned id = infos.getInfo(inst).id; instructions.push_back(inst); sm.setIndexedValue(stats::minDistToUncovered, |