mirror of https://github.com/stella-emu/stella.git
More fixes for warnings from clang-tidy.
This commit is contained in:
parent
bf8648679c
commit
a4b216aac1
|
@ -30,7 +30,7 @@ class CartridgeELF: public Cartridge {
|
|||
public:
|
||||
CartridgeELF(const ByteBuffer& image, size_t size, string_view md5,
|
||||
const Settings& settings);
|
||||
virtual ~CartridgeELF();
|
||||
~CartridgeELF() override;
|
||||
|
||||
// Methods from Device
|
||||
public:
|
||||
|
@ -67,11 +67,11 @@ class CartridgeELF: public Cartridge {
|
|||
|
||||
private:
|
||||
class BusFallbackDelegate: public CortexM0::BusTransactionDelegate {
|
||||
CortexM0::err_t fetch16(uInt32 address, uInt16& value, uInt8& op, CortexM0& cortex);
|
||||
CortexM0::err_t read8(uInt32 address, uInt8& value, CortexM0& cortex);
|
||||
CortexM0::err_t fetch16(uInt32 address, uInt16& value, uInt8& op, CortexM0& cortex) override;
|
||||
CortexM0::err_t read8(uInt32 address, uInt8& value, CortexM0& cortex) override;
|
||||
};
|
||||
|
||||
enum class ExecutionStage {
|
||||
enum class ExecutionStage: uInt8 {
|
||||
boot, preinit, init, main
|
||||
};
|
||||
|
||||
|
@ -125,6 +125,14 @@ class CartridgeELF: public Cartridge {
|
|||
|
||||
ExecutionStage myExecutionStage{ExecutionStage::boot};
|
||||
uInt32 myInitFunctionIndex{0};
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeELF(const CartridgeELF&) = delete;
|
||||
CartridgeELF(CartridgeELF&&) = delete;
|
||||
CartridgeELF& operator=(const CartridgeELF&) = delete;
|
||||
CartridgeELF& operator=(CartridgeELF&&) = delete;
|
||||
|
||||
};
|
||||
|
||||
#endif // CARTRIDGE_ELF
|
||||
|
|
|
@ -32,6 +32,7 @@ class CortexM0
|
|||
|
||||
class BusTransactionDelegate {
|
||||
public:
|
||||
BusTransactionDelegate() = default;
|
||||
virtual ~BusTransactionDelegate() = default;
|
||||
|
||||
virtual err_t read32(uInt32 address, uInt32& value, CortexM0& cortex);
|
||||
|
@ -43,6 +44,13 @@ class CortexM0
|
|||
virtual err_t write8(uInt32 address, uInt8 value, CortexM0& cortex);
|
||||
|
||||
virtual err_t fetch16(uInt32 address, uInt16& value, uInt8& op, CortexM0& cortex);
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
BusTransactionDelegate(const BusTransactionDelegate&) = delete;
|
||||
BusTransactionDelegate(BusTransactionDelegate&&) = delete;
|
||||
BusTransactionDelegate& operator=(const BusTransactionDelegate&) = delete;
|
||||
BusTransactionDelegate& operator=(BusTransactionDelegate&&) = delete;
|
||||
};
|
||||
|
||||
static constexpr uInt32 PAGE_SIZE = 4096;
|
||||
|
@ -63,27 +71,27 @@ class CortexM0
|
|||
static constexpr err_t ERR_SWI = 13;
|
||||
static constexpr err_t ERR_UNDEFINED_INST = 14;
|
||||
|
||||
static inline bool isErrCustom(err_t err) {
|
||||
static constexpr bool isErrCustom(err_t err) {
|
||||
return (err & 0xff) == 0;
|
||||
}
|
||||
|
||||
static inline uInt32 getErrCustom(err_t err) {
|
||||
static constexpr uInt32 getErrCustom(err_t err) {
|
||||
return (err & 0xffffffff) >> 8;
|
||||
}
|
||||
|
||||
static inline uInt8 getErrInstrinsic(err_t err) {
|
||||
static constexpr uInt8 getErrInstrinsic(err_t err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline uInt32 getErrExtra(err_t err) {
|
||||
static constexpr uInt32 getErrExtra(err_t err) {
|
||||
return err >> 32;
|
||||
}
|
||||
|
||||
static inline err_t errCustom(uInt32 code, uInt32 extra = 0) {
|
||||
static constexpr err_t errCustom(uInt32 code, uInt32 extra = 0) {
|
||||
return ((static_cast<uInt64>(code) << 8) & 0xffffffff) | (static_cast<uInt64>(extra) << 32);
|
||||
}
|
||||
|
||||
static inline err_t errIntrinsic(uInt8 code, uInt32 extra = 0) {
|
||||
static constexpr err_t errIntrinsic(uInt8 code, uInt32 extra = 0) {
|
||||
return static_cast<uInt64>(code) | (static_cast<uInt64>(extra) << 32);
|
||||
}
|
||||
|
||||
|
@ -91,6 +99,7 @@ class CortexM0
|
|||
|
||||
public:
|
||||
CortexM0();
|
||||
~CortexM0() = default;
|
||||
|
||||
CortexM0& mapRegionData(uInt32 pageBase, uInt32 pageCount,
|
||||
bool readOnly, uInt8* backingStore);
|
||||
|
@ -120,7 +129,7 @@ class CortexM0
|
|||
err_t write16(uInt32 address, uInt16 value);
|
||||
err_t write8(uInt32 address, uInt8 value);
|
||||
|
||||
inline uInt64 getCycles() const {
|
||||
uInt64 getCycles() const {
|
||||
return myCycleCounter;
|
||||
}
|
||||
|
||||
|
@ -134,12 +143,12 @@ class CortexM0
|
|||
};
|
||||
|
||||
struct MemoryRegionAccessData {
|
||||
uInt8* backingStore;
|
||||
uInt8* backingStore{nullptr};
|
||||
};
|
||||
|
||||
struct MemoryRegionAccessCode {
|
||||
uInt8* backingStore;
|
||||
uInt8* ops;
|
||||
uInt8* backingStore{nullptr};
|
||||
uInt8* ops{nullptr};
|
||||
};
|
||||
|
||||
struct MemoryRegion {
|
||||
|
@ -152,14 +161,14 @@ class CortexM0
|
|||
|
||||
MemoryRegionType type{MemoryRegionType::unmapped};
|
||||
|
||||
uInt32 base;
|
||||
uInt32 size;
|
||||
bool readOnly;
|
||||
uInt32 base{0};
|
||||
uInt32 size{0};
|
||||
bool readOnly{false};
|
||||
|
||||
union {
|
||||
MemoryRegionAccessData accessData;
|
||||
MemoryRegionAccessCode accessCode;
|
||||
BusTransactionDelegate* delegate;
|
||||
BusTransactionDelegate* delegate{nullptr};
|
||||
} access;
|
||||
|
||||
private:
|
||||
|
@ -195,10 +204,10 @@ class CortexM0
|
|||
uInt64 myCycleCounter{0};
|
||||
|
||||
static constexpr uInt32
|
||||
CPSR_N = 1u << 31,
|
||||
CPSR_Z = 1u << 30,
|
||||
CPSR_C = 1u << 29,
|
||||
CPSR_V = 1u << 28;
|
||||
CPSR_N = 1U << 31,
|
||||
CPSR_Z = 1U << 30,
|
||||
CPSR_C = 1U << 29,
|
||||
CPSR_V = 1U << 28;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -28,14 +28,15 @@ class BusTransactionQueue {
|
|||
|
||||
void setBusState(bool& drive, uInt8& value) const;
|
||||
|
||||
uInt16 address;
|
||||
uInt8 value;
|
||||
uInt64 timestamp;
|
||||
bool yield;
|
||||
uInt16 address{0};
|
||||
uInt8 value{0};
|
||||
uInt64 timestamp{0};
|
||||
bool yield{false};
|
||||
};
|
||||
|
||||
public:
|
||||
explicit BusTransactionQueue(size_t capacity);
|
||||
~BusTransactionQueue() = default;
|
||||
|
||||
BusTransactionQueue& reset();
|
||||
|
||||
|
@ -52,7 +53,7 @@ class BusTransactionQueue {
|
|||
bool hasPendingTransaction() const;
|
||||
Transaction* getNextTransaction(uInt16 address, uInt64 timestamp);
|
||||
|
||||
inline size_t size() const {
|
||||
size_t size() const {
|
||||
return myQueueSize;
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ class BusTransactionQueue {
|
|||
void push(const Transaction& transaction);
|
||||
|
||||
private:
|
||||
const size_t myQueueCapacity;
|
||||
const size_t myQueueCapacity{0};
|
||||
|
||||
unique_ptr<Transaction[]> myQueue;
|
||||
size_t myQueueNext{0};
|
||||
|
|
|
@ -120,6 +120,6 @@ namespace elfEnvironment {
|
|||
enum class Palette: uInt8 {pal, ntsc};
|
||||
|
||||
vector<ElfLinker::ExternalSymbol> externalSymbols(Palette palette);
|
||||
}
|
||||
} // namespace elfEnvironment
|
||||
|
||||
#endif // ELF_ENVIRONMENT
|
||||
|
|
|
@ -23,44 +23,45 @@
|
|||
class ElfFile {
|
||||
public:
|
||||
struct Section {
|
||||
uInt32 nameOffset;
|
||||
uInt32 nameOffset{0};
|
||||
string name;
|
||||
|
||||
uInt32 type;
|
||||
uInt32 flags;
|
||||
uInt32 type{0};
|
||||
uInt32 flags{0};
|
||||
|
||||
uInt32 virtualAddress;
|
||||
uInt32 offset;
|
||||
uInt32 size;
|
||||
uInt32 virtualAddress{0};
|
||||
uInt32 offset{0};
|
||||
uInt32 size{0};
|
||||
|
||||
uInt32 info;
|
||||
uInt32 align;
|
||||
uInt32 info{0};
|
||||
uInt32 align{0};
|
||||
};
|
||||
|
||||
struct Symbol {
|
||||
uInt32 nameOffset;
|
||||
uInt32 value;
|
||||
uInt32 size;
|
||||
uInt8 info;
|
||||
uInt8 visibility;
|
||||
uInt16 section;
|
||||
uInt32 nameOffset{0};
|
||||
uInt32 value{0};
|
||||
uInt32 size{0};
|
||||
uInt8 info{0};
|
||||
uInt8 visibility{0};
|
||||
uInt16 section{0};
|
||||
|
||||
string name;
|
||||
uInt8 bind;
|
||||
uInt8 type;
|
||||
uInt8 bind{0};
|
||||
uInt8 type{0};
|
||||
};
|
||||
|
||||
struct Relocation {
|
||||
uInt32 offset;
|
||||
uInt32 info;
|
||||
uInt32 offset{0};
|
||||
uInt32 info{0};
|
||||
optional<uInt32> addend;
|
||||
|
||||
uInt32 symbol;
|
||||
uInt8 type;
|
||||
uInt32 symbol{0};
|
||||
uInt8 type{0};
|
||||
string symbolName;
|
||||
};
|
||||
|
||||
public:
|
||||
ElfFile() = default;
|
||||
virtual ~ElfFile() = default;
|
||||
|
||||
virtual const uInt8 *getData() const = 0;
|
||||
|
@ -68,7 +69,7 @@ class ElfFile {
|
|||
|
||||
virtual const vector<Section>& getSections() const = 0;
|
||||
virtual const vector<Symbol>& getSymbols() const = 0;
|
||||
virtual const optional<vector<Relocation>> getRelocations(size_t section) const = 0;
|
||||
virtual optional<vector<Relocation>> getRelocations(size_t section) const = 0;
|
||||
|
||||
public:
|
||||
static constexpr uInt8 ENDIAN_LITTLE_ENDIAN = 0x01;
|
||||
|
@ -100,6 +101,13 @@ class ElfFile {
|
|||
static constexpr uInt32 R_ARM_TARGET1 = 0x26;
|
||||
|
||||
static constexpr uInt32 STT_FUNC = 0x02;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
ElfFile(const ElfFile&) = delete;
|
||||
ElfFile(ElfFile&&) = delete;
|
||||
ElfFile& operator=(const ElfFile&) = delete;
|
||||
ElfFile& operator=(ElfFile&&) = delete;
|
||||
};
|
||||
|
||||
#endif // ELF_FILE
|
||||
|
|
|
@ -155,7 +155,7 @@ ElfLinker::RelocatedSymbol ElfLinker::findRelocatedSymbol(string_view name) cons
|
|||
if (!myRelocatedSymbols[i])
|
||||
ElfSymbolResolutionError::raise("symbol could not be relocated");
|
||||
|
||||
return *myRelocatedSymbols[i];
|
||||
return *myRelocatedSymbols[i]; // FIXME: bugprone-unchecked-optional-access
|
||||
}
|
||||
|
||||
ElfSymbolResolutionError::raise("symbol not found");
|
||||
|
@ -404,7 +404,7 @@ void ElfLinker::copyInitArrays(vector<uInt32>& initArray, const std::unordered_m
|
|||
void ElfLinker::applyRelocationToSection(const ElfFile::Relocation& relocation, size_t iSection)
|
||||
{
|
||||
const auto& targetSection = myElf.getSections()[iSection];
|
||||
const auto& targetSectionRelocated = *myRelocatedSections[iSection];
|
||||
const auto& targetSectionRelocated = *myRelocatedSections[iSection]; // FIXME: bugprone-unchecked-optional-access
|
||||
const auto& symbol = myElf.getSymbols()[relocation.symbol];
|
||||
const auto& relocatedSymbol = myRelocatedSymbols[relocation.symbol];
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class ElfLinker {
|
|||
explicit ElfLinkError(string_view reason) : myReason(reason) {}
|
||||
|
||||
private:
|
||||
const string myReason;
|
||||
string myReason;
|
||||
};
|
||||
|
||||
class ElfSymbolResolutionError : public std::exception {
|
||||
|
@ -54,29 +54,30 @@ class ElfLinker {
|
|||
explicit ElfSymbolResolutionError(string_view reason) : myReason(reason) {}
|
||||
|
||||
private:
|
||||
const string myReason;
|
||||
string myReason;
|
||||
};
|
||||
|
||||
enum class SegmentType: uInt8 { text, data, rodata };
|
||||
|
||||
struct RelocatedSection {
|
||||
SegmentType segment;
|
||||
uInt32 offset;
|
||||
uInt32 offset{0};
|
||||
};
|
||||
|
||||
struct RelocatedSymbol {
|
||||
optional<SegmentType> segment;
|
||||
uInt32 value;
|
||||
bool undefined;
|
||||
uInt32 value{0};
|
||||
bool undefined{true};
|
||||
};
|
||||
|
||||
struct ExternalSymbol {
|
||||
string name;
|
||||
uInt32 value;
|
||||
uInt32 value{0};
|
||||
};
|
||||
|
||||
public:
|
||||
ElfLinker(uInt32 textBase, uInt32 dataBase, uInt32 rodataBase, const ElfFile& elf);
|
||||
~ElfLinker() = default;
|
||||
|
||||
ElfLinker& setUndefinedSymbolDefault(uInt32 defaultValue);
|
||||
void link(const vector<ExternalSymbol>& externalSymbols);
|
||||
|
|
|
@ -127,7 +127,7 @@ const vector<ElfParser::Symbol>& ElfParser::getSymbols() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const optional<vector<ElfParser::Relocation>> ElfParser::getRelocations(size_t section) const
|
||||
optional<vector<ElfParser::Relocation>> ElfParser::getRelocations(size_t section) const
|
||||
{
|
||||
return myRelocations.contains(section) ? myRelocations.at(section) : optional<vector<Relocation>>();
|
||||
}
|
||||
|
|
|
@ -39,11 +39,12 @@ class ElfParser : public ElfFile {
|
|||
explicit ElfParseError(string_view reason) : myReason(reason) {}
|
||||
|
||||
private:
|
||||
const string myReason;
|
||||
string myReason;
|
||||
};
|
||||
|
||||
public:
|
||||
ElfParser() = default;
|
||||
~ElfParser() override = default;
|
||||
|
||||
void parse(const uInt8 *elfData, size_t size);
|
||||
|
||||
|
@ -52,18 +53,18 @@ class ElfParser : public ElfFile {
|
|||
|
||||
const vector<Section>& getSections() const override;
|
||||
const vector<Symbol>& getSymbols() const override;
|
||||
const optional<vector<Relocation>> getRelocations(size_t section) const override;
|
||||
optional<vector<Relocation>> getRelocations(size_t section) const override;
|
||||
|
||||
private:
|
||||
struct Header {
|
||||
uInt16 type;
|
||||
uInt16 arch;
|
||||
uInt8 endianess;
|
||||
uInt32 shOffset;
|
||||
uInt16 type{0};
|
||||
uInt16 arch{0};
|
||||
uInt8 endianess{0};
|
||||
uInt32 shOffset{0};
|
||||
|
||||
uInt16 shNum;
|
||||
uInt16 shSize;
|
||||
uInt16 shstrIndex;
|
||||
uInt16 shNum{0};
|
||||
uInt16 shSize{0};
|
||||
uInt16 shstrIndex{0};
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -81,9 +82,9 @@ class ElfParser : public ElfFile {
|
|||
|
||||
private:
|
||||
const uInt8 *myData{nullptr};
|
||||
size_t mySize;
|
||||
size_t mySize{0};
|
||||
|
||||
bool myBigEndian{true};
|
||||
bool myBigEndian{false};
|
||||
|
||||
Header myHeader;
|
||||
vector<Section> mySections;
|
||||
|
|
|
@ -24,6 +24,6 @@ namespace elfUtil {
|
|||
Int32 decode_B_BL(uInt32 opcode);
|
||||
|
||||
uInt32 encode_B_BL(Int32 offset, bool link);
|
||||
}
|
||||
} // namespace elfUtil
|
||||
|
||||
#endif // ELF_UTIL
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace {
|
|||
return mySymbols;
|
||||
}
|
||||
|
||||
const optional<vector<Relocation>> getRelocations(size_t section) const override {
|
||||
optional<vector<Relocation>> getRelocations(size_t section) const override {
|
||||
return myRelocations.contains(section) ? myRelocations.at(section) : optional<vector<Relocation>>();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,8 +107,10 @@ namespace {
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
VcsLib::VcsLib(BusTransactionQueue& transactionQueue) : myTransactionQueue(transactionQueue)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void VcsLib::reset()
|
||||
{
|
||||
myStuffMaskA = myStuffMaskX = myStuffMaskY = 0x00;
|
||||
|
@ -364,7 +366,7 @@ CortexM0::err_t VcsLib::fetch16(uInt32 address, uInt16& value, uInt8& op, Cortex
|
|||
}
|
||||
|
||||
case ADDR_RANDINT:
|
||||
cortex.setRegister(0, rand());
|
||||
cortex.setRegister(0, rand()); // FIXME: use C++11 random library instead
|
||||
return returnFromStub(value, op);
|
||||
|
||||
case ADDR_VCS_TXS2:
|
||||
|
|
|
@ -25,17 +25,18 @@
|
|||
class VcsLib: public CortexM0::BusTransactionDelegate {
|
||||
public:
|
||||
explicit VcsLib(BusTransactionQueue& transactionQueue);
|
||||
~VcsLib() override = default;
|
||||
|
||||
void reset();
|
||||
|
||||
CortexM0::err_t fetch16(uInt32 address, uInt16& value, uInt8& op, CortexM0& cortex) override;
|
||||
|
||||
inline void updateBus(uInt16 address, uInt8 value) {
|
||||
void updateBus(uInt16 address, uInt8 value) {
|
||||
myCurrentAddress = address;
|
||||
myCurrentValue = value;
|
||||
}
|
||||
|
||||
inline bool isSuspended() const {
|
||||
bool isSuspended() const {
|
||||
return
|
||||
myIsWaitingForRead && (myTransactionQueue.size() > 0 || (myWaitingForReadAddress != myCurrentAddress));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue