Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang format #1273

Draft
wants to merge 2 commits into
base: dev-v1.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
BasedOnStyle: Webkit
IndentWidth: 2
Standard: Cpp11
UseTab: Never
TabWidth: 2
MaxEmptyLinesToKeep: 1
ColumnLimit: 120
BreakBeforeBraces: Attach
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
IndentCaseLabels: true
CompactNamespaces: false
NamespaceIndentation: All
AlignOperands: Align
AlignConsecutiveAssignments: AcrossComments
BinPackArguments: false
PointerAlignment: Left
ReferenceAlignment: Left
BreakBeforeBinaryOperators: None
AllowShortCaseLabelsOnASingleLine: true
FixNamespaceComments: true
AlignAfterOpenBracket: Align
AlignTrailingComments: true
IndentPPDirectives: BeforeHash
IndentAccessModifiers: true
...
20 changes: 3 additions & 17 deletions src/libtriton/arch/basicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,32 @@
** This program is under the terms of the Apache License 2.0.
*/

#include <triton/exceptions.hpp>
#include <triton/basicBlock.hpp>


#include <triton/exceptions.hpp>

namespace triton {
namespace arch {

BasicBlock::BasicBlock() {
}


BasicBlock::BasicBlock(const std::vector<triton::arch::Instruction>& instructions) {
this->instructions = instructions;
}


BasicBlock::BasicBlock(const BasicBlock& other) {
this->instructions = other.instructions;
}


BasicBlock& BasicBlock::operator=(const BasicBlock& other) {
this->instructions = other.instructions;
return *this;
}


BasicBlock::~BasicBlock() {
this->instructions.clear();
}


void BasicBlock::add(const Instruction& instruction) {
Instruction copy = instruction;
if (this->instructions.size()) {
Expand All @@ -46,39 +39,33 @@ namespace triton {
this->instructions.push_back(copy);
}


bool BasicBlock::remove(triton::uint32 position) {
if (this->instructions.size() <= position)
return false;
this->instructions.erase(this->instructions.begin() + position);
return true;
}


std::vector<triton::arch::Instruction>& BasicBlock::getInstructions(void) {
return this->instructions;
}


triton::usize BasicBlock::getSize(void) const {
return this->instructions.size();
}


triton::uint64 BasicBlock::getFirstAddress(void) const {
if (this->instructions.size() == 0)
throw triton::exceptions::BasicBlock("BasicBlock::getFirstAddress(): No instruction in the block.");
return this->instructions.front().getAddress();
}


triton::uint64 BasicBlock::getLastAddress(void) const {
if (this->instructions.size() == 0)
throw triton::exceptions::BasicBlock("BasicBlock::getLastAddress(): No instruction in the block.");
return this->instructions.back().getAddress();
}


std::ostream& operator<<(std::ostream& stream, BasicBlock& block) {
triton::usize size = block.getSize();
for (const auto& inst : block.getInstructions()) {
Expand All @@ -90,11 +77,10 @@ namespace triton {
return stream;
}


std::ostream& operator<<(std::ostream& stream, BasicBlock* block) {
stream << *block;
return stream;
}

};
};
}; // namespace arch
}; // namespace triton
Loading
Loading