Add various -Werror flags
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -12,7 +12,10 @@ endif()
project(Ripes CXX)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
- set(CMAKE_CXX_FLAGS "-Wextra -Wall -Wno-unused-local-typedefs -Wno-unused-function")
+ set(CMAKE_CXX_FLAGS "-Wextra -Wall \
+ -Werror=switch -Werror=return-type -Werror=shadow \
+ -Werror=unreachable-code -Werror=Wno-bad-function-cast \
+ -Werror=no-unused-function -Werror=no-unused-local-typedefs")
endif()
######################################################################

MODIFY
external/VSRTL
external/VSRTL
-Subproject commit 403b51a65a2729e8916df97a6e087dd68bef2b78
+Subproject commit 744f4361767eca48b96d07a84b079aeef99e7499

MODIFY
src/assembler/assembler.h
src/assembler/assembler.h
@@ -115,12 +115,12 @@ protected:
}
m_relocations = relocations;
for (const auto& iter : m_relocations) {
- const auto relocations = iter.get()->name();
- if (m_relocationsMap.count(relocations) != 0) {
- throw std::runtime_error("Error: relocation " + relocations.toStdString() +
+ const auto relocation = iter.get()->name();
+ if (m_relocationsMap.count(relocation) != 0) {
+ throw std::runtime_error("Error: relocation " + relocation.toStdString() +
" has already been registerred.");
}
- m_relocationsMap[relocations] = iter;
+ m_relocationsMap[relocation] = iter;
}
}

MODIFY
src/assembler/matcher.h
src/assembler/matcher.h
@@ -70,7 +70,6 @@ private:
MatchNode buildMatchTree(const std::vector<std::shared_ptr<Instruction>>& instructions,
const unsigned fieldDepth = 1, OpPart matcher = OpPart(0, BitRange(0, 0, 2))) {
- using InstrVec = std::vector<std::shared_ptr<Instruction>>;
std::map<OpPart, InstrVec> instrsWithEqualOpPart;
for (const auto& instr : instructions) {

MODIFY
src/cachesim/cacheconfigwidget.cpp
src/cachesim/cacheconfigwidget.cpp
@@ -93,8 +93,8 @@ void CacheConfigWidget::setupPresets() {
preset.ways = 1;
presets.push_back({"32-entry 4-word 2-way set associative", preset});
- for (const auto& preset : presets) {
- m_ui->presets->addItem(preset.first, QVariant::fromValue<CacheSim::CachePreset>(preset.second));
+ for (const auto& it : presets) {
+ m_ui->presets->addItem(it.first, QVariant::fromValue<CacheSim::CachePreset>(it.second));
}
connect(m_ui->presets, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index) {

MODIFY
src/cachesim/cachesim.cpp
src/cachesim/cachesim.cpp
@@ -83,7 +83,7 @@ CacheSim::CacheSize CacheSim::getCacheSize() const {
if (m_wrPolicy == WritePolicy::WriteBack) {
// Dirty bits
- unsigned componentBits = entries; // 1 bit per entry
+ componentBits = entries; // 1 bit per entry
size.components.push_back("Dirty bits: " + QString::number(componentBits));
size.bits += componentBits;
}

MODIFY
src/processors/RISC-V/rv_alu.h
src/processors/RISC-V/rv_alu.h
@@ -23,16 +23,16 @@ public:
case ALUOp::MUL:
return static_cast<uint32_t>(op1.sValue() * op2.sValue());
case ALUOp::MULH: {
- const auto res = static_cast<int64_t>(op1.sValue()) * static_cast<int64_t>(op2.sValue());
- return static_cast<uint32_t>(res >> 32);
+ const auto result = static_cast<int64_t>(op1.sValue()) * static_cast<int64_t>(op2.sValue());
+ return static_cast<uint32_t>(result >> 32);
}
case ALUOp::MULHU: {
- const auto res = static_cast<uint64_t>(op1.uValue()) * static_cast<uint64_t>(op2.uValue());
- return static_cast<uint32_t>(res >> 32);
+ const auto result = static_cast<uint64_t>(op1.uValue()) * static_cast<uint64_t>(op2.uValue());
+ return static_cast<uint32_t>(result >> 32);
}
case ALUOp::MULHSU: {
- const int64_t res = static_cast<int64_t>(op1.sValue()) * static_cast<uint64_t>(op2.uValue());
- return static_cast<uint32_t>(res >> 32);
+ const int64_t result = static_cast<int64_t>(op1.sValue()) * static_cast<uint64_t>(op2.uValue());
+ return static_cast<uint32_t>(result >> 32);
}
case ALUOp::DIV:
if (op2.sValue() == 0) {

DELETE
src/rwjumpwidget.cpp
-#include "rwjumpwidget.h"
-#include "ui_rwjumpwidget.h"
-
-#include <QHeaderView>
-
-namespace Ripes {
-
-RWJumpWidget::RWJumpWidget(QWidget* parent) : QWidget(parent), ui(new Ui::RWJumpWidget) {
- ui->setupUi(this);
-}
-
-void RWJumpWidget::init() {
- return;
- // m_model = new RWJumpModel();
- // ui->view->setModel(m_model);
- ui->view->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
- ui->view->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
- ui->view->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
- ui->view->horizontalHeader()->setSectionResizeMode(3, QHeaderView::Stretch);
- ui->view->setSelectionBehavior(QAbstractItemView::SelectRows);
-}
-
-void RWJumpWidget::updateModel() {
- // m_model->update();
-}
-
-RWJumpWidget::~RWJumpWidget() {
- delete ui;
-}
-
-void RWJumpWidget::on_jump_clicked() {
- // Get selected index
- auto selecter = ui->view->selectionModel();
- if (selecter->hasSelection()) {
- auto indexes = selecter->selectedIndexes();
- // emit jumpToAdress(m_model->data(indexes[0], Qt::UserRole).value<uint32_t>());
- }
-}
-} // namespace Ripes

DELETE
src/rwjumpwidget.h
-#pragma once
-
-#include <QWidget>
-
-namespace Ripes {
-
-namespace Ui {
-class RWJumpWidget;
-}
-
-class RWJumpWidget : public QWidget {
- Q_OBJECT
-
-public:
- explicit RWJumpWidget(QWidget* parent = nullptr);
- ~RWJumpWidget() override;
- void init();
- void updateModel();
-
-signals:
- void jumpToAdress(uint32_t);
-
-private slots:
- void on_jump_clicked();
-
-private:
- Ui::RWJumpWidget* ui;
-};
-} // namespace Ripes

DELETE
src/rwjumpwidget.ui
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Ripes::RWJumpWidget</class>
- <widget class="QWidget" name="Ripes::RWJumpWidget">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Memory accesses</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="jump">
- <property name="text">
- <string>Go to selected access address</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QTableView" name="view"/>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>

Add various -Werror flags