Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
ceeac committed Nov 22, 2019
1 parent e5980ee commit 677035d
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ IRFragment *StringInstructionProcessor::splitForBranch(IRFragment *bb, RTL *stri
const bool entryBBNeedsUpdate = !haveA && bb == m_proc->getCFG()->getEntryBB();
m_proc->getCFG()->removeFragment(bb);

IRFragment *skipBB = nullptr; // m_proc->getCFG()->createBB(BBType::Twoway, std::move(skipBBRTLs));
IRFragment *rptBB = nullptr; // m_proc->getCFG()->createBB(BBType::Twoway, std::move(rptBBRTLs));
IRFragment
*skipBB = nullptr; // m_proc->getCFG()->createBB(BBType::Twoway, std::move(skipBBRTLs));
IRFragment
*rptBB = nullptr; // m_proc->getCFG()->createBB(BBType::Twoway, std::move(rptBBRTLs));

assert(skipBB && rptBB);

Expand Down
3 changes: 1 addition & 2 deletions src/boomerang/db/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void BasicBlock::completeBB(const std::vector<MachineInstruction> &insns)

m_insns = insns;

m_lowAddr = m_insns.front().m_addr;
m_lowAddr = m_insns.front().m_addr;
m_highAddr = m_insns.back().m_addr + m_insns.back().m_size;
}

Expand Down Expand Up @@ -106,4 +106,3 @@ void BasicBlock::print(OStream &os) const

os << "\n";
}

4 changes: 2 additions & 2 deletions src/boomerang/db/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class BOOMERANG_API BasicBlock : public GraphNode<BasicBlock>
inline Function *getFunction() { return m_function; }

inline Address getLowAddr() const { return m_lowAddr; }
inline Address getHiAddr() const { return m_highAddr; }
inline Address getHiAddr() const { return m_highAddr; }

inline bool isComplete() const { return !m_insns.empty(); }

Expand Down Expand Up @@ -125,7 +125,7 @@ class BOOMERANG_API BasicBlock : public GraphNode<BasicBlock>
/// The function this BB is part of, or nullptr if this BB is not part of a function.
Function *m_function = nullptr;

Address m_lowAddr = Address::ZERO;
Address m_lowAddr = Address::ZERO;
Address m_highAddr = Address::INVALID;

BBType m_bbType = BBType::Invalid; ///< type of basic block
Expand Down
43 changes: 19 additions & 24 deletions src/boomerang/db/IRFragment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
#pragma endregion License
#include "IRFragment.h"


#include "boomerang/db/proc/UserProc.h"
#include "boomerang/ssl/statements/ImplicitAssign.h"
#include "boomerang/ssl/statements/PhiAssign.h"
#include "boomerang/ssl/statements/CallStatement.h"
#include "boomerang/ssl/exp/Const.h"
#include "boomerang/ssl/statements/BranchStatement.h"
#include "boomerang/ssl/statements/CallStatement.h"
#include "boomerang/ssl/statements/CaseStatement.h"
#include "boomerang/ssl/exp/Const.h"
#include "boomerang/ssl/statements/ImplicitAssign.h"
#include "boomerang/ssl/statements/PhiAssign.h"
#include "boomerang/util/log/Log.h"


Expand All @@ -42,8 +41,8 @@ IRFragment::IRFragment(const IRFragment &other)

IRFragment &IRFragment::operator=(const IRFragment &other)
{
m_bb = other.m_bb;
m_lowAddr = other.m_lowAddr;
m_bb = other.m_bb;
m_lowAddr = other.m_lowAddr;
m_highAddr = other.m_highAddr;

if (other.m_listOfRTLs) {
Expand Down Expand Up @@ -88,7 +87,6 @@ const Function *IRFragment::getFunction() const
}



RTL *IRFragment::getLastRTL()
{
return m_listOfRTLs ? m_listOfRTLs->back().get() : nullptr;
Expand Down Expand Up @@ -281,7 +279,7 @@ std::shared_ptr<ImplicitAssign> IRFragment::addImplicitAssign(const SharedExp &l

// do not allow BB with 2 zero address RTLs
assert(m_listOfRTLs->size() < 2 ||
(*std::next(m_listOfRTLs->begin()))->getAddress() != Address::ZERO);
(*std::next(m_listOfRTLs->begin()))->getAddress() != Address::ZERO);

for (const SharedStmt &s : *m_listOfRTLs->front()) {
if (s->isPhi() && *s->as<PhiAssign>()->getLeft() == *lhs) {
Expand Down Expand Up @@ -315,7 +313,7 @@ std::shared_ptr<PhiAssign> IRFragment::addPhi(const SharedExp &usedExp)

// do not allow BB with 2 zero address RTLs
assert(m_listOfRTLs->size() < 2 ||
(*std::next(m_listOfRTLs->begin()))->getAddress() != Address::ZERO);
(*std::next(m_listOfRTLs->begin()))->getAddress() != Address::ZERO);

for (auto existingIt = m_listOfRTLs->front()->begin();
existingIt != m_listOfRTLs->front()->end();) {
Expand Down Expand Up @@ -355,8 +353,6 @@ void IRFragment::clearPhis()
}




bool IRFragment::hasStatement(const SharedStmt &stmt) const
{
if (!stmt || !m_listOfRTLs) {
Expand All @@ -383,7 +379,7 @@ void IRFragment::removeRTL(RTL *rtl)

RTLList::iterator it = std::find_if(
m_listOfRTLs->begin(), m_listOfRTLs->end(),
[rtl](const std::unique_ptr<RTL> &rtl2) { return rtl == rtl2.get(); });
[rtl](const std::unique_ptr<RTL> &rtl2) { return rtl == rtl2.get(); });

if (it != m_listOfRTLs->end()) {
m_listOfRTLs->erase(it);
Expand Down Expand Up @@ -615,18 +611,18 @@ void IRFragment::simplify()
}


void IRFragment::print(OStream& os) const
void IRFragment::print(OStream &os) const
{
switch (getType()) {
case FragType::Oneway: os << "Oneway BB"; break;
case FragType::Twoway: os << "Twoway BB"; break;
case FragType::Nway: os << "Nway BB"; break;
case FragType::Call: os << "Call BB"; break;
case FragType::Ret: os << "Ret BB"; break;
case FragType::Fall: os << "Fall BB"; break;
case FragType::CompJump: os << "Computed jump BB"; break;
case FragType::CompCall: os << "Computed call BB"; break;
case FragType::Invalid: os << "Invalid BB"; break;
case FragType::Oneway: os << "Oneway BB"; break;
case FragType::Twoway: os << "Twoway BB"; break;
case FragType::Nway: os << "Nway BB"; break;
case FragType::Call: os << "Call BB"; break;
case FragType::Ret: os << "Ret BB"; break;
case FragType::Fall: os << "Fall BB"; break;
case FragType::CompJump: os << "Computed jump BB"; break;
case FragType::CompCall: os << "Computed call BB"; break;
case FragType::Invalid: os << "Invalid BB"; break;
}

os << ":\n";
Expand Down Expand Up @@ -660,4 +656,3 @@ QString IRFragment::toString() const
print(os);
return result;
}

3 changes: 2 additions & 1 deletion src/boomerang/db/IRFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BOOMERANG_API IRFragment : public GraphNode<IRFragment>
IRFragment(BasicBlock *bb, std::unique_ptr<RTLList> rtls);
IRFragment(const IRFragment &);
IRFragment(IRFragment &&) = default;
~IRFragment() = default;
~IRFragment() = default;

IRFragment &operator=(const IRFragment &);
IRFragment &operator=(IRFragment &&) = default;
Expand Down Expand Up @@ -186,6 +186,7 @@ class BOOMERANG_API IRFragment : public GraphNode<IRFragment>
void print(OStream &os) const;

QString toString() const;

public:
BasicBlock *m_bb;
std::unique_ptr<RTLList> m_listOfRTLs = nullptr; ///< Ptr to list of RTLs
Expand Down
4 changes: 2 additions & 2 deletions src/boomerang/db/LowLevelCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ BasicBlock *LowLevelCFG::createBB(BBType bbType, const std::vector<MachineInstru

// If this addr is non zero, check the map to see if we have a (possibly incomplete) BB here
// already If it is zero, this is a special BB for handling delayed branches or the like
bool mustCreateBB = true;
BasicBlock *currentBB = nullptr;
bool mustCreateBB = true;
BasicBlock *currentBB = nullptr;

BBStartMap::iterator mi = m_bbStartMap.find(startAddr);

Expand Down
2 changes: 1 addition & 1 deletion src/boomerang/db/LowLevelCFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class BOOMERANG_API LowLevelCFG
void insertBB(BasicBlock *bb);

private:
Prog *m_prog = nullptr; ///< Procedure to which this CFG belongs.
Prog *m_prog = nullptr; ///< Procedure to which this CFG belongs.
BasicBlock *m_entryBB = nullptr; ///< The BB corresponding to the entry point of the program.
BBStartMap m_bbStartMap; ///< The Address to BB map
};
16 changes: 6 additions & 10 deletions src/boomerang/db/proc/ProcCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool ProcCFG::hasFragment(const IRFragment *frag) const
}


IRFragment *ProcCFG::createFragment(std::unique_ptr<RTLList> rtls, BasicBlock* bb)
IRFragment *ProcCFG::createFragment(std::unique_ptr<RTLList> rtls, BasicBlock *bb)
{
IRFragment *frag = new IRFragment(bb, std::move(rtls));
m_fragmentSet.insert(frag);
Expand All @@ -68,9 +68,7 @@ IRFragment *ProcCFG::createFragment(std::unique_ptr<RTLList> rtls, BasicBlock* b
IRFragment *ProcCFG::splitFragment(IRFragment *frag, Address splitAddr)
{
auto it = std::find_if(frag->getRTLs()->begin(), frag->getRTLs()->end(),
[splitAddr] (const auto &rtl) {
return splitAddr == rtl->getAddress();
});
[splitAddr](const auto &rtl) { return splitAddr == rtl->getAddress(); });

if (it == frag->getRTLs()->end()) {
// cannot split
Expand All @@ -83,8 +81,8 @@ IRFragment *ProcCFG::splitFragment(IRFragment *frag, Address splitAddr)

// move RTLs with addr >= splitAddr to new list
std::unique_ptr<RTLList> newRTLs(new RTLList);
std::for_each(it, frag->getRTLs()->end(), [&newRTLs](std::unique_ptr<RTL> &rtl) {
newRTLs->push_back(std::move(rtl)); });
std::for_each(it, frag->getRTLs()->end(),
[&newRTLs](std::unique_ptr<RTL> &rtl) { newRTLs->push_back(std::move(rtl)); });
frag->getRTLs()->erase(it, frag->getRTLs()->end());

IRFragment *newFrag = createFragment(std::move(newRTLs), frag->getBB());
Expand Down Expand Up @@ -147,9 +145,8 @@ void ProcCFG::removeFragment(IRFragment *frag)

IRFragment *ProcCFG::getFragmentByAddr(Address addr)
{
auto it = std::find_if(m_fragmentSet.begin(), m_fragmentSet.end(), [addr] (IRFragment *frag) {
return frag->getLowAddr() == addr;
});
auto it = std::find_if(m_fragmentSet.begin(), m_fragmentSet.end(),
[addr](IRFragment *frag) { return frag->getLowAddr() == addr; });

return it != m_fragmentSet.end() ? *it : nullptr;
}
Expand Down Expand Up @@ -333,4 +330,3 @@ ProcCFG::FragmentSet::iterator ProcCFG::findFragment(const IRFragment *frag) con

return m_fragmentSet.end();
}

5 changes: 2 additions & 3 deletions src/boomerang/db/proc/ProcCFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#pragma once


#include "boomerang/db/IRFragment.h"
#include "boomerang/frontend/MachineInstruction.h"
#include "boomerang/ssl/exp/ExpHelp.h"
#include "boomerang/ssl/statements/Statement.h"
#include "boomerang/util/Address.h"
#include "boomerang/util/MapIterators.h"
#include "boomerang/db/IRFragment.h"
#include "boomerang/util/Util.h"


#include <list>
#include <map>
#include <memory>
Expand Down Expand Up @@ -163,5 +162,5 @@ class BOOMERANG_API ProcCFG

/// True when the implicits are done; they can cause problems
/// (e.g. with ad-hoc global assignment)
bool m_implicitsDone = false;
bool m_implicitsDone = false;
};
2 changes: 1 addition & 1 deletion src/boomerang/decomp/CFGCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include "CFGCompressor.h"

#include "boomerang/db/BasicBlock.h"
#include "boomerang/db/proc/ProcCFG.h"
#include "boomerang/db/IRFragment.h"
#include "boomerang/db/proc/ProcCFG.h"
#include "boomerang/ssl/RTL.h"
#include "boomerang/ssl/statements/Statement.h"
#include "boomerang/util/log/Log.h"
Expand Down
8 changes: 4 additions & 4 deletions src/boomerang/decomp/IndirectJumpAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "boomerang/core/Project.h"
#include "boomerang/core/Settings.h"
#include "boomerang/db/LowLevelCFG.h"
#include "boomerang/db/Prog.h"
#include "boomerang/db/proc/UserProc.h"
#include "boomerang/db/LowLevelCFG.h"
#include "boomerang/ssl/RTL.h"
#include "boomerang/ssl/exp/Binary.h"
#include "boomerang/ssl/exp/Const.h"
Expand Down Expand Up @@ -376,7 +376,7 @@ void IndirectJumpAnalyzer::processSwitch(IRFragment *bb, UserProc *proc)
}
}
else if (si->switchType == SwitchType::F) {
const int *entry = reinterpret_cast<int *>(si->tableAddr.value());
const int *entry = reinterpret_cast<int *>(si->tableAddr.value());
switchDestination = Address(entry[i]);
}
else if (!image->readNativeAddr4(si->tableAddr + 4 * i, switchDestination)) {
Expand Down Expand Up @@ -867,8 +867,8 @@ bool IndirectJumpAnalyzer::analyzeCompCall(IRFragment *bb, UserProc *proc)

bool IndirectJumpAnalyzer::createCompJumpDest(BasicBlock *sourceBB, int destIdx, Address destAddr)
{
Prog *prog = sourceBB->getFunction()->getProg();
LowLevelCFG *cfg = prog->getCFG();
Prog *prog = sourceBB->getFunction()->getProg();
LowLevelCFG *cfg = prog->getCFG();
const bool canDecode = !cfg->isStartOfBB(destAddr) || cfg->isStartOfIncompleteBB(destAddr);

if (!canDecode) {
Expand Down
Loading

0 comments on commit 677035d

Please sign in to comment.