diff --git a/src/CFGraph/IR_SSAForm.cpp b/src/CFGraph/IR_SSAForm.cpp index e22f044..987aa92 100644 --- a/src/CFGraph/IR_SSAForm.cpp +++ b/src/CFGraph/IR_SSAForm.cpp @@ -124,7 +124,7 @@ static vector* getCommonElements(const vector>* vectors) } -static map> findDominators(vector blocks) +static map> findDominators(const vector& blocks) { map> result; @@ -133,7 +133,7 @@ static map> findDominators(vector blocks) { changed = false; - for (auto currentBlock : blocks) + for (auto& currentBlock : blocks) { auto pred = currentBlock->getPrev(); auto prevDominators = new vector>(); @@ -166,7 +166,7 @@ static void renumberBlocks(BBlock* current, int* n, map* res, setgetInstructions()[0]->getInstruction()->getOperator()->lineNumber() > b->getInstructions()[0]->getInstruction()->getOperator()->lineNumber(); }); - for (auto i : nextBlocks) + for (auto& i : nextBlocks) renumberBlocks(i, n, res, visited); (*res)[current->getNumber()] = *n; @@ -214,7 +214,7 @@ static BBlock* findImmediateDominatorsDfsHelper(BBlock* block, BBlock* currentBl if (find(dominators[block].begin(), dominators[block].end(), currentBlock) != dominators[block].end()) currentImmediateDominator = currentBlock; - for (auto nextBlock : currentBlock->getNext()) + for (auto& nextBlock : currentBlock->getNext()) { auto result = findImmediateDominatorsDfsHelper(block, nextBlock, currentImmediateDominator, visited, dominators); @@ -239,13 +239,13 @@ static map findImmediateDominators1(const map blocks, set& counter, map& counter, map>& stack) { - for (auto irBlock : block->getInstructions()) + for (auto& irBlock : block->getInstructions()) { auto instruction = irBlock->getInstruction(); if (instruction->getOperation() == CFG_OP::F_CALL && instruction->getArg1() != NULL && @@ -463,7 +463,7 @@ static void renameFiFunctionResultVar(BBlock* block, map& counter, static void renameInstructionVars(BBlock* block, map& counter, map>& stack) { - for (auto irBlock : block->getInstructions()) + for (auto& irBlock : block->getInstructions()) { auto instruction = irBlock->getInstruction(); @@ -483,7 +483,7 @@ static void renameFiFunctionArgsVar(BBlock* block, map auto size = block->getInstructions().size(); auto& instructions = block->getInstructions(); - for (auto i = 0; i < size; i++) + for (size_t i = 0; i < size; ++i) { auto irBlock = instructions[i]; auto instruction = irBlock->getInstruction(); @@ -518,9 +518,8 @@ static vector findBlocksWithValue(map& iDominators, B vector result; // Проходим по всем элементам map - for (auto& pair : iDominators) - // Если значение равно x, добавляем ключ в результат - if (pair.second == x) + for (auto& pair : iDominators) + if (pair.second == x) // Если значение равно x, добавляем ключ в результат result.push_back(pair.first); return result; @@ -531,10 +530,10 @@ static void renameIR(BBlock* block, map& iDominators, mapgetNext()) + for (auto& successor : block->getNext()) renameFiFunctionArgsVar(successor, stack); - for (auto* child : findBlocksWithValue(iDominators, block)) + for (auto& child : findBlocksWithValue(iDominators, block)) renameIR(child, iDominators, counter, stack); for (auto& irBlock : block->getInstructions()) @@ -567,12 +566,12 @@ void buildIRSSAForm(const map>& fullIR, vector funcIR; - for (auto i : funcIRConst) + for (auto& i : funcIRConst) funcIR.push_back(new BBlock(*i)); restoreConnections(funcIRConst, funcIR); - for (auto i : funcIR) { + for (auto& i : funcIR) { //printBlock(i); } auto dominators = findDominators(funcIR); @@ -631,7 +630,7 @@ void buildIRSSAForm(const map>& fullIR, map count; map> varStack; - for (auto var : globals) + for (auto& var : globals) { count[var->getValue()] = 0; @@ -643,7 +642,7 @@ void buildIRSSAForm(const map>& fullIR, renameIR(funcIR[0], iDominators, count, varStack); - for (auto i : funcIR) { + for (auto& i : funcIR) { //printBlock(i); } //cout << endl << endl << endl << endl << endl;