Merge pull request #222 from Quuxplusone/fix-warnings

Fix or suppress a bunch of Clang warnings. NFCI.
This commit is contained in:
Zeno Rogue 2021-07-12 00:31:49 +02:00 committed by GitHub
commit 08cbe8e4e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 114 additions and 115 deletions

View File

@ -83,7 +83,7 @@ ifeq (${TOOLCHAIN},clang)
CXXFLAGS_STD = -std=c++11
CXXFLAGS_EARLY += -march=native -fPIC
CXXFLAGS_EARLY += -W -Wall -Wextra -Werror -pedantic
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option
CXXFLAGS_EARLY += -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-unknown-warning-option -Wno-overloaded-virtual
endif
ifeq (${TOOLCHAIN},gcc)

View File

@ -27,9 +27,9 @@ struct supersaver {
virtual void load(const string& s) = 0;
virtual bool dosave() = 0;
virtual void reset() = 0;
virtual ~supersaver() {}
virtual bool affects(void* v) { return false; }
virtual void set_default() = 0;
virtual ~supersaver() = default;
};
typedef vector<shared_ptr<supersaver>> saverlist;
@ -56,7 +56,7 @@ struct setting {
return parameter_name + "|" + config_name + "|" + menu_item_name + "|" + help_text;
}
virtual cld get_cld() = 0;
setting() { restrict = auto_restrict; is_editable = false; }
explicit setting() { restrict = auto_restrict; is_editable = false; }
virtual void check_change() {
cld val = get_cld();
if(val != last_value) {
@ -68,7 +68,7 @@ struct setting {
setting *set_sets(const reaction_t& s) { sets = s; return this; }
setting *set_extra(const reaction_t& r);
setting *set_reaction(const reaction_t& r);
virtual ~setting() {}
virtual ~setting() = default;
virtual void load_from(const string& s) {
println(hlog, "cannot load this parameter");
exit(1);
@ -100,7 +100,7 @@ struct list_setting : setting {
default_key = key;
return this;
}
virtual void show_edit_option(char key) override;
void show_edit_option(char key) override;
};
template<class T> struct enum_setting : list_setting {
@ -108,10 +108,10 @@ template<class T> struct enum_setting : list_setting {
T dft;
int get_value() override { return (int) *value; }
void set_value(int i) override { *value = (T) i; }
virtual bool affects(void* v) override { return v == value; }
virtual void add_as_saver() override;
virtual cld get_cld() override { return get_value(); }
virtual void load_from(const string& s) override {
bool affects(void* v) override { return v == value; }
void add_as_saver() override;
cld get_cld() override { return get_value(); }
void load_from(const string& s) override {
*value = (T) parseint(s);
}
};
@ -134,11 +134,10 @@ struct float_setting : public setting {
function<void(float_setting*)> modify_me;
float_setting *modif(const function<void(float_setting*)>& r) { modify_me = r; return this; }
void add_as_saver() override;
virtual bool affects(void *v) override { return v == value; }
virtual void show_edit_option(char key) override;
virtual cld get_cld() override { return *value; }
virtual void load_from(const string& s) override;
bool affects(void *v) override { return v == value; }
void show_edit_option(char key) override;
cld get_cld() override { return *value; }
void load_from(const string& s) override;
};
struct int_setting : public setting {
@ -149,9 +148,9 @@ struct int_setting : public setting {
void add_as_saver() override;
function<void(int_setting*)> modify_me;
int_setting *modif(const function<void(int_setting*)>& r) { modify_me = r; return this; }
virtual bool affects(void *v) override { return v == value; }
virtual void show_edit_option(char key) override;
virtual cld get_cld() override { return *value; }
bool affects(void *v) override { return v == value; }
void show_edit_option(char key) override;
cld get_cld() override { return *value; }
int_setting *editable(int min_value, int max_value, ld step, string menu_item_name, string help_text, char key) {
this->min_value = min_value;
this->max_value = max_value;
@ -162,7 +161,7 @@ struct int_setting : public setting {
return this;
}
virtual void load_from(const string& s) override {
void load_from(const string& s) override {
*value = parseint(s);
}
};
@ -176,10 +175,10 @@ struct bool_setting : public setting {
is_editable = true;
menu_item_name = cap; default_key = key; return this;
}
virtual bool affects(void *v) override { return v == value; }
virtual void show_edit_option(char key) override;
virtual cld get_cld() override { return *value ? 1 : 0; }
virtual void load_from(const string& s) override {
bool affects(void *v) override { return v == value; }
void show_edit_option(char key) override;
cld get_cld() override { return *value ? 1 : 0; }
void load_from(const string& s) override {
*value = parseint(s);
}
};
@ -188,9 +187,9 @@ struct custom_setting : public setting {
function<void(char)> custom_viewer;
function<cld()> custom_value;
function<bool(void*)> custom_affect;
virtual void show_edit_option(char key) override { custom_viewer(key); }
virtual cld get_cld() override { return custom_value(); }
virtual bool affects(void *v) override { return custom_affect(v); }
void show_edit_option(char key) override { custom_viewer(key); }
cld get_cld() override { return custom_value(); }
bool affects(void *v) override { return custom_affect(v); }
};
#if CAP_CONFIG
@ -198,11 +197,11 @@ struct custom_setting : public setting {
template<class T> struct dsaver : supersaver {
T& val;
T dft;
bool dosave() { return val != dft; }
void reset() { val = dft; }
dsaver(T& val) : val(val) { }
bool affects(void* v) { return v == &val; }
void set_default() { dft = val; }
bool dosave() override { return val != dft; }
void reset() override { val = dft; }
explicit dsaver(T& val) : val(val) { }
bool affects(void* v) override { return v == &val; }
void set_default() override { dft = val; }
};
template<class T> struct saver : dsaver<T> {};
@ -233,13 +232,13 @@ template<class T> void set_saver_default(T& val) {
template<class T> struct saverenum : supersaver {
T& val;
T dft;
bool dosave() { return val != dft; }
void reset() { val = dft; }
saverenum<T>(T& v) : val(v) { }
string save() { return its(int(val)); }
void load(const string& s) { val = (T) atoi(s.c_str()); }
virtual bool affects(void* v) { return v == &val; }
virtual void set_default() { dft = val; }
explicit saverenum(T& v) : val(v) { }
bool dosave() override { return val != dft; }
void reset() override { val = dft; }
string save() override { return its(int(val)); }
void load(const string& s) override { val = (T) atoi(s.c_str()); }
bool affects(void* v) override { return v == &val; }
void set_default() override { dft = val; }
};
template<class T, class U> void addsaverenum(T& i, U name, T dft) {
@ -254,39 +253,39 @@ template<class T, class U> void addsaverenum(T& i, U name) {
}
template<> struct saver<int> : dsaver<int> {
saver<int>(int& val) : dsaver<int>(val) { }
string save() { return its(val); }
void load(const string& s) { val = atoi(s.c_str()); }
explicit saver(int& val) : dsaver<int>(val) { }
string save() override { return its(val); }
void load(const string& s) override { val = atoi(s.c_str()); }
};
template<> struct saver<char> : dsaver<char> {
saver<char>(char& val) : dsaver<char>(val) { }
string save() { return its(val); }
void load(const string& s) { val = atoi(s.c_str()); }
explicit saver(char& val) : dsaver<char>(val) { }
string save() override { return its(val); }
void load(const string& s) override { val = atoi(s.c_str()); }
};
template<> struct saver<bool> : dsaver<bool> {
saver<bool>(bool& val) : dsaver<bool>(val) { }
string save() { return val ? "yes" : "no"; }
void load(const string& s) { val = isize(s) && s[0] == 'y'; }
explicit saver(bool& val) : dsaver<bool>(val) { }
string save() override { return val ? "yes" : "no"; }
void load(const string& s) override { val = isize(s) && s[0] == 'y'; }
};
template<> struct saver<unsigned> : dsaver<unsigned> {
saver<unsigned>(unsigned& val) : dsaver<unsigned>(val) { }
string save() { return itsh(val); }
void load(const string& s) { val = (unsigned) strtoll(s.c_str(), NULL, 16); }
explicit saver(unsigned& val) : dsaver<unsigned>(val) { }
string save() override { return itsh(val); }
void load(const string& s) override { val = (unsigned) strtoll(s.c_str(), NULL, 16); }
};
template<> struct saver<string> : dsaver<string> {
saver<string>(string& val) : dsaver<string>(val) { }
string save() { return val; }
void load(const string& s) { val = s; }
explicit saver(string& val) : dsaver<string>(val) { }
string save() override { return val; }
void load(const string& s) override { val = s; }
};
template<> struct saver<ld> : dsaver<ld> {
saver<ld>(ld& val) : dsaver<ld>(val) { }
string save() { return fts(val, 10); }
void load(const string& s) {
explicit saver(ld& val) : dsaver<ld>(val) { }
string save() override { return fts(val, 10); }
void load(const string& s) override {
if(s == "0.0000000000e+000") ; // ignore!
else val = atof(s.c_str());
}

View File

@ -56,7 +56,7 @@ struct drawqueueitem {
virtual void draw() = 0;
/** \brief Draw the object as background. */
virtual void draw_back() {}
virtual ~drawqueueitem() {}
virtual ~drawqueueitem() = default;
/** \brief When minimizing OpenGL calls, we need to group items of the same color, etc. together. This value is used as an extra sorting key. */
virtual color_t outline_group() = 0;
};
@ -85,12 +85,12 @@ struct dqi_poly : drawqueueitem {
hyperpoint intester;
/** \brief temporarily cached data */
float cache;
void draw();
void draw() override;
#if CAP_GL
void gldraw();
#endif
void draw_back();
virtual color_t outline_group() { return outline; }
void draw_back() override;
color_t outline_group() override { return outline; }
};
/** \brief Drawqueueitem used to draw lines */
@ -101,9 +101,9 @@ struct dqi_line : drawqueueitem {
int prf;
/** \brief width of this line */
double width;
void draw();
void draw_back();
virtual color_t outline_group() { return color; }
void draw() override;
void draw_back() override;
color_t outline_group() override { return color; }
};
/** \brief Drawqueueitem used to draw strings, using sccreen coodinates */
@ -120,8 +120,8 @@ struct dqi_string : drawqueueitem {
int frame;
/** alignment (0-8-16) */
int align;
void draw();
virtual color_t outline_group() { return 1; }
void draw() override;
color_t outline_group() override { return 1; }
};
/** Drawqueueitem used to draw circles, using screen coordinates */
@ -134,16 +134,16 @@ struct dqi_circle : drawqueueitem {
color_t fillcolor;
/** \brief width of the circle */
double linewidth;
void draw();
virtual color_t outline_group() { return 2; }
void draw() override;
color_t outline_group() override { return 2; }
};
/** \brief Perform an arbitrary action. May temporarily change the model, etc. */
struct dqi_action : drawqueueitem {
reaction_t action;
dqi_action(const reaction_t& a) : action(a) {}
void draw() { action(); }
virtual color_t outline_group() { return 2; }
explicit dqi_action(const reaction_t& a) : action(a) {}
void draw() override { action(); }
color_t outline_group() override { return 2; }
};
#endif

View File

@ -122,25 +122,25 @@ struct hstream_exception : hr_exception { hstream_exception() {} };
struct fhstream : hstream {
color_t vernum;
virtual color_t get_vernum() override { return vernum; }
FILE *f;
virtual void write_char(char c) override { write_chars(&c, 1); }
virtual void write_chars(const char* c, size_t i) override { if(fwrite(c, i, 1, f) != 1) throw hstream_exception(); }
virtual void read_chars(char* c, size_t i) override { if(fread(c, i, 1, f) != 1) throw hstream_exception(); }
virtual char read_char() override { char c; read_chars(&c, 1); return c; }
fhstream() { f = NULL; vernum = VERNUM_HEX; }
fhstream(const string pathname, const char *mode) { f = fopen(pathname.c_str(), mode); vernum = VERNUM_HEX; }
explicit fhstream() { f = NULL; vernum = VERNUM_HEX; }
explicit fhstream(const string pathname, const char *mode) { f = fopen(pathname.c_str(), mode); vernum = VERNUM_HEX; }
~fhstream() { if(f) fclose(f); }
color_t get_vernum() override { return vernum; }
void write_char(char c) override { write_chars(&c, 1); }
void write_chars(const char* c, size_t i) override { if(fwrite(c, i, 1, f) != 1) throw hstream_exception(); }
void read_chars(char* c, size_t i) override { if(fread(c, i, 1, f) != 1) throw hstream_exception(); }
char read_char() override { char c; read_chars(&c, 1); return c; }
};
struct shstream : hstream {
color_t vernum;
virtual color_t get_vernum() override { return vernum; }
string s;
int pos;
shstream(const string& t = "") : s(t) { pos = 0; vernum = VERNUM_HEX; }
virtual void write_char(char c) override { s += c; }
virtual char read_char() override { if(pos == isize(s)) throw hstream_exception(); return s[pos++]; }
explicit shstream(const string& t = "") : s(t) { pos = 0; vernum = VERNUM_HEX; }
color_t get_vernum() override { return vernum; }
void write_char(char c) override { s += c; }
char read_char() override { if(pos == isize(s)) throw hstream_exception(); return s[pos++]; }
};
inline void print(hstream& hs) {}
@ -243,11 +243,11 @@ int SDL_GetTicks();
struct logger : hstream {
int indentation;
bool doindent;
logger() { doindent = false; }
virtual void write_char(char c) { if(doindent) { doindent = false;
explicit logger() { doindent = false; }
void write_char(char c) override { if(doindent) { doindent = false;
if(debugflags & DF_TIME) { int t = SDL_GetTicks(); if(t < 0) t = 999999; t %= 1000000; string s = its(t); while(isize(s) < 6) s = "0" + s; for(char c: s) special_log(c); special_log(' '); }
for(int i=0; i<indentation; i++) special_log(' '); } special_log(c); if(c == 10) doindent = true; if(c == 10 && debugfile) fflush(debugfile); }
virtual char read_char() { throw hstream_exception(); }
char read_char() override { throw hstream_exception(); }
};
extern logger hlog;
@ -278,11 +278,11 @@ inline void print(hstream& hs, cellwalker cw) {
struct indenter {
dynamicval<int> ind;
indenter(int i = 2) : ind(hlog.indentation, hlog.indentation + (i)) {}
explicit indenter(int i = 2) : ind(hlog.indentation, hlog.indentation + (i)) {}
};
struct indenter_finish : indenter {
indenter_finish(bool b = true): indenter(b ? 2:0) {}
explicit indenter_finish(bool b = true): indenter(b ? 2:0) {}
~indenter_finish() { if(hlog.indentation != ind.backup) println(hlog, "(done)"); }
};

View File

@ -19,10 +19,10 @@ template<class T, class R, class... Args>
struct function_state : function_state_base<R, Args...> {
T t_;
explicit function_state(T t) : t_(std::move(t)) {}
R call(Args... args) const /*override*/ {
R call(Args... args) const override {
return const_cast<T&>(t_)(static_cast<Args&&>(args)...);
}
function_state_base<R, Args...> *clone() const /*override*/ {
function_state_base<R, Args...> *clone() const override {
return new function_state(*this);
}
};

View File

@ -21,7 +21,7 @@ EX namespace inforder {
struct hrmap_inforder : hrmap_hyperbolic {
heptagon *create_step(heptagon *h, int direction) {
heptagon *create_step(heptagon *h, int direction) override {
int deg = h->type;
if(mixed()) deg = 7 - deg;
auto h1 = init_heptagon(deg);
@ -51,4 +51,4 @@ EX namespace inforder {
EX }
}
}

View File

@ -339,7 +339,7 @@ struct hrmap_kite : hrmap {
return gm * where;
}
virtual int wall_offset(cell *c) {
int wall_offset(cell *c) override {
if(WDIM == 3)
return kite::getshape(c->master) == kite::pKite ? 10 : 0;
else
@ -426,4 +426,4 @@ auto hooksw = addHook(hooks_swapdim, 100, [] { if(kite::in() && currentmap) kite
#endif
}}

View File

@ -664,10 +664,10 @@ EX namespace patterns {
si.reflect = false;
}
else {
int ids = 0, tids = 0, td = 0;
int ids = 0, td = 0;
for(int i=0; i<S3; i++) {
int d = c->move(2*i)->master->fieldval;
ids |= (1<<d); tids += d;
ids |= (1<<d);
}
for(int i=0; i<S3; i++) {
int d = c->move(2*i)->master->fieldval;

View File

@ -64,16 +64,16 @@ struct hrmap_quotient : hrmap_standard {
void build();
hrmap_quotient() {
explicit hrmap_quotient() {
generate_connections();
build();
}
hrmap_quotient(const vector<int>& con) : connections(con) {
explicit hrmap_quotient(const vector<int>& con) : connections(con) {
build();
}
heptagon *getOrigin() { return allh[0]; }
heptagon *getOrigin() override { return allh[0]; }
~hrmap_quotient() {
for(int i=0; i<isize(allh); i++) {
@ -82,7 +82,7 @@ struct hrmap_quotient : hrmap_standard {
}
}
vector<cell*>& allcells() { return celllist; }
vector<cell*>& allcells() override { return celllist; }
};
#endif

View File

@ -649,7 +649,7 @@ EX namespace reg3 {
int h_id;
/** transition matrix to that heptagon */
transmatrix T;
/** the sequence of moves we need to make to get there */;
/** the sequence of moves we need to make to get there */
vector<int> move_sequence;
};
@ -680,7 +680,7 @@ EX namespace reg3 {
return cgi.subshapes[id].vertices_only_local;
}
transmatrix master_relative(cell *c, bool get_inverse) {
transmatrix master_relative(cell *c, bool get_inverse) override {
int id = local_id.at(c).second;
auto& ss = cgi.subshapes[id];
return get_inverse ? ss.from_cellcenter : ss.to_cellcenter;
@ -689,11 +689,11 @@ EX namespace reg3 {
void make_subconnections();
int wall_offset(cell *c) override;
int shvid(cell *c) { return local_id.at(c).second; }
int shvid(cell *c) override { return local_id.at(c).second; }
virtual transmatrix ray_iadj(cell *c, int i) override;
transmatrix ray_iadj(cell *c, int i) override;
const vector<bool>& adjacent_dirs(cell *c, int i) {
const vector<bool>& adjacent_dirs(cell *c, int i) override {
int id = local_id.at(c).second;
return cgi.subshapes[id].dirs_adjacent[i];
}
@ -1490,7 +1490,7 @@ EX namespace reg3 {
return cgi.vertices_only;
}
const vector<bool>& adjacent_dirs(cell *c, int i) {
const vector<bool>& adjacent_dirs(cell *c, int i) override {
return cgi.dirs_adjacent[i];
}
@ -1582,7 +1582,7 @@ EX namespace reg3 {
clearfrom(allh[0]);
}
virtual struct transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
struct transmatrix relative_matrix(heptagon *h2, heptagon *h1, const hyperpoint& hint) override {
return iso_inverse(locations[h1->fieldval]) * locations[h2->fieldval];
}
@ -1901,13 +1901,13 @@ EX namespace reg3 {
return relative_matrix_via_masters(c2, c1, hint);
}
transmatrix master_relative(cell *c, bool get_inverse) {
transmatrix master_relative(cell *c, bool get_inverse) override {
if(PURE) return Id;
int aid = cell_id.at(c);
return quotient_map->master_relative(quotient_map->acells[aid], get_inverse);
}
int shvid(cell *c) {
int shvid(cell *c) override {
if(PURE) return 0;
if(!cell_id.count(c)) return quotient_map->shvid(c);
int aid = cell_id.at(c);
@ -1963,14 +1963,14 @@ EX namespace reg3 {
c->c.connect(d, c1, ac->c.spin(d), false);
}
virtual transmatrix ray_iadj(cell *c, int i) {
transmatrix ray_iadj(cell *c, int i) override {
if(PURE) return iadj(c, i);
if(!cell_id.count(c)) return quotient_map->ray_iadj(c, i); /* necessary because ray samples are from quotient_map */
int aid = cell_id.at(c);
return quotient_map->ray_iadj(quotient_map->acells[aid], i);
}
const vector<bool>& adjacent_dirs(cell *c, int i) {
const vector<bool>& adjacent_dirs(cell *c, int i) override {
if(PURE) return cgi.dirs_adjacent[i];
int aid = cell_id.at(c);
return quotient_map->adjacent_dirs(quotient_map->acells[aid], i);

View File

@ -24,11 +24,11 @@ struct sky_item {
struct dqi_sky : drawqueueitem {
vector<sky_item> sky;
void draw();
virtual color_t outline_group() { return 3; }
void draw() override;
color_t outline_group() override { return 3; }
// singleton
dqi_sky() { hr::sky = this; }
~dqi_sky() { hr::sky = NULL; }
explicit dqi_sky() { hr::sky = this; }
~dqi_sky() override { hr::sky = NULL; }
};
EX struct dqi_sky *sky;

View File

@ -139,14 +139,14 @@ struct hrmap_spherical : hrmap_standard {
#endif
}
heptagon *getOrigin() { return dodecahedron[0]; }
heptagon *getOrigin() override { return dodecahedron[0]; }
~hrmap_spherical() {
for(int i=0; i<spherecells(); i++) clearHexes(dodecahedron[i]);
for(int i=0; i<spherecells(); i++) tailored_delete(dodecahedron[i]);
}
void verify() {
void verify() override {
for(int i=0; i<spherecells(); i++) for(int k=0; k<S7; k++) {
heptspin hs(dodecahedron[i], k, false);
heptspin hs2 = hs + wstep + (S7-1) + wstep + (S7-1) + wstep + (S7-1);
@ -172,7 +172,7 @@ struct hrmap_spherical : hrmap_standard {
return Id;
}
transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) {
transmatrix relative_matrix(cell *c2, cell *c1, const hyperpoint& hint) override {
transmatrix T = iso_inverse(get_where(c1)) * get_where(c2);
if(elliptic) fixelliptic(T);
return T;