Fix some -Weffc++ warnings (part 1)

This commit is contained in:
Nekotekina 2021-03-30 18:31:46 +03:00
parent deacf05769
commit 2212a131ef
24 changed files with 162 additions and 56 deletions

View file

@ -3,6 +3,11 @@
#include "util/types.hpp"
#include "Utilities/StrFmt.h"
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
template<typename T, uint N>
struct bf_base
{
@ -250,6 +255,10 @@ struct ff_t : bf_base<T, N>
}
};
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
template<typename T, uint I, uint N>
struct fmt_unveil<bf_t<T, I, N>, void>
{

View file

@ -48,11 +48,11 @@ namespace cfg
// Config tree entry abstract base class
class _base
{
const type m_type;
const type m_type{};
protected:
bool m_dynamic = true;
const std::string m_name;
const std::string m_name{};
// Ownerless entry constructor
_base(type _type);
@ -65,6 +65,8 @@ namespace cfg
_base& operator=(const _base&) = delete;
virtual ~_base() = default;
// Get type
type get_type() const { return m_type; }
@ -98,7 +100,7 @@ namespace cfg
// Config tree node which contains another nodes
class node : public _base
{
std::vector<_base*> m_nodes;
std::vector<_base*> m_nodes{};
friend class _base;
@ -443,7 +445,7 @@ namespace cfg
// Simple set entry (TODO: template for various types)
class set_entry final : public _base
{
std::set<std::string> m_set;
std::set<std::string> m_set{};
public:
// Default value is empty list in current implementation
@ -479,7 +481,7 @@ namespace cfg
class log_entry final : public _base
{
std::map<std::string, logs::level> m_map;
std::map<std::string, logs::level> m_map{};
public:
log_entry(node* owner, const std::string& name)

View file

@ -210,9 +210,9 @@ namespace fs
class device_manager final
{
mutable shared_mutex m_mutex;
mutable shared_mutex m_mutex{};
std::unordered_map<std::string, std::shared_ptr<device_base>> m_map;
std::unordered_map<std::string, std::shared_ptr<device_base>> m_map{};
public:
std::shared_ptr<device_base> get_device(const std::string& path);
@ -1339,6 +1339,10 @@ fs::file::file(const void* ptr, usz size)
{
}
memory_stream(const memory_stream&) = delete;
memory_stream& operator=(const memory_stream&) = delete;
bool trunc(u64) override
{
return false;
@ -1509,6 +1513,10 @@ bool fs::dir::open(const std::string& path)
{
}
unix_dir(const unix_dir&) = delete;
unix_dir& operator=(const unix_dir&) = delete;
~unix_dir() override
{
::closedir(m_dd);
@ -1843,8 +1851,8 @@ fs::file fs::make_gather(std::vector<fs::file> files)
{
u64 pos = 0;
u64 end = 0;
std::vector<file> files;
std::map<u64, u64> ends; // Fragment End Offset -> Index
std::vector<file> files{};
std::map<u64, u64> ends{}; // Fragment End Offset -> Index
gather_stream(std::vector<fs::file> arg)
: files(std::move(arg))

View file

@ -95,7 +95,7 @@ namespace fs
// Directory entry (TODO)
struct dir_entry : stat_t
{
std::string name;
std::string name{};
dir_entry()
: stat_t{}
@ -198,7 +198,7 @@ namespace fs
class file final
{
std::unique_ptr<file_base> m_file;
std::unique_ptr<file_base> m_file{};
bool strict_read_check(u64 size, u64 type_size) const;
@ -501,7 +501,7 @@ namespace fs
class dir final
{
std::unique_ptr<dir_base> m_dir;
std::unique_ptr<dir_base> m_dir{};
public:
dir() = default;
@ -562,7 +562,7 @@ namespace fs
class iterator
{
const dir* m_parent;
dir_entry m_entry;
dir_entry m_entry{};
public:
enum class mode
@ -590,6 +590,14 @@ namespace fs
}
}
iterator(const iterator&) = default;
iterator(iterator&&) = default;
iterator& operator=(const iterator&) = default;
iterator& operator=(iterator&&) = default;
dir_entry& operator *()
{
return m_entry;
@ -627,7 +635,7 @@ namespace fs
// Unique pending file creation destined to be renamed to the destination file
struct pending_file
{
fs::file file;
fs::file file{};
// This is meant to modify files atomically, overwriting is likely
bool commit(bool overwrite = true);
@ -636,8 +644,8 @@ namespace fs
~pending_file();
private:
std::string m_path; // Pending file path
std::string m_dest; // Destination file path
std::string m_path{}; // Pending file path
std::string m_dest{}; // Destination file path
};
// Get real path for comparisons (TODO: investigate std::filesystem::path::compare implementation)

View file

@ -284,6 +284,7 @@ asmjit::Runtime& asmjit::get_global_runtime()
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Weffc++"
#endif
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/FormattedStream.h"

View file

@ -16,6 +16,7 @@
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Weffc++"
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wduplicated-branches"
#endif
@ -186,6 +187,7 @@ inline FT build_function_asm(F&& builder)
#pragma GCC diagnostic ignored "-Wsuggest-override"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Weffc++"
#ifdef __clang__
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#endif

View file

@ -49,12 +49,12 @@ public:
{
patch_type type = patch_type::load;
u32 offset = 0;
std::string original_value; // Used for import consistency (avoid rounding etc.)
std::string original_value{}; // Used for import consistency (avoid rounding etc.)
union
{
u64 long_value;
f64 double_value;
} value { 0 };
} value{0};
};
using patch_app_versions = std::unordered_map<std::string /*app_version*/, bool /*enabled*/>;
@ -64,25 +64,25 @@ public:
struct patch_info
{
// Patch information
std::vector<patch_data> data_list;
patch_titles titles;
std::string description;
std::string patch_version;
std::string patch_group;
std::string author;
std::string notes;
std::string source_path;
std::vector<patch_data> data_list{};
patch_titles titles{};
std::string description{};
std::string patch_version{};
std::string patch_group{};
std::string author{};
std::string notes{};
std::string source_path{};
// Redundant information for accessibility (see patch_container)
std::string hash;
std::string version;
std::string hash{};
std::string version{};
};
struct patch_container
{
std::unordered_map<std::string /*description*/, patch_info> patch_info_map;
std::string hash;
std::string version;
std::unordered_map<std::string /*description*/, patch_info> patch_info_map{};
std::string hash{};
std::string version{};
};
using patch_map = std::unordered_map<std::string /*hash*/, patch_container>;
@ -140,8 +140,8 @@ public:
private:
// Database
patch_map m_map;
patch_map m_map{};
// Only one patch per patch group can be applied
std::set<std::string> m_applied_groups;
std::set<std::string> m_applied_groups{};
};

View file

@ -315,10 +315,6 @@ public:
auto fetch_or(const bs_t&) = delete;
auto or_fetch(const bs_t&) = delete;
auto operator |=(const bs_t&) = delete;
auto operator ++() = delete;
auto operator --() = delete;
auto operator ++(int) = delete;
auto operator --(int) = delete;
bs_t operator +(bs_t rhs) const
{

View file

@ -18,9 +18,9 @@ class cpu_thread;
class CPUDisAsm
{
protected:
const cpu_disasm_mode m_mode;
const std::add_pointer_t<const u8> m_offset;
const std::add_pointer_t<const cpu_thread> m_cpu;
const cpu_disasm_mode m_mode{};
const std::add_pointer_t<const u8> m_offset{};
const std::add_pointer_t<const cpu_thread> m_cpu{};
u32 m_op = 0;
void Write(const std::string& value)
@ -62,8 +62,8 @@ protected:
}
public:
std::string last_opcode;
u32 dump_pc;
std::string last_opcode{};
u32 dump_pc{};
template <typename T, std::enable_if_t<std::is_base_of_v<CPUDisAsm, T>, int> = 0>
static T copy_and_change_mode(const T& dis, cpu_disasm_mode mode)
@ -79,7 +79,13 @@ protected:
{
}
virtual u32 DisAsmBranchTarget(s32 /*imm*/) { return 0; };
CPUDisAsm(const CPUDisAsm&) = delete;
CPUDisAsm& operator=(const CPUDisAsm&) = delete;
virtual ~CPUDisAsm() = default;
virtual u32 DisAsmBranchTarget(s32 /*imm*/);
// TODO: Add builtin fmt helpper for best performance
template <typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>

View file

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "CPUThread.h"
#include "CPUDisAsm.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
@ -1185,3 +1186,9 @@ void cpu_thread::flush_profilers() noexcept
g_fxo->get<cpu_profiler>().registered.push(0);
}
}
u32 CPUDisAsm::DisAsmBranchTarget(s32 /*imm*/)
{
// Unused
return 0;
}

View file

@ -46,6 +46,9 @@ protected:
cpu_thread(u32 id);
public:
cpu_thread(const cpu_thread&) = delete;
cpu_thread& operator=(const cpu_thread&) = delete;
virtual ~cpu_thread();
void operator()();

View file

@ -11,6 +11,7 @@
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Weffc++"
#endif
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/IRBuilder.h"

View file

@ -33,6 +33,7 @@
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Weffc++"
#endif
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MemoryBuffer.h"

View file

@ -129,6 +129,9 @@ public:
ppu_thread(const ppu_thread_params&, std::string_view name, u32 prio, int detached = 0);
ppu_thread(const ppu_thread&) = delete;
ppu_thread& operator=(const ppu_thread&) = delete;
u64 gpr[32] = {}; // General-Purpose Registers
f64 fpr[32] = {}; // Floating Point Registers
v128 vr[32] = {}; // Vector Registers

View file

@ -3228,6 +3228,7 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out)
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Weffc++"
#endif
#include "llvm/ADT/Triple.h"
#include "llvm/IR/LegacyPassManager.h"

View file

@ -642,6 +642,9 @@ public:
spu_thread(lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated = false, u32 option = 0);
spu_thread(const spu_thread&) = delete;
spu_thread& operator=(const spu_thread&) = delete;
u32 pc = 0;
u32 dbg_step_pc = 0;

View file

@ -172,6 +172,8 @@ struct lv2_fs_object
{
}
virtual ~lv2_fs_object() = default;
static lv2_fs_mount_point* get_mp(std::string_view filename);
static std::array<char, 0x420> get_name(std::string_view filename)

View file

@ -893,11 +893,10 @@ namespace rsx
class atomic_bitmask_t
{
private:
atomic_t<bitmask_type> m_data;
atomic_t<bitmask_type> m_data{0};
public:
atomic_bitmask_t() { m_data.store(0); }
~atomic_bitmask_t() = default;
atomic_bitmask_t() = default;
T load() const
{
@ -988,7 +987,7 @@ namespace rsx
}
}
simple_array(const simple_array<Ty>& other)
simple_array(const simple_array& other)
{
_capacity = other._capacity;
_size = other._size;
@ -998,11 +997,27 @@ namespace rsx
std::memcpy(_data, other._data, size_bytes);
}
simple_array(simple_array<Ty>&& other) noexcept
simple_array(simple_array&& other) noexcept
{
swap(other);
}
simple_array& operator=(const simple_array& other)
{
if (&other != this)
{
simple_array{other}.swap(*this);
}
return *this;
}
simple_array& operator=(simple_array&& other) noexcept
{
swap(other);
return *this;
}
~simple_array()
{
if (_data)

View file

@ -17,18 +17,18 @@
struct vfs_directory
{
// Real path (empty if root or not exists)
std::string path;
std::string path{};
// Virtual subdirectories (vector because only vector allows incomplete types)
std::vector<std::pair<std::string, vfs_directory>> dirs;
std::vector<std::pair<std::string, vfs_directory>> dirs{};
};
struct vfs_manager
{
shared_mutex mutex;
shared_mutex mutex{};
// VFS root
vfs_directory root;
vfs_directory root{};
};
bool vfs::mount(std::string_view vpath, std::string_view path)

View file

@ -783,7 +783,7 @@ namespace
}
// Advance: linearly to prevent self-collisions, but always switch between two big 2^16 chunks
void operator++(int) noexcept
void advance() noexcept
{
if (id >= 0x10000)
{
@ -840,7 +840,7 @@ atomic_t<u16>* root_info::slot_alloc(uptr ptr) noexcept
u32 limit = 0;
for (hash_engine _this(ptr);; _this++)
for (hash_engine _this(ptr);; _this.advance())
{
slot = _this->bits.atomic_op([&](slot_allocator& bits) -> atomic_t<u16>*
{
@ -919,7 +919,7 @@ void root_info::slot_free(uptr iptr, atomic_t<u16>* slot, u32 tls_slot) noexcept
cond_free(cond_id, tls_slot);
}
for (hash_engine curr(iptr);; curr++)
for (hash_engine curr(iptr);; curr.advance())
{
// Reset reference counter and allocation bit in every slot
curr->bits.atomic_op([&](slot_allocator& bits)
@ -945,7 +945,7 @@ FORCE_INLINE auto root_info::slot_search(uptr iptr, u128 mask, F func) noexcept
u32 index = 0;
u32 total = 0;
for (hash_engine _this(iptr);; _this++)
for (hash_engine _this(iptr);; _this.advance())
{
const auto bits = _this->bits.load();

View file

@ -1083,6 +1083,11 @@ struct atomic_storage<T, 16> : atomic_storage<T, 0>
// TODO
};
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
// Atomic type with lock-free and standard layout guarantees (and appropriate limitations)
template <typename T, usz Align = sizeof(T)>
class atomic_t
@ -1710,3 +1715,7 @@ namespace atomic_wait
template <usz Align>
constexpr u128 default_mask<atomic_t<bool, Align>> = 1;
}
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif

View file

@ -4,6 +4,10 @@
#include "Emu/RSX/RSXThread.h"
#include "Emu/RSX/Capture/rsx_capture.h"
#ifndef _MSC_VER
#pragma GCC diagnostic ignored "-Weffc++"
#endif
#include "cereal/archives/binary.hpp"
#include <cereal/types/vector.hpp>
#include <cereal/types/array.hpp>

View file

@ -12,6 +12,22 @@ namespace utils
dynamic_library() = default;
dynamic_library(const std::string& path);
dynamic_library(const dynamic_library&) = delete;
dynamic_library(dynamic_library&& other)
: m_handle(other.m_handle)
{
other.m_handle = nullptr;
}
dynamic_library& operator=(const dynamic_library&) = delete;
dynamic_library& operator=(dynamic_library&& other)
{
std::swap(m_handle, other.m_handle);
return *this;
}
~dynamic_library();
bool load(const std::string& path);

View file

@ -2,6 +2,11 @@
#include "util/types.hpp"
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
namespace stx
{
template <typename T, usz Align = alignof(T), usz Size = sizeof(T)>
@ -467,3 +472,7 @@ public:
}
};
}
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif