Skip to content

Commit

Permalink
maor [[nodiscard]]
Browse files Browse the repository at this point in the history
  • Loading branch information
eteran committed Mar 18, 2024
1 parent 5d5d6f8 commit ee0da7d
Show file tree
Hide file tree
Showing 43 changed files with 172 additions and 172 deletions.
12 changes: 6 additions & 6 deletions include/ArchProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ class EDB_EXPORT ArchProcessor : public QObject {

public:
QStringList updateInstructionInfo(edb::address_t address);
bool canStepOver(const edb::Instruction &inst) const;
bool isFilling(const edb::Instruction &inst) const;
[[nodiscard]] bool canStepOver(const edb::Instruction &inst) const;
[[nodiscard]] bool isFilling(const edb::Instruction &inst) const;
//! Checks whether potentially conditional instruction's condition is satisfied
bool isExecuted(const edb::Instruction &inst, const State &state) const;
Result<edb::address_t, QString> getEffectiveAddress(const edb::Instruction &inst, const edb::Operand &op, const State &state) const;
edb::address_t getEffectiveAddress(const edb::Instruction &inst, const edb::Operand &op, const State &state, bool &ok) const;
[[nodiscard]] bool isExecuted(const edb::Instruction &inst, const State &state) const;
[[nodiscard]] Result<edb::address_t, QString> getEffectiveAddress(const edb::Instruction &inst, const edb::Operand &op, const State &state) const;
[[nodiscard]] edb::address_t getEffectiveAddress(const edb::Instruction &inst, const edb::Operand &op, const State &state, bool &ok) const;
void reset();
void aboutToResume();
void setupRegisterView();
void updateRegisterView(const QString &default_region_name, const State &state);
RegisterViewModelBase::Model &registerViewModel() const;
[[nodiscard]] RegisterViewModelBase::Model &registerViewModel() const;

private:
bool justAttached_ = true;
Expand Down
42 changes: 21 additions & 21 deletions include/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,41 @@ class EDB_EXPORT BasicBlock {
void addReference(edb::address_t refsite, edb::address_t target);

public:
std::vector<std::pair<edb::address_t, edb::address_t>> references() const;
[[nodiscard]] std::vector<std::pair<edb::address_t, edb::address_t>> references() const;

public:
reference operator[](size_type pos);
const_reference operator[](size_type pos) const;
[[nodiscard]] reference operator[](size_type pos);
[[nodiscard]] const_reference operator[](size_type pos) const;

const_reference back() const;
const_reference front() const;
reference back();
reference front();
[[nodiscard]] const_reference back() const;
[[nodiscard]] const_reference front() const;
[[nodiscard]] reference back();
[[nodiscard]] reference front();

public:
const_iterator begin() const;
const_iterator end() const;
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
iterator begin();
iterator end();
reverse_iterator rbegin();
reverse_iterator rend();
[[nodiscard]] const_iterator begin() const;
[[nodiscard]] const_iterator end() const;
[[nodiscard]] const_reverse_iterator rbegin() const;
[[nodiscard]] const_reverse_iterator rend() const;
[[nodiscard]] iterator begin();
[[nodiscard]] iterator end();
[[nodiscard]] reverse_iterator rbegin();
[[nodiscard]] reverse_iterator rend();

public:
size_type size() const;
bool empty() const;
[[nodiscard]] size_type size() const;
[[nodiscard]] bool empty() const;

public:
void swap(BasicBlock &other);

public:
QString toString() const;
[[nodiscard]] QString toString() const;

public:
size_type byteSize() const;
edb::address_t firstAddress() const;
edb::address_t lastAddress() const;
[[nodiscard]] size_type byteSize() const;
[[nodiscard]] edb::address_t firstAddress() const;
[[nodiscard]] edb::address_t lastAddress() const;

private:
std::vector<instruction_pointer> instructions_;
Expand Down
6 changes: 3 additions & 3 deletions include/BinaryString.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ private Q_SLOTS:
void on_keepSize_stateChanged(int state);

public:
[[nodiscard]] bool showKeepSize() const;
[[nodiscard]] QByteArray value() const;
void setMaxLength(int n);
QByteArray value() const;
void setValue(const QByteArray &);
void setShowKeepSize(bool visible);
bool showKeepSize() const;
void setValue(const QByteArray &);

private:
void setEntriesMaxLength(int n);
Expand Down
8 changes: 4 additions & 4 deletions include/ByteShiftArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class EDB_EXPORT ByteShiftArray {
ByteShiftArray &operator<<(uint8_t x);

public:
int size() const;
[[nodiscard]] int size() const;

public:
uint8_t &operator[](std::size_t i);
uint8_t operator[](std::size_t i) const;
const uint8_t *data() const;
[[nodiscard]] uint8_t &operator[](std::size_t i);
[[nodiscard]] uint8_t operator[](std::size_t i) const;
[[nodiscard]] const uint8_t *data() const;

private:
QVector<uint8_t> data_;
Expand Down
38 changes: 19 additions & 19 deletions include/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,34 @@ class EDB_EXPORT Function {
public:
void insert(const BasicBlock &bb);
void addReference();
Type type() const;
[[nodiscard]] Type type() const;
void setType(Type t);

public:
const_reference back() const;
const_reference front() const;
reference back();
reference front();
[[nodiscard]] const_reference back() const;
[[nodiscard]] const_reference front() const;
[[nodiscard]] reference back();
[[nodiscard]] reference front();

public:
const_iterator begin() const;
const_iterator end() const;
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
iterator begin();
iterator end();
reverse_iterator rbegin();
reverse_iterator rend();
[[nodiscard]] const_iterator begin() const;
[[nodiscard]] const_iterator end() const;
[[nodiscard]] const_reverse_iterator rbegin() const;
[[nodiscard]] const_reverse_iterator rend() const;
[[nodiscard]] iterator begin();
[[nodiscard]] iterator end();
[[nodiscard]] reverse_iterator rbegin();
[[nodiscard]] reverse_iterator rend();

public:
bool empty() const;
size_type size() const;
[[nodiscard]] bool empty() const;
[[nodiscard]] size_type size() const;

public:
edb::address_t entryAddress() const;
edb::address_t endAddress() const;
edb::address_t lastInstruction() const;
int referenceCount() const;
[[nodiscard]] edb::address_t entryAddress() const;
[[nodiscard]] edb::address_t endAddress() const;
[[nodiscard]] edb::address_t lastInstruction() const;
[[nodiscard]] int referenceCount() const;

public:
void swap(Function &other);
Expand Down
8 changes: 4 additions & 4 deletions include/GraphEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ class GraphEdge final : public QGraphicsItemGroup {
}

public:
GraphNode *from() const;
GraphNode *to() const;
[[nodiscard]] GraphNode *from() const;
[[nodiscard]] GraphNode *to() const;
void clear();
void syncState();

public:
int lineThickness() const;
QColor lineColor() const;
[[nodiscard]] int lineThickness() const;
[[nodiscard]] QColor lineColor() const;

public:
void updateLines();
Expand Down
2 changes: 1 addition & 1 deletion include/GraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GraphNode final : public QGraphicsItem {

public:
void setFont(const QFont &font);
QFont font() const;
[[nodiscard]] QFont font() const;

public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
Expand Down
14 changes: 7 additions & 7 deletions include/IPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ class IPlugin {

public:
// optional, overload these to have there contents added to a view's context menu
virtual QList<QAction *> cpuContextMenu() { return {}; }
virtual QList<QAction *> registerContextMenu() { return {}; }
virtual QList<QAction *> stackContextMenu() { return {}; }
virtual QList<QAction *> dataContextMenu() { return {}; }
[[nodiscard]] virtual QList<QAction *> cpuContextMenu() { return {}; }
[[nodiscard]] virtual QList<QAction *> registerContextMenu() { return {}; }
[[nodiscard]] virtual QList<QAction *> stackContextMenu() { return {}; }
[[nodiscard]] virtual QList<QAction *> dataContextMenu() { return {}; }

// optional, overload this to add a page to the options dialog
virtual QWidget *optionsPage() { return nullptr; }
[[nodiscard]] virtual QWidget *optionsPage() { return nullptr; }

public:
virtual QVariantMap saveState() const { return {}; }
[[nodiscard]] virtual QVariantMap saveState() const { return {}; }
virtual void restoreState(const QVariantMap &) {}

public:
Expand All @@ -65,7 +65,7 @@ class IPlugin {

// optional, command line argument processing
// return a string to add to "--help"
virtual QString extraArguments() const { return {}; }
[[nodiscard]] virtual QString extraArguments() const { return {}; }

// take actions based on the command line arguments
// you *may* remove arguments which are exclusively yours
Expand Down
4 changes: 2 additions & 2 deletions include/MemoryRegions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class EDB_EXPORT MemoryRegions final : public QAbstractItemModel {
~MemoryRegions() override = default;

public:
std::shared_ptr<IRegion> findRegion(edb::address_t address) const;
const QList<std::shared_ptr<IRegion>> &regions() const { return regions_; }
[[nodiscard]] std::shared_ptr<IRegion> findRegion(edb::address_t address) const;
[[nodiscard]] const QList<std::shared_ptr<IRegion>> &regions() const { return regions_; }
void clear();
void sync();

Expand Down
4 changes: 2 additions & 2 deletions include/QLongValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class EDB_EXPORT QLongValidator : public QValidator {
~QLongValidator() override = default;

public:
value_type bottom() const;
value_type top() const;
[[nodiscard]] value_type bottom() const;
[[nodiscard]] value_type top() const;
QValidator::State validate(QString &input, int &pos) const override;
void setRange(value_type bottom, value_type top);
void setBottom(value_type bottom);
Expand Down
4 changes: 2 additions & 2 deletions include/QULongValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class EDB_EXPORT QULongValidator : public QValidator {
~QULongValidator() override = default;

public:
value_type bottom() const;
value_type top() const;
[[nodiscard]] value_type bottom() const;
[[nodiscard]] value_type top() const;
QValidator::State validate(QString &input, int &pos) const override;
void setRange(value_type bottom, value_type top);
void setBottom(value_type bottom);
Expand Down
16 changes: 8 additions & 8 deletions include/Register.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ class EDB_EXPORT Register {
Register &operator=(const Register &rhs) = default;

public:
bool operator==(const Register &rhs) const;
bool operator!=(const Register &rhs) const;
[[nodiscard]] bool operator==(const Register &rhs) const;
[[nodiscard]] bool operator!=(const Register &rhs) const;

public:
bool valid() const { return type_ != TYPE_INVALID; }
explicit operator bool() const { return valid(); }

Type type() const { return type_; }
QString name() const { return name_; }
std::size_t bitSize() const { return bitSize_; }
const char *rawData() const { return reinterpret_cast<const char *>(&value_); }
[[nodiscard]] Type type() const { return type_; }
[[nodiscard]] QString name() const { return name_; }
[[nodiscard]] std::size_t bitSize() const { return bitSize_; }
[[nodiscard]] const char *rawData() const { return reinterpret_cast<const char *>(&value_); }

template <class T>
T value() const { return T(value_); }

// Return the value, zero-extended to address_t to be usable in address calculations
edb::address_t valueAsAddress() const;
[[nodiscard]] edb::address_t valueAsAddress() const;

uint64_t valueAsInteger() const {
return valueAsAddress().toUint();
Expand Down Expand Up @@ -97,7 +97,7 @@ class EDB_EXPORT Register {
std::memcpy(to, from, bitSize_ / 8);
}

QString toHexString() const;
[[nodiscard]] QString toHexString() const;

private:
QString name_ = tr("<unknown>");
Expand Down
30 changes: 15 additions & 15 deletions include/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,31 @@ class EDB_EXPORT State {
void swap(State &other);

public:
[[nodiscard]] QString flagsToString() const;
[[nodiscard]] QString flagsToString(edb::reg_t flags) const;
[[nodiscard]] Register value(const QString &reg) const;
[[nodiscard]] Register instructionPointerRegister() const;
[[nodiscard]] Register flagsRegister() const;
[[nodiscard]] bool empty() const;
[[nodiscard]] edb::address_t framePointer() const;
[[nodiscard]] edb::address_t instructionPointer() const;
[[nodiscard]] edb::address_t stackPointer() const;
[[nodiscard]] edb::reg_t debugRegister(size_t n) const;
[[nodiscard]] edb::reg_t flags() const;
[[nodiscard]] Register gpRegister(size_t n) const;
[[nodiscard]] QString flagsToString() const;
[[nodiscard]] QString flagsToString(edb::reg_t flags) const;
[[nodiscard]] Register archRegister(uint64_t type, size_t n) const;
[[nodiscard]] Register flagsRegister() const;
[[nodiscard]] Register gpRegister(size_t n) const;
[[nodiscard]] Register instructionPointerRegister() const;
[[nodiscard]] Register value(const QString &reg) const;
void adjustStack(int bytes);
void clear();
bool empty() const;

public:
#if defined(EDB_X86) || defined(EDB_X86_64)
int fpuStackPointer() const;
edb::value80 fpuRegister(size_t n) const;
bool fpuRegisterIsEmpty(std::size_t n) const;
QString fpuRegisterTagString(std::size_t n) const;
edb::value16 fpuControlWord() const;
edb::value16 fpuStatusWord() const;
edb::value16 fpuTagWord() const;
[[nodiscard]] int fpuStackPointer() const;
[[nodiscard]] edb::value80 fpuRegister(size_t n) const;
[[nodiscard]] bool fpuRegisterIsEmpty(std::size_t n) const;
[[nodiscard]] QString fpuRegisterTagString(std::size_t n) const;
[[nodiscard]] edb::value16 fpuControlWord() const;
[[nodiscard]] edb::value16 fpuStatusWord() const;
[[nodiscard]] edb::value16 fpuTagWord() const;
#endif

public:
Expand All @@ -88,7 +88,7 @@ class EDB_EXPORT State {
void setRegister(const Register &reg);

public:
Register operator[](const QString &reg) const;
[[nodiscard]] Register operator[](const QString &reg) const;

private:
std::unique_ptr<IState> impl_;
Expand Down
2 changes: 1 addition & 1 deletion plugins/Analyzer/Analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Analyzer final : public QObject, public IAnalyzer, public IPlugin {
bool forFuncsInRange(edb::address_t start, edb::address_t end, std::function<bool(const Function *)> functor) const override;

private:
bool findContainingFunction(edb::address_t address, Function *function) const;
[[nodiscard]] bool findContainingFunction(edb::address_t address, Function *function) const;
void bonusEntryPoint(RegionData *data) const;
void bonusMain(RegionData *data) const;
void bonusMarkedFunctions(RegionData *data);
Expand Down
8 changes: 4 additions & 4 deletions plugins/Backtrace/CallStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class CallStack {
void getCallStack();

public:
StackFrame *operator[](size_t index);
size_t size() const;
StackFrame *top();
StackFrame *bottom();
[[nodiscard]] StackFrame *operator[](size_t index);
[[nodiscard]] size_t size() const;
[[nodiscard]] StackFrame *top();
[[nodiscard]] StackFrame *bottom();
void push(StackFrame frame);

private:
Expand Down
2 changes: 1 addition & 1 deletion plugins/BinarySearcher/DialogResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DialogResults : public QDialog {

public:
void addResult(RegionType region, edb::address_t address);
int resultCount() const;
[[nodiscard]] int resultCount() const;

public Q_SLOTS:
void on_listWidget_itemDoubleClicked(QListWidgetItem *);
Expand Down
Loading

0 comments on commit ee0da7d

Please sign in to comment.