From a566130825489cd69a96b90f6fba2d45a65e0cc8 Mon Sep 17 00:00:00 2001 From: Alessandro Di Federico Date: Mon, 23 Apr 2018 08:45:05 +0200 Subject: [PATCH] Outline lambdas --- jumptargetmanager.cpp | 26 +++++++++++++------------- reachingdefinitions.cpp | 7 ++++--- variablemanager.cpp | 9 +++++---- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/jumptargetmanager.cpp b/jumptargetmanager.cpp index d49ee9c8b..9f782b896 100644 --- a/jumptargetmanager.cpp +++ b/jumptargetmanager.cpp @@ -647,22 +647,22 @@ void JumpTargetManager::registerInstruction(uint64_t PC, CallInst *JumpTargetManager::findNextExitTB(Instruction *Start) { CallInst *Result = nullptr; - visitSuccessors(Start, - make_blacklist(*this), - [this,&Result] (BasicBlockRange Range) { - for (Instruction &I : Range) { - if (auto *Call = dyn_cast(&I)) { - assert(!(Call->getCalledFunction()->getName() == "newpc")); - if (Call->getCalledFunction() == ExitTB) { - assert(Result == nullptr); - Result = Call; - return ExhaustQueueAndStop; - } + auto Visitor = [this, &Result](BasicBlockRange Range) { + for (Instruction &I : Range) { + if (auto *Call = dyn_cast(&I)) { + assert( + !(Call->getCalledFunction()->getName() == "newpc")); + if (Call->getCalledFunction() == ExitTB) { + assert(Result == nullptr); + Result = Call; + return ExhaustQueueAndStop; } } + } - return Continue; - }); + return Continue; + }; + visitSuccessors(Start, make_blacklist(*this), Visitor); return Result; } diff --git a/reachingdefinitions.cpp b/reachingdefinitions.cpp index 2b6e9389d..d53828111 100644 --- a/reachingdefinitions.cpp +++ b/reachingdefinitions.cpp @@ -620,9 +620,10 @@ void BasicBlockInfo::dump(std::ostream &Output) { void BasicBlockInfo::newDefinition(StoreInst *Store, TypeSizeProvider &TSP) { // Remove all the aliased reaching definitions MemoryAccess TargetMA(Store, TSP); - removeDefinitions([&TargetMA] (MemoryInstruction &MI) { - return TargetMA.mayAlias(MI.MA); - }); + auto Match = [&TargetMA](MemoryInstruction &MI) { + return TargetMA.mayAlias(MI.MA); + }; + removeDefinitions(Match); // Add this definition Definitions.push_back(MemoryInstruction(Store, TSP)); diff --git a/variablemanager.cpp b/variablemanager.cpp index 51429c7d1..4715fc0c6 100644 --- a/variablemanager.cpp +++ b/variablemanager.cpp @@ -215,12 +215,13 @@ VariableManager::VariableManager(Module& TheModule, assert(EnvElection.size() > 0); + auto Compare = [] (ElectionMapElement& It1, + ElectionMapElement& It2) { + return It1.second < It2.second; + }; CPUStateType = std::max_element(EnvElection.begin(), EnvElection.end(), - [] (ElectionMapElement& It1, - ElectionMapElement& It2) { - return It1.second < It2.second; - })->first; + Compare)->first; // Look for structures containing CPUStateType as a member and promove them // to CPUStateType. Basically this is a flexible way to keep track of the *CPU