From d63f589a3fda3c6d69c730596be194c3485a5801 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 20 Feb 2015 17:29:13 +0100 Subject: [PATCH] Remove unused LLVMBasicBlock class --- src/core/BasicBlock.hxx | 12 ++++++++++-- src/disassembler/llvm/LLVMBasicBlock.hxx | 22 ---------------------- src/disassembler/llvm/LLVMDisassembler.cxx | 12 ++++++------ src/disassembler/llvm/LLVMDisassembler.hxx | 3 +-- 4 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 src/disassembler/llvm/LLVMBasicBlock.hxx diff --git a/src/core/BasicBlock.hxx b/src/core/BasicBlock.hxx index b3e5a89..0a759bf 100644 --- a/src/core/BasicBlock.hxx +++ b/src/core/BasicBlock.hxx @@ -5,9 +5,13 @@ #include #include +class Disassembler; + class BasicBlock { public: - BasicBlock() { + BasicBlock(uint64_t start_address, Disassembler * disassembler) + : start_address(start_address) + , disassembler(disassembler) { next_blocks[0] = 0; next_blocks[1] = 0; } @@ -44,10 +48,14 @@ public: return s.str(); } + Disassembler * getDisassembler() { + return disassembler; + } + private: uint64_t start_address; uint64_t end_address; - + Disassembler* disassembler; uint64_t next_blocks[2]; }; diff --git a/src/disassembler/llvm/LLVMBasicBlock.hxx b/src/disassembler/llvm/LLVMBasicBlock.hxx deleted file mode 100644 index 15826aa..0000000 --- a/src/disassembler/llvm/LLVMBasicBlock.hxx +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef INCLUDE__LLVMBasicBlock_hxx -#define INCLUDE__LLVMBasicBlock_hxx - -#include "core/BasicBlock.hxx" - -class Disassembler; - -class LLVMBasicBlock : public BasicBlock { -public: - LLVMBasicBlock(uint64_t start_address, Disassembler * disassembler) { - setStartAddress(start_address); - } - - Disassembler * getDisassembler() { - return disassembler; - } - -private: - Disassembler * disassembler; -}; - -#endif diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index fbbbc94..1d4f2df 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -1,7 +1,7 @@ #include "disassembler/llvm/LLVMDisassembler.hxx" -#include "disassembler/llvm/LLVMBasicBlock.hxx" #include "core/InformationManager.hxx" #include "core/Function.hxx" +#include "core/BasicBlock.hxx" #include #include @@ -205,7 +205,7 @@ Function* LLVMDisassembler::disassembleFunctionAt(uint64_t address, const template void LLVMDisassembler::disassembleFunction(Function* function) { - std::stack remaining_blocks; + std::stack remaining_blocks; SectionRef text_section = sections[".text"]; StringRef bytes; text_section.getContents(bytes); @@ -213,13 +213,13 @@ void LLVMDisassembler::disassembleFunction(Function* function) { LOG4CXX_DEBUG(logger, "Handling function " << function->getName()); - LLVMBasicBlock * block = new LLVMBasicBlock(function->getStartAddress(), this); + BasicBlock * block = new BasicBlock(function->getStartAddress(), this); remaining_blocks.push(block); blocks.insert(std::make_pair(block->getStartAddress(), block)); function->addBasicBlock(block); while (remaining_blocks.size()) { - LLVMBasicBlock * current_block = remaining_blocks.top(); + BasicBlock * current_block = remaining_blocks.top(); remaining_blocks.pop(); LOG4CXX_DEBUG(logger, "Handling Block starting at " << std::hex << current_block->getStartAddress()); @@ -247,7 +247,7 @@ void LLVMDisassembler::disassembleFunction(Function* function) { } else { current_block->setNextBlock(0, jmptarget); if (blocks.find(jmptarget) == blocks.end()) { - LLVMBasicBlock * block = new LLVMBasicBlock(jmptarget, this); + BasicBlock * block = new BasicBlock(jmptarget, this); blocks.insert(std::make_pair(block->getStartAddress(), block)); function->addBasicBlock(block); remaining_blocks.push(block); @@ -259,7 +259,7 @@ void LLVMDisassembler::disassembleFunction(Function* function) { jmptarget = base_address + current_address + inst_size; current_block->setNextBlock(1, jmptarget); if (blocks.find(jmptarget) == blocks.end()) { - LLVMBasicBlock * block = new LLVMBasicBlock(jmptarget, this); + BasicBlock * block = new BasicBlock(jmptarget, this); blocks.insert(std::make_pair(block->getStartAddress(), block)); function->addBasicBlock(block); remaining_blocks.push(block); diff --git a/src/disassembler/llvm/LLVMDisassembler.hxx b/src/disassembler/llvm/LLVMDisassembler.hxx index 2713ac6..426cc89 100644 --- a/src/disassembler/llvm/LLVMDisassembler.hxx +++ b/src/disassembler/llvm/LLVMDisassembler.hxx @@ -11,7 +11,6 @@ class Function; class BasicBlock; -class LLVMBasicBlock; Disassembler * createLLVMDisassembler(const std::string& filename, InformationManager* manager); @@ -55,7 +54,7 @@ private: void readDynamicSymbols(); log4cxx::LoggerPtr logger; - std::map blocks; + std::map blocks; std::map functions; llvm::Triple triple; -- 2.39.5