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
{