From 64c70366607b284ca1a253a797429ade2711182c Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 27 Jul 2016 10:10:50 +0200 Subject: [PATCH] active -Wsuggest-override where supported * m4/gccwarn.m4: Add the option. * bin/autfilt.cc, bin/common_output.hh, bin/dstar2tgba.cc, bin/ltl2tgba.cc, bin/ltl2tgta.cc, bin/ltlcross.cc, bin/ltldo.cc, bin/ltlfilt.cc, bin/ltlgrind.cc, spot/kripke/kripke.hh, spot/ltsmin/ltsmin.cc, spot/ta/ta.hh, spot/ta/tgtaproduct.hh, spot/taalgos/dot.cc, spot/taalgos/reachiter.hh, spot/taalgos/statessetbuilder.cc, spot/taalgos/stats.cc, spot/twa/twaproduct.cc, spot/twaalgos/emptiness.cc, spot/twaalgos/gtec/ce.cc, spot/twaalgos/lbtt.cc, spot/twaalgos/ndfs_result.hxx, spot/twaalgos/stats.hh, spot/twaalgos/tau03opt.cc, tests/core/ngraph.cc: Add suggested override qualifiers. --- bin/autfilt.cc | 4 ++-- bin/common_output.hh | 6 +++--- bin/dstar2tgba.cc | 4 ++-- bin/ltl2tgba.cc | 2 +- bin/ltl2tgta.cc | 2 +- bin/ltlcross.cc | 4 ++-- bin/ltldo.cc | 4 ++-- bin/ltlfilt.cc | 4 ++-- bin/ltlgrind.cc | 2 +- m4/gccwarn.m4 | 3 ++- spot/kripke/kripke.hh | 3 ++- spot/ltsmin/ltsmin.cc | 20 ++++++++++---------- spot/ta/ta.hh | 4 ---- spot/ta/tgtaproduct.hh | 16 ++++++---------- spot/taalgos/dot.cc | 8 ++++---- spot/taalgos/reachiter.hh | 12 ++++-------- spot/taalgos/statessetbuilder.cc | 4 ++-- spot/taalgos/stats.cc | 4 ++-- spot/twa/twaproduct.cc | 22 +++++++++++----------- spot/twaalgos/emptiness.cc | 4 ++-- spot/twaalgos/gtec/ce.cc | 4 ++-- spot/twaalgos/lbtt.cc | 6 +++--- spot/twaalgos/ndfs_result.hxx | 15 ++++++++------- spot/twaalgos/stats.hh | 4 ++-- spot/twaalgos/tau03opt.cc | 4 ++-- tests/core/ngraph.cc | 13 ++++++------- 26 files changed, 84 insertions(+), 94 deletions(-) diff --git a/bin/autfilt.cc b/bin/autfilt.cc index 84908b300..691c265ed 100644 --- a/bin/autfilt.cc +++ b/bin/autfilt.cc @@ -813,7 +813,7 @@ namespace } int - process_formula(spot::formula, const char*, int) + process_formula(spot::formula, const char*, int) override { SPOT_UNREACHABLE(); } @@ -1066,7 +1066,7 @@ namespace } int - process_file(const char* filename) + process_file(const char* filename) override { auto hp = spot::automaton_stream_parser(filename, opt_parse); int err = 0; diff --git a/bin/common_output.hh b/bin/common_output.hh index 7b40db048..4c1fc0b7b 100644 --- a/bin/common_output.hh +++ b/bin/common_output.hh @@ -1,6 +1,6 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2012, 2013, 2014, 2015 Laboratoire de Recherche et -// Développement de l'Epita (LRDE). +// Copyright (C) 2012, 2013, 2014, 2015, 2016 Laboratoire de Recherche +// et Développement de l'Epita (LRDE). // // This file is part of Spot, a model checking library. // @@ -63,7 +63,7 @@ public: } virtual void - print(std::ostream& os, const char*) const; + print(std::ostream& os, const char*) const override; }; class aut_stat_printer: protected spot::stat_printer diff --git a/bin/dstar2tgba.cc b/bin/dstar2tgba.cc index ec51b5743..c687bcac5 100644 --- a/bin/dstar2tgba.cc +++ b/bin/dstar2tgba.cc @@ -118,7 +118,7 @@ namespace } int - process_formula(spot::formula, const char*, int) + process_formula(spot::formula, const char*, int) override { SPOT_UNREACHABLE(); } @@ -146,7 +146,7 @@ namespace } int - process_file(const char* filename) + process_file(const char* filename) override { auto hp = spot::automaton_stream_parser(filename, opt_parse); int err = 0; diff --git a/bin/ltl2tgba.cc b/bin/ltl2tgba.cc index 7096bbc35..d1c1992ab 100644 --- a/bin/ltl2tgba.cc +++ b/bin/ltl2tgba.cc @@ -125,7 +125,7 @@ namespace int process_formula(spot::formula f, - const char* filename = nullptr, int linenum = 0) + const char* filename = nullptr, int linenum = 0) override { // This should not happen, because the parser we use can only // read PSL/LTL formula, but since our formula type can diff --git a/bin/ltl2tgta.cc b/bin/ltl2tgta.cc index 68c3b934c..469344e2b 100644 --- a/bin/ltl2tgta.cc +++ b/bin/ltl2tgta.cc @@ -175,7 +175,7 @@ namespace int process_formula(spot::formula f, - const char* filename = nullptr, int linenum = 0) + const char* filename = nullptr, int linenum = 0) override { auto aut = trans.run(&f); diff --git a/bin/ltlcross.cc b/bin/ltlcross.cc index b9beaf8ad..2ddc8be13 100644 --- a/bin/ltlcross.cc +++ b/bin/ltlcross.cc @@ -826,7 +826,7 @@ namespace int process_string(const std::string& input, const char* filename, - int linenum) + int linenum) override { auto pf = parse_formula(input); if (!pf.f || !pf.errors.empty()) @@ -928,7 +928,7 @@ namespace int process_formula(spot::formula f, - const char* filename = nullptr, int linenum = 0) + const char* filename = nullptr, int linenum = 0) override { static unsigned round = 0; diff --git a/bin/ltldo.cc b/bin/ltldo.cc index 313858ebb..c9e69776f 100644 --- a/bin/ltldo.cc +++ b/bin/ltldo.cc @@ -274,7 +274,7 @@ namespace int process_string(const std::string& input, const char* filename, - int linenum) + int linenum) override { spot::parsed_formula pf = parse_formula(input); @@ -294,7 +294,7 @@ namespace int process_formula(spot::formula f, - const char* filename = nullptr, int linenum = 0) + const char* filename = nullptr, int linenum = 0) override { std::unique_ptr relmap; diff --git a/bin/ltlfilt.cc b/bin/ltlfilt.cc index dd3c1c35f..18682b9a1 100644 --- a/bin/ltlfilt.cc +++ b/bin/ltlfilt.cc @@ -515,7 +515,7 @@ namespace int process_string(const std::string& input, - const char* filename = nullptr, int linenum = 0) + const char* filename = nullptr, int linenum = 0) override { spot::parsed_formula pf = parse_formula(input); @@ -548,7 +548,7 @@ namespace int process_formula(spot::formula f, - const char* filename = nullptr, int linenum = 0) + const char* filename = nullptr, int linenum = 0) override { if (opt_max_count >= 0 && match_count >= opt_max_count) { diff --git a/bin/ltlgrind.cc b/bin/ltlgrind.cc index 978000125..76dac8373 100644 --- a/bin/ltlgrind.cc +++ b/bin/ltlgrind.cc @@ -113,7 +113,7 @@ namespace public: int process_formula(spot::formula f, const char* filename = nullptr, - int linenum = 0) + int linenum = 0) override { auto mutations = spot::mutate(f, mut_opts, max_output, mutation_nb, opt_sort); diff --git a/m4/gccwarn.m4 b/m4/gccwarn.m4 index 0198a1720..bfb3da957 100644 --- a/m4/gccwarn.m4 +++ b/m4/gccwarn.m4 @@ -39,7 +39,8 @@ EOF Wmisleading-indentation \ Wlogical-op \ Wduplicated-cond \ - Wnull-dereference + Wnull-dereference \ + Wsuggest-override do CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$cf_opt" if AC_TRY_EVAL(ac_compile); then diff --git a/spot/kripke/kripke.hh b/spot/kripke/kripke.hh index 5c710da5c..9f6ed10c4 100644 --- a/spot/kripke/kripke.hh +++ b/spot/kripke/kripke.hh @@ -97,7 +97,8 @@ namespace spot virtual ~kripke(); - virtual acc_cond::mark_t state_acceptance_conditions(const state*) const; + virtual + acc_cond::mark_t state_acceptance_conditions(const state*) const override; }; typedef std::shared_ptr kripke_ptr; diff --git a/spot/ltsmin/ltsmin.cc b/spot/ltsmin/ltsmin.cc index 86f6f14f2..6a0c85364 100644 --- a/spot/ltsmin/ltsmin.cc +++ b/spot/ltsmin/ltsmin.cc @@ -84,7 +84,7 @@ namespace spot //////////////////////////////////////////////////////////////////////// // STATE - struct spins_state: public state + struct spins_state final: public state { spins_state(int s, fixed_size_pool* p) : pool(p), size(s), count(1) @@ -98,25 +98,25 @@ namespace spot hash_value = wang32_hash(hash_value ^ vars[i]); } - spins_state* clone() const + spins_state* clone() const override { ++count; return const_cast(this); } - void destroy() const + void destroy() const override { if (--count) return; pool->deallocate(this); } - size_t hash() const + size_t hash() const override { return hash_value; } - int compare(const state* other) const + int compare(const state* other) const override { if (this == other) return 0; @@ -143,7 +143,7 @@ namespace spot int vars[0]; }; - struct spins_compressed_state: public state + struct spins_compressed_state final: public state { spins_compressed_state(int s, multiple_size_pool* p) : pool(p), size(s), count(1) @@ -157,25 +157,25 @@ namespace spot hash_value = wang32_hash(hash_value ^ vars[i]); } - spins_compressed_state* clone() const + spins_compressed_state* clone() const override { ++count; return const_cast(this); } - void destroy() const + void destroy() const override { if (--count) return; pool->deallocate(this, sizeof(*this) + size * sizeof(*vars)); } - size_t hash() const + size_t hash() const override { return hash_value; } - int compare(const state* other) const + int compare(const state* other) const override { if (this == other) return 0; diff --git a/spot/ta/ta.hh b/spot/ta/ta.hh index 5a4916bcd..e790f920f 100644 --- a/spot/ta/ta.hh +++ b/spot/ta/ta.hh @@ -201,10 +201,6 @@ namespace spot ~ta_succ_iterator() { } - /// \brief Get the changeset on the transition leading to current successor. - /// - /// This is a boolean function of atomic propositions. - virtual bdd cond() const = 0; }; #ifndef SWIG diff --git a/spot/ta/tgtaproduct.hh b/spot/ta/tgtaproduct.hh index e1bb5d947..d6adea188 100644 --- a/spot/ta/tgtaproduct.hh +++ b/spot/ta/tgtaproduct.hh @@ -60,18 +60,14 @@ namespace spot ~tgta_succ_iterator_product(); // iteration - bool first(); - bool next(); - bool done() const; + bool first() override; + bool next() override; + bool done() const override; // inspection - state_product* - dst() const; - bdd - cond() const; - - acc_cond::mark_t - acc() const; + state_product* dst() const override; + bdd cond() const override; + acc_cond::mark_t acc() const override; private: //@{ diff --git a/spot/taalgos/dot.cc b/spot/taalgos/dot.cc index fe5c9ec83..c6a612218 100644 --- a/spot/taalgos/dot.cc +++ b/spot/taalgos/dot.cc @@ -141,7 +141,7 @@ namespace spot } void - start() + start() override { os_ << "digraph G {\n"; @@ -198,13 +198,13 @@ namespace spot } void - end() + end() override { os_ << '}' << std::endl; } void - process_state(const state* s, int n) + process_state(const state* s, int n) override { std::string style; @@ -223,7 +223,7 @@ namespace spot } void - process_link(int in, int out, const ta_succ_iterator* si) + process_link(int in, int out, const ta_succ_iterator* si) override { bdd_dict_ptr d = t_automata_->get_dict(); std::string label = diff --git a/spot/taalgos/reachiter.hh b/spot/taalgos/reachiter.hh index 91cd6a668..448aac65d 100644 --- a/spot/taalgos/reachiter.hh +++ b/spot/taalgos/reachiter.hh @@ -100,10 +100,8 @@ namespace spot public: ta_reachable_iterator_depth_first(const const_ta_ptr& a); - virtual void - add_state(const state* s); - virtual const state* - next_state(); + virtual void add_state(const state* s) override; + virtual const state* next_state() override; protected: std::stack todo; ///< A stack of states yet to explore. @@ -118,10 +116,8 @@ namespace spot public: ta_reachable_iterator_breadth_first(const const_ta_ptr& a); - virtual void - add_state(const state* s); - virtual const state* - next_state(); + virtual void add_state(const state* s) override; + virtual const state* next_state() override; protected: std::deque todo; ///< A queue of states yet to explore. diff --git a/spot/taalgos/statessetbuilder.cc b/spot/taalgos/statessetbuilder.cc index 061376996..7e1a611d2 100644 --- a/spot/taalgos/statessetbuilder.cc +++ b/spot/taalgos/statessetbuilder.cc @@ -36,13 +36,13 @@ namespace spot } void - process_state(const state* s, int) + process_state(const state* s, int) override { states_set_.insert(s); } void - process_link(int, int, const ta_succ_iterator*) + process_link(int, int, const ta_succ_iterator*) override { } diff --git a/spot/taalgos/stats.cc b/spot/taalgos/stats.cc index c2a7087e9..f7851834c 100644 --- a/spot/taalgos/stats.cc +++ b/spot/taalgos/stats.cc @@ -38,7 +38,7 @@ namespace spot } void - process_state(const state* s, int) + process_state(const state* s, int) override { ++s_.states; if (t_automata_->is_accepting_state(s) @@ -47,7 +47,7 @@ namespace spot } void - process_link(int, int, const ta_succ_iterator*) + process_link(int, int, const ta_succ_iterator*) override { ++s_.edges; } diff --git a/spot/twa/twaproduct.cc b/spot/twa/twaproduct.cc index 03957aed1..a124b43fa 100644 --- a/spot/twa/twaproduct.cc +++ b/spot/twa/twaproduct.cc @@ -107,7 +107,7 @@ namespace spot virtual bool next_non_false_() = 0; - bool first() + bool first() override { if (!right_) return false; @@ -125,12 +125,12 @@ namespace spot return next_non_false_(); } - bool done() const + bool done() const override { return !right_ || right_->done(); } - const state_product* dst() const + const state_product* dst() const override { return new(pool_->allocate()) state_product(left_->dst(), right_->dst(), @@ -171,7 +171,7 @@ namespace spot return right_->next(); } - bool next_non_false_() + bool next_non_false_() override { assert(!done()); do @@ -190,19 +190,19 @@ namespace spot return false; } - bool next() + bool next() override { if (step_()) return next_non_false_(); return false; } - bdd cond() const + bdd cond() const override { return current_cond_; } - acc_cond::mark_t acc() const + acc_cond::mark_t acc() const override { return left_->acc() | (right_->acc() << prod_->left_acc().num_sets()); } @@ -229,7 +229,7 @@ namespace spot { } - bool next_non_false_() + bool next_non_false_() override { // All the transitions of left_ iterator have the // same label, because it is a Kripke structure. @@ -250,7 +250,7 @@ namespace spot return false; } - bool next() + bool next() override { if (left_->next()) return true; @@ -260,12 +260,12 @@ namespace spot return false; } - bdd cond() const + bdd cond() const override { return current_cond_; } - acc_cond::mark_t acc() const + acc_cond::mark_t acc() const override { return right_->acc(); } diff --git a/spot/twaalgos/emptiness.cc b/spot/twaalgos/emptiness.cc index b7c92e290..07cbe2716 100644 --- a/spot/twaalgos/emptiness.cc +++ b/spot/twaalgos/emptiness.cc @@ -313,7 +313,7 @@ namespace spot } const state* - filter(const state* s) + filter(const state* s) override { state_set::const_iterator i = seen.find(s); if (i == seen.end()) @@ -327,7 +327,7 @@ namespace spot } bool - match(twa_run::step&, const state* dest) + match(twa_run::step&, const state* dest) override { return target->find(dest) != target->end(); } diff --git a/spot/twaalgos/gtec/ce.cc b/spot/twaalgos/gtec/ce.cc index 443c11227..66aae9b9d 100644 --- a/spot/twaalgos/gtec/ce.cc +++ b/spot/twaalgos/gtec/ce.cc @@ -45,7 +45,7 @@ namespace spot } const state* - filter(const state* s) + filter(const state* s) override { r->inc_ars_prefix_states(); auto i = ecs->h.find(s); @@ -60,7 +60,7 @@ namespace spot } bool - match(twa_run::step&, const state* dest) + match(twa_run::step&, const state* dest) override { return target->find(dest) != target->end(); } diff --git a/spot/twaalgos/lbtt.cc b/spot/twaalgos/lbtt.cc index db05044d9..389de45bf 100644 --- a/spot/twaalgos/lbtt.cc +++ b/spot/twaalgos/lbtt.cc @@ -74,7 +74,7 @@ namespace spot void - process_state(const state* s, int n, twa_succ_iterator*) + process_state(const state* s, int n, twa_succ_iterator*) override { --n; if (n == 0) @@ -93,7 +93,7 @@ namespace spot void process_link(const state*, int, - const state*, int out, const twa_succ_iterator* si) + const state*, int out, const twa_succ_iterator* si) override { body_ << out - 1 << ' '; if (!sba_format_) @@ -107,7 +107,7 @@ namespace spot } void - end() + end() override { os_ << seen.size() << ' '; if (sba_format_) diff --git a/spot/twaalgos/ndfs_result.hxx b/spot/twaalgos/ndfs_result.hxx index 53c025f7c..2cfb67fb6 100644 --- a/spot/twaalgos/ndfs_result.hxx +++ b/spot/twaalgos/ndfs_result.hxx @@ -398,7 +398,7 @@ namespace spot return nullptr; } - const state* filter(const state* s) + const state* filter(const state* s) override { if (!h.has_been_visited(s) || seen.find(s) != seen.end() @@ -412,9 +412,10 @@ namespace spot return s; } - void finalize(const std::map&, - const twa_run::step&, const state*, twa_run::steps&) + void + finalize(const std::map&, + const twa_run::step&, const state*, twa_run::steps&) override { } @@ -423,7 +424,7 @@ namespace spot return seen; } - bool match(twa_run::step&, const state* dest) + bool match(twa_run::step&, const state* dest) override { return target->compare(dest) == 0; } @@ -493,7 +494,7 @@ namespace spot return nullptr; } - const state* filter(const state* s) + const state* filter(const state* s) override { ndfsr_trace << "filter: " << a_->format_state(s); if (!h.has_been_visited(s) || seen.find(s) != seen.end()) @@ -514,7 +515,7 @@ namespace spot return s; } - bool match(twa_run::step&, const state* dest) + bool match(twa_run::step&, const state* dest) override { ndfsr_trace << "match: " << a_->format_state(dest) << std::endl; diff --git a/spot/twaalgos/stats.hh b/spot/twaalgos/stats.hh index 30932c8bb..688d5c3b7 100644 --- a/spot/twaalgos/stats.hh +++ b/spot/twaalgos/stats.hh @@ -1,5 +1,5 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2008, 2011, 2012, 2013, 2014, 2015 Laboratoire de +// Copyright (C) 2008, 2011, 2012, 2013, 2014, 2015, 2016 Laboratoire de // Recherche et Développement de l'Epita (LRDE). // Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6), // département Systèmes Répartis Coopératifs (SRC), Université Pierre @@ -66,7 +66,7 @@ namespace spot } virtual void - print(std::ostream& os, const char*) const; + print(std::ostream& os, const char*) const override; }; /// \brief prints various statistics about a TGBA diff --git a/spot/twaalgos/tau03opt.cc b/spot/twaalgos/tau03opt.cc index 15a6659cc..7eb788100 100644 --- a/spot/twaalgos/tau03opt.cc +++ b/spot/twaalgos/tau03opt.cc @@ -97,7 +97,7 @@ namespace spot /// /// \return non null pointer iff the algorithm has found an /// accepting path. - virtual emptiness_check_result_ptr check() + virtual emptiness_check_result_ptr check() override { if (!st_blue.empty()) return nullptr; @@ -113,7 +113,7 @@ namespace spot return nullptr; } - virtual std::ostream& print_stats(std::ostream &os) const + virtual std::ostream& print_stats(std::ostream &os) const override { os << states() << " distinct nodes visited" << std::endl; os << transitions() << " transitions explored" << std::endl; diff --git a/tests/core/ngraph.cc b/tests/core/ngraph.cc index 2fcad25a3..b7704b07f 100644 --- a/tests/core/ngraph.cc +++ b/tests/core/ngraph.cc @@ -1,6 +1,6 @@ // -*- coding: utf-8 -*- -// Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement -// de l'Epita. +// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et +// Développement de l'Epita. // // This file is part of Spot, a model checking library. // @@ -347,7 +347,7 @@ public: { } - virtual int compare(const spot::state* other) const + int compare(const spot::state* other) const override { auto o = down_cast(other); assert(o); @@ -360,19 +360,18 @@ public: return 0; } - virtual size_t hash() const + size_t hash() const override { return reinterpret_cast(this) - static_cast(nullptr); } - virtual my_state* - clone() const + my_state* clone() const override { return const_cast(this); } - virtual void destroy() const + void destroy() const override { }