diff --git a/Utilities/BitField.h b/Utilities/BitField.h index 8c3536e745..189c631fa1 100644 --- a/Utilities/BitField.h +++ b/Utilities/BitField.h @@ -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 struct bf_base { @@ -250,6 +255,10 @@ struct ff_t : bf_base } }; +#ifndef _MSC_VER +#pragma GCC diagnostic pop +#endif + template struct fmt_unveil, void> { diff --git a/Utilities/Config.h b/Utilities/Config.h index d79095d73e..1cdd2063b2 100644 --- a/Utilities/Config.h +++ b/Utilities/Config.h @@ -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 m_set; + std::set 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 m_map; + std::map m_map{}; public: log_entry(node* owner, const std::string& name) diff --git a/Utilities/File.cpp b/Utilities/File.cpp index a790bc5308..2fc9797a41 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -210,9 +210,9 @@ namespace fs class device_manager final { - mutable shared_mutex m_mutex; + mutable shared_mutex m_mutex{}; - std::unordered_map> m_map; + std::unordered_map> m_map{}; public: std::shared_ptr 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 files) { u64 pos = 0; u64 end = 0; - std::vector files; - std::map ends; // Fragment End Offset -> Index + std::vector files{}; + std::map ends{}; // Fragment End Offset -> Index gather_stream(std::vector arg) : files(std::move(arg)) diff --git a/Utilities/File.h b/Utilities/File.h index f17671c9d0..69d85fcfc6 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -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 m_file; + std::unique_ptr m_file{}; bool strict_read_check(u64 size, u64 type_size) const; @@ -501,7 +501,7 @@ namespace fs class dir final { - std::unique_ptr m_dir; + std::unique_ptr 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) diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index f73263e937..f6be381a7f 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -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" diff --git a/Utilities/JIT.h b/Utilities/JIT.h index e520a2ae4b..5c6a5f8c09 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -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 diff --git a/Utilities/bin_patch.h b/Utilities/bin_patch.h index d8de70e5da..463e83f304 100644 --- a/Utilities/bin_patch.h +++ b/Utilities/bin_patch.h @@ -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; @@ -64,25 +64,25 @@ public: struct patch_info { // Patch information - std::vector 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 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 patch_info_map; - std::string hash; - std::string version; + std::unordered_map patch_info_map{}; + std::string hash{}; + std::string version{}; }; using patch_map = std::unordered_map; @@ -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 m_applied_groups; + std::set m_applied_groups{}; }; diff --git a/Utilities/bit_set.h b/Utilities/bit_set.h index 1dc53f4bdb..3fd3ef2270 100644 --- a/Utilities/bit_set.h +++ b/Utilities/bit_set.h @@ -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 { diff --git a/rpcs3/Emu/CPU/CPUDisAsm.h b/rpcs3/Emu/CPU/CPUDisAsm.h index 5358a41707..259a71416b 100644 --- a/rpcs3/Emu/CPU/CPUDisAsm.h +++ b/rpcs3/Emu/CPU/CPUDisAsm.h @@ -18,9 +18,9 @@ class cpu_thread; class CPUDisAsm { protected: - const cpu_disasm_mode m_mode; - const std::add_pointer_t m_offset; - const std::add_pointer_t m_cpu; + const cpu_disasm_mode m_mode{}; + const std::add_pointer_t m_offset{}; + const std::add_pointer_t 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 , 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 , int> = 0> diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 978b658403..4f8eb19409 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -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().registered.push(0); } } + +u32 CPUDisAsm::DisAsmBranchTarget(s32 /*imm*/) +{ + // Unused + return 0; +} diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 18e5e92ad6..02fcd7b192 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -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()(); diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 4e953340d7..3fbefbf317 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -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" diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 0a4c4b9f43..3cf4eb0b92 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -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" diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index a2db5eb551..b3e6d4b3f4 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -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 diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index e7b2df4662..21d0b3be97 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -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" diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index faf928c005..3622b01a5f 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -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; diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 7ad2da538a..a51d9b9251 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -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 get_name(std::string_view filename) diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index f81292eb98..01acca7d07 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -893,11 +893,10 @@ namespace rsx class atomic_bitmask_t { private: - atomic_t m_data; + atomic_t 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& 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&& 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) diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index 9975d46e4e..9303906b60 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -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> dirs; + std::vector> 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) diff --git a/rpcs3/util/atomic.cpp b/rpcs3/util/atomic.cpp index d11d9218b0..b47c575e68 100644 --- a/rpcs3/util/atomic.cpp +++ b/rpcs3/util/atomic.cpp @@ -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* 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* { @@ -919,7 +919,7 @@ void root_info::slot_free(uptr iptr, atomic_t* 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(); diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index 83b8a38e7c..1eeddab5ee 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -1083,6 +1083,11 @@ struct atomic_storage : atomic_storage // 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 class atomic_t @@ -1710,3 +1715,7 @@ namespace atomic_wait template constexpr u128 default_mask> = 1; } + +#ifndef _MSC_VER +#pragma GCC diagnostic pop +#endif diff --git a/rpcs3/util/cereal.cpp b/rpcs3/util/cereal.cpp index 750ae334f3..221f8db4f9 100644 --- a/rpcs3/util/cereal.cpp +++ b/rpcs3/util/cereal.cpp @@ -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 #include diff --git a/rpcs3/util/dyn_lib.hpp b/rpcs3/util/dyn_lib.hpp index ccee7b8e4f..75c676ad21 100644 --- a/rpcs3/util/dyn_lib.hpp +++ b/rpcs3/util/dyn_lib.hpp @@ -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); diff --git a/rpcs3/util/endian.hpp b/rpcs3/util/endian.hpp index 42f56c77b9..c8f99f431f 100644 --- a/rpcs3/util/endian.hpp +++ b/rpcs3/util/endian.hpp @@ -2,6 +2,11 @@ #include "util/types.hpp" +#ifndef _MSC_VER +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#endif + namespace stx { template @@ -467,3 +472,7 @@ public: } }; } + +#ifndef _MSC_VER +#pragma GCC diagnostic pop +#endif