srctree

Johan Norberg parent bfd7bb1d d5247756
Run clang-tidy with clang-13

.clang-tidy added: 27, removed: 18, total 9
@@ -1,6 +1,8 @@
---
Checks: '
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
clang-analyzer-*,
-clang-analyzer-cplusplus.NewDeleteLeaks,
clang-diagnostic-*,
@@ -10,6 +12,7 @@ Checks: '
hicpp-signed-bitwise,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
-modernize-use-trailing-return-type,
-modernize-use-nodiscard,
 
.github/workflows/ci-linux.yaml added: 27, removed: 18, total 9
@@ -42,10 +42,10 @@ jobs:
configuration: Debug
cmake-args: -DADDRESS_SANITIZER=ON -DUNDEFINED_SANITIZER=ON
 
- name: ubuntu-20.04-clang-tidy-10
- name: ubuntu-20.04-clang-tidy-13
os: ubuntu-20.04
compiler: clang
version: "10"
version: "13"
configuration: Debug
clang-tidy: true
cmake-args: -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
 
core/src/mos6502.cpp added: 27, removed: 18, total 9
@@ -21,10 +21,12 @@ constexpr uint8_t low_bits(uint8_t byte) {
 
constexpr int8_t to_signed(uint8_t byte) {
if (is_negative(byte)) {
return low_bits(byte) - static_cast<uint8_t>(128);
return static_cast<int8_t>(low_bits(byte) - static_cast<uint8_t>(128));
}
 
return low_bits(byte);
// this is fine since we have already checked that the number is not
// negative
return static_cast<int8_t>(low_bits(byte));
}
 
constexpr uint16_t high_byte(uint16_t word) {
@@ -896,10 +898,10 @@ Pipeline Mos6502::create_compare_instruction(Opcode opcode) {
const uint8_t value = mmu_->read_byte(effective_address_);
// Compare instructions are not affected be the
// carry flag when executing the subtraction.
const int16_t temp_result = *reg - value;
const uint8_t temp_result = *reg - value;
set_carry(*reg >= value);
set_zero(static_cast<uint8_t>(temp_result));
set_negative(static_cast<uint8_t>(temp_result));
set_zero(temp_result);
set_negative(temp_result);
});
return result;
}
@@ -917,9 +919,9 @@ Pipeline Mos6502::create_dcp_instruction(Opcode opcode) {
const uint8_t reg = registers_->a;
 
set_carry(reg >= new_value);
const int16_t temp_result = reg - new_value;
set_zero(static_cast<uint8_t>(temp_result));
set_negative(static_cast<uint8_t>(temp_result));
const uint8_t temp_result = reg - new_value;
set_zero(temp_result);
set_negative(temp_result);
});
return result;
}
 
core/src/rom_factory.cpp added: 27, removed: 18, total 9
@@ -40,7 +40,8 @@ std::unique_ptr<IRom> RomFactory::from_bytes(std::istream &bytestream) {
"File isn't big enough to contain a header");
}
 
if (!bytestream.read(reinterpret_cast<char *>(&bytes[0]), bytes.size())) {
const auto size = static_cast<std::streamsize>(bytes.size());
if (!bytestream.read(reinterpret_cast<char *>(&bytes[0]), size)) {
throw std::invalid_argument("Unable to get bytes");
}
 
 
disassembler/src/disassembler.cpp added: 27, removed: 18, total 9
@@ -23,9 +23,12 @@ constexpr uint8_t low_bits(uint8_t byte) {
 
constexpr int8_t to_signed(uint8_t byte) {
if (is_negative(byte)) {
return low_bits(byte) - static_cast<uint8_t>(128);
return static_cast<int8_t>(low_bits(byte) - static_cast<uint8_t>(128));
}
return low_bits(byte);
 
// this is fine since we have already checked that the number is not
// negative
return static_cast<int8_t>(low_bits(byte));
}
 
std::uint8_t read_mmu(const n_e_s::core::IMmu &mmu, const uint16_t addr) {