From 54935cb9c7012ac113091a7e8f34a225a4b3903b Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 2 Oct 2015 11:47:21 +0200 Subject: [PATCH] Add noexcept to various constructors related to graphs. * m4/gccwarn.m4: Enable -Wnoexcept. * src/graph/graph.hh, src/twa/acc.hh, src/twa/twagraph.hh: Add noexcept to various constructors. --- m4/gccwarn.m4 | 3 ++- src/graph/graph.hh | 41 ++++++++++++++++++++++++++--------------- src/twa/acc.hh | 6 +++--- src/twa/twagraph.hh | 7 +++---- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/m4/gccwarn.m4 b/m4/gccwarn.m4 index b3792e8ad..1a5d44372 100644 --- a/m4/gccwarn.m4 +++ b/m4/gccwarn.m4 @@ -33,7 +33,8 @@ EOF Wwrite-strings \ Wcast-qual \ Wdocumentation \ - Wmissing-declarations + Wmissing-declarations \ + Wnoexcept do CXXFLAGS="$cf_save_CXXFLAGS $ac_cv_prog_gxx_warn_flags -$cf_opt" if AC_TRY_EVAL(ac_compile); then diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 3cd1fec50..8a1c3d5c0 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -27,6 +27,7 @@ #include #include #include +#include namespace spot { @@ -64,14 +65,16 @@ namespace spot template ::value>::type> - boxed_label(Args&&... args): - label{std::forward(args)...} + boxed_label(Args&&... args) + noexcept(std::is_nothrow_constructible::value) + : label{std::forward(args)...} { } // if Data is a POD type, G++ 4.8.2 wants default values for all // label fields unless we define this default constructor here. explicit boxed_label() + noexcept(std::is_nothrow_constructible::value) { } @@ -115,14 +118,16 @@ namespace spot template ::value>::type> - boxed_label(Args&&... args): - Data{std::forward(args)...} + boxed_label(Args&&... args) + noexcept(std::is_nothrow_constructible::value) + : Data{std::forward(args)...} { } // if Data is a POD type, G++ 4.8.2 wants default values for all // label fields unless we define this default constructor here. explicit boxed_label() + noexcept(std::is_nothrow_constructible::value) { } @@ -154,8 +159,9 @@ namespace spot template ::value>::type> - distate_storage(Args&&... args): - State_Data{std::forward(args)...} + distate_storage(Args&&... args) + noexcept(std::is_nothrow_constructible::value) + : State_Data{std::forward(args)...} { } }; @@ -178,6 +184,7 @@ namespace spot StateIn src; // source explicit edge_storage() + noexcept(std::is_nothrow_constructible::value) : Edge_Data{} { } @@ -185,6 +192,9 @@ namespace spot template edge_storage(StateOut dst, Edge next_succ, StateIn src, Args&&... args) + noexcept(std::is_nothrow_constructible::value + && std::is_nothrow_constructible::value + && std::is_nothrow_constructible::value) : Edge_Data{std::forward(args)...}, dst(dst), next_succ(next_succ), src(src) { @@ -238,12 +248,13 @@ namespace spot public: typedef typename Graph::edge edge; - edge_iterator() + edge_iterator() noexcept : g_(nullptr), t_(0) { } - edge_iterator(Graph* g, edge t): g_(g), t_(t) + edge_iterator(Graph* g, edge t) noexcept + : g_(g), t_(t) { } @@ -305,8 +316,8 @@ namespace spot typedef typename Graph::state_storage_t state_storage_t; typedef typename Graph::edge edge; - killer_edge_iterator(Graph* g, edge t, state_storage_t& src): - super(g, t), src_(src), prev_(0) + killer_edge_iterator(Graph* g, edge t, state_storage_t& src) noexcept + : super(g, t), src_(src), prev_(0) { } @@ -371,8 +382,8 @@ namespace spot { public: typedef typename Graph::edge edge; - state_out(Graph* g, edge t): - g_(g), t_(t) + state_out(Graph* g, edge t) noexcept + : g_(g), t_(t) { } @@ -433,13 +444,13 @@ namespace spot } public: - all_edge_iterator(unsigned pos, tv_t& tv) + all_edge_iterator(unsigned pos, tv_t& tv) noexcept : t_(pos), tv_(tv) { skip_(); } - all_edge_iterator(tv_t& tv) + all_edge_iterator(tv_t& tv) noexcept : t_(tv.size()), tv_(tv) { } @@ -492,7 +503,7 @@ namespace spot tv_t& tv_; public: - all_trans(tv_t& tv) + all_trans(tv_t& tv) noexcept : tv_(tv) { } diff --git a/src/twa/acc.hh b/src/twa/acc.hh index 105fc2dd0..1bd8b65f9 100644 --- a/src/twa/acc.hh +++ b/src/twa/acc.hh @@ -38,20 +38,20 @@ namespace spot mark_t() = default; - mark_t(value_t id) + mark_t(value_t id) noexcept : id(id) { } template - mark_t(const iterator& begin, const iterator& end) + mark_t(const iterator& begin, const iterator& end) noexcept { id = 0U; for (iterator i = begin; i != end; ++i) set(*i); } - mark_t(std::initializer_list vals) + mark_t(std::initializer_list vals) noexcept : mark_t(vals.begin(), vals.end()) { } diff --git a/src/twa/twagraph.hh b/src/twa/twagraph.hh index 9f20e9525..fb4b3530b 100644 --- a/src/twa/twagraph.hh +++ b/src/twa/twagraph.hh @@ -34,8 +34,7 @@ namespace spot struct SPOT_API twa_graph_state: public spot::state { public: - twa_graph_state(): - spot::state() + twa_graph_state() noexcept { } @@ -78,12 +77,12 @@ namespace spot bdd cond; acc_cond::mark_t acc; - explicit twa_graph_edge_data() + explicit twa_graph_edge_data() noexcept : cond(bddfalse), acc(0) { } - twa_graph_edge_data(bdd cond, acc_cond::mark_t acc = 0U) + twa_graph_edge_data(bdd cond, acc_cond::mark_t acc = 0U) noexcept : cond(cond), acc(acc) { }