From 5a2c1d78a1a4a5424dc8afc7f8957647870c7145 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 08:25:13 +0100 Subject: [PATCH 01/47] miniBDD: Added copyright notice --- src/solvers/miniBDD/example.cpp | 9 +++++++++ src/solvers/miniBDD/miniBDD.cpp | 9 +++++++++ unit/miniBDD.cpp | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/src/solvers/miniBDD/example.cpp b/src/solvers/miniBDD/example.cpp index f79c02d42c7..48244a7c2fe 100644 --- a/src/solvers/miniBDD/example.cpp +++ b/src/solvers/miniBDD/example.cpp @@ -1,3 +1,12 @@ +/*******************************************************************\ + +Module: A minimalistic BDD library, following Bryant's original paper + and Andersen's lecture notes + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + #include #include "miniBDD.h" diff --git a/src/solvers/miniBDD/miniBDD.cpp b/src/solvers/miniBDD/miniBDD.cpp index 345a84b9b97..94f81e568b5 100644 --- a/src/solvers/miniBDD/miniBDD.cpp +++ b/src/solvers/miniBDD/miniBDD.cpp @@ -1,3 +1,12 @@ +/*******************************************************************\ + +Module: A minimalistic BDD library, following Bryant's original paper + and Andersen's lecture notes + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + #include #include diff --git a/unit/miniBDD.cpp b/unit/miniBDD.cpp index c51ec2addc5..644af963926 100644 --- a/unit/miniBDD.cpp +++ b/unit/miniBDD.cpp @@ -1,3 +1,12 @@ +/*******************************************************************\ + +Module: A minimalistic BDD library, following Bryant's original paper + and Andersen's lecture notes + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + #include #include From d55758e2e85bcd67ce64e5b0c8f75a11160ac415 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 08:31:55 +0100 Subject: [PATCH 02/47] miniBDD lint-cleaning: Do not use namespaces --- src/solvers/miniBDD/miniBDD.cpp | 5 ----- src/solvers/miniBDD/miniBDD.h | 5 ----- src/solvers/miniBDD/miniBDD.inc | 5 ----- unit/miniBDD.cpp | 2 -- 4 files changed, 17 deletions(-) diff --git a/src/solvers/miniBDD/miniBDD.cpp b/src/solvers/miniBDD/miniBDD.cpp index 94f81e568b5..7428249d2e4 100644 --- a/src/solvers/miniBDD/miniBDD.cpp +++ b/src/solvers/miniBDD/miniBDD.cpp @@ -16,9 +16,6 @@ Author: Daniel Kroening, kroening@kroening.com #define forall_nodes(it) for(nodest::const_iterator it=nodes.begin(); \ it!=nodes.end(); it++) -namespace miniBDD -{ - void node::remove_reference() { assert(reference_counter!=0); @@ -470,5 +467,3 @@ bool OneSat(const BDD &v, std::map &assignment) return OneSat(v.low(), assignment); } } - -} // namespace miniBDD diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index eb1a6ea0da2..3718988f90d 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -24,9 +24,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -namespace miniBDD -{ - class BDD { public: @@ -137,8 +134,6 @@ BDD substitute(const BDD &where, unsigned var, const BDD &by_what); std::string cubes(const BDD &u); bool OneSat(const BDD &v, std::map &assignment); -} // namespace miniBDD - // inline functions #include "miniBDD.inc" diff --git a/src/solvers/miniBDD/miniBDD.inc b/src/solvers/miniBDD/miniBDD.inc index a73d8a97daf..bfde5742775 100644 --- a/src/solvers/miniBDD/miniBDD.inc +++ b/src/solvers/miniBDD/miniBDD.inc @@ -2,9 +2,6 @@ // inline functions -namespace miniBDD -{ - BDD::BDD():node(0) { } @@ -129,5 +126,3 @@ std::size_t mgr::number_of_nodes() { return nodes.size()-free.size(); } - -} // namespace miniBDD diff --git a/unit/miniBDD.cpp b/unit/miniBDD.cpp index 644af963926..d164fc31b44 100644 --- a/unit/miniBDD.cpp +++ b/unit/miniBDD.cpp @@ -11,8 +11,6 @@ Author: Daniel Kroening, kroening@kroening.com #include -using namespace miniBDD; - void test1() { mgr mgr; From 2aac9b5eafd68c75bc30625c7063fef9ea43af27 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 08:56:48 +0100 Subject: [PATCH 03/47] miniBDD lint-cleaning: Proper type names, ending in t --- src/solvers/miniBDD/miniBDD.cpp | 98 ++++++++++++++++----------------- src/solvers/miniBDD/miniBDD.h | 78 +++++++++++++------------- src/solvers/miniBDD/miniBDD.inc | 46 ++++++++-------- src/solvers/prop/bdd_expr.cpp | 28 +++++----- src/solvers/prop/bdd_expr.h | 12 ++-- unit/miniBDD.cpp | 26 ++++----- 6 files changed, 143 insertions(+), 145 deletions(-) diff --git a/src/solvers/miniBDD/miniBDD.cpp b/src/solvers/miniBDD/miniBDD.cpp index 7428249d2e4..a1f6c3fcd8a 100644 --- a/src/solvers/miniBDD/miniBDD.cpp +++ b/src/solvers/miniBDD/miniBDD.cpp @@ -16,7 +16,7 @@ Author: Daniel Kroening, kroening@kroening.com #define forall_nodes(it) for(nodest::const_iterator it=nodes.begin(); \ it!=nodes.end(); it++) -void node::remove_reference() +void mini_bdd_nodet::remove_reference() { assert(reference_counter!=0); @@ -24,7 +24,7 @@ void node::remove_reference() if(reference_counter==0 && node_number>=2) { - mgr::reverse_keyt reverse_key(var, low, high); + mini_bdd_mgrt::reverse_keyt reverse_key(var, low, high); mgr->reverse_map.erase(reverse_key); low.clear(); high.clear(); @@ -32,7 +32,7 @@ void node::remove_reference() } } -BDD mgr::Var(const std::string &label) +mini_bddt mini_bdd_mgrt::Var(const std::string &label) { var_table.push_back(var_table_entryt(label)); true_bdd.node->var=var_table.size()+1; @@ -40,7 +40,7 @@ BDD mgr::Var(const std::string &label) return mk(var_table.size(), false_bdd, true_bdd); } -void mgr::DumpDot(std::ostream &out, bool suppress_zero) const +void mini_bdd_mgrt::DumpDot(std::ostream &out, bool suppress_zero) const { out << "digraph BDD {\n"; @@ -101,7 +101,7 @@ void mgr::DumpDot(std::ostream &out, bool suppress_zero) const out << "}\n"; } -void mgr::DumpTikZ( +void mini_bdd_mgrt::DumpTikZ( std::ostream &out, bool suppress_zero, bool node_numbers) const @@ -178,24 +178,24 @@ void mgr::DumpTikZ( out << "\\end{tikzpicture}\n"; } -class apply +class mini_bdd_applyt { public: - inline explicit apply(bool (*_fkt)(bool, bool)):fkt(_fkt) + inline explicit mini_bdd_applyt(bool (*_fkt)(bool, bool)):fkt(_fkt) { } - BDD operator()(const BDD &x, const BDD &y) { return APP(x, y); } + mini_bddt operator()(const mini_bddt &x, const mini_bddt &y) { return APP(x, y); } protected: bool (*fkt)(bool, bool); - BDD APP(const BDD &x, const BDD &y); + mini_bddt APP(const mini_bddt &x, const mini_bddt &y); - typedef std::map, BDD> Gt; + typedef std::map, mini_bddt> Gt; Gt G; }; -BDD apply::APP(const BDD &x, const BDD &y) +mini_bddt mini_bdd_applyt::APP(const mini_bddt &x, const mini_bddt &y) { assert(x.is_initialized() && y.is_initialized()); assert(x.node->mgr==y.node->mgr); @@ -205,12 +205,12 @@ BDD apply::APP(const BDD &x, const BDD &y) Gt::const_iterator G_it=G.find(key); if(G_it!=G.end()) return G_it->second; - mgr *mgr=x.node->mgr; + mini_bdd_mgrt *mgr=x.node->mgr; - BDD u; + mini_bddt u; if(x.is_constant() && y.is_constant()) - u=BDD(fkt(x.is_true(), y.is_true())?mgr->True():mgr->False()); + u=mini_bddt(fkt(x.is_true(), y.is_true())?mgr->True():mgr->False()); else if(x.var()==y.var()) u=mgr->mk(x.var(), APP(x.low(), y.low()), @@ -234,9 +234,9 @@ bool equal_fkt(bool x, bool y) return x==y; } -BDD BDD::operator ==(const BDD &other) const +mini_bddt mini_bddt::operator ==(const mini_bddt &other) const { - return apply(equal_fkt)(*this, other); + return mini_bdd_applyt(equal_fkt)(*this, other); } bool xor_fkt(bool x, bool y) @@ -244,12 +244,12 @@ bool xor_fkt(bool x, bool y) return x ^ y; } -BDD BDD::operator ^(const BDD &other) const +mini_bddt mini_bddt::operator ^(const mini_bddt &other) const { - return apply(xor_fkt)(*this, other); + return mini_bdd_applyt(xor_fkt)(*this, other); } -BDD BDD::operator !() const +mini_bddt mini_bddt::operator !() const { return node->mgr->True() ^ *this; } @@ -259,9 +259,9 @@ bool and_fkt(bool x, bool y) return x && y; } -BDD BDD::operator &(const BDD &other) const +mini_bddt mini_bddt::operator &(const mini_bddt &other) const { - return apply(and_fkt)(*this, other); + return mini_bdd_applyt(and_fkt)(*this, other); } bool or_fkt(bool x, bool y) @@ -269,25 +269,25 @@ bool or_fkt(bool x, bool y) return x || y; } -BDD BDD::operator |(const BDD &other) const +mini_bddt mini_bddt::operator |(const mini_bddt &other) const { - return apply(or_fkt)(*this, other); + return mini_bdd_applyt(or_fkt)(*this, other); } -mgr::mgr() +mini_bdd_mgrt::mini_bdd_mgrt() { // add true/false nodes - nodes.push_back(node(this, 0, 0, BDD(), BDD())); - false_bdd=BDD(&nodes.back()); - nodes.push_back(node(this, 1, 1, BDD(), BDD())); - true_bdd=BDD(&nodes.back()); + nodes.push_back(mini_bdd_nodet(this, 0, 0, mini_bddt(), mini_bddt())); + false_bdd=mini_bddt(&nodes.back()); + nodes.push_back(mini_bdd_nodet(this, 1, 1, mini_bddt(), mini_bddt())); + true_bdd=mini_bddt(&nodes.back()); } -mgr::~mgr() +mini_bdd_mgrt::~mini_bdd_mgrt() { } -BDD mgr::mk(unsigned var, const BDD &low, const BDD &high) +mini_bddt mini_bdd_mgrt::mk(unsigned var, const mini_bddt &low, const mini_bddt &high) { assert(var<=var_table.size()); @@ -299,15 +299,15 @@ BDD mgr::mk(unsigned var, const BDD &low, const BDD &high) reverse_mapt::const_iterator it=reverse_map.find(reverse_key); if(it!=reverse_map.end()) - return BDD(it->second); + return mini_bddt(it->second); else { - node *n; + mini_bdd_nodet *n; if(free.empty()) { unsigned new_number=nodes.back().node_number+1; - nodes.push_back(node(this, var, new_number, low, high)); + nodes.push_back(mini_bdd_nodet(this, var, new_number, low, high)); n=&nodes.back(); } else // reuse a node @@ -320,13 +320,13 @@ BDD mgr::mk(unsigned var, const BDD &low, const BDD &high) } reverse_map[reverse_key]=n; - return BDD(n); + return mini_bddt(n); } } } -bool operator < (const mgr::reverse_keyt &x, - const mgr::reverse_keyt &y) +bool operator < (const mini_bdd_mgrt::reverse_keyt &x, + const mini_bdd_mgrt::reverse_keyt &y) { if(x.vary.var) return false; @@ -335,7 +335,7 @@ bool operator < (const mgr::reverse_keyt &x, return x.highmgr; + mini_bdd_mgrt *mgr=u.node->mgr; - BDD t; + mini_bddt t; if(u.var()>var) t=u; @@ -395,19 +395,19 @@ BDD restrictt::RES(const BDD &u) return t; } -BDD restrict(const BDD &u, unsigned var, const bool value) +mini_bddt restrict(const mini_bddt &u, unsigned var, const bool value) { return restrictt(var, value)(u); } -BDD exists(const BDD &u, const unsigned var) +mini_bddt exists(const mini_bddt &u, const unsigned var) { // u[var/0] OR u[var/1] return restrict(u, var, false) | restrict(u, var, true); } -BDD substitute(const BDD &t, unsigned var, const BDD &tp) +mini_bddt substitute(const mini_bddt &t, unsigned var, const mini_bddt &tp) { // t[var/tp] = // ( tp & t[var/1]) | @@ -417,7 +417,7 @@ BDD substitute(const BDD &t, unsigned var, const BDD &tp) ((!tp) & restrict(t, var, false)); } -void cubes(const BDD &u, const std::string &path, std::string &result) +void cubes(const mini_bddt &u, const std::string &path, std::string &result) { if(u.is_false()) return; @@ -428,7 +428,7 @@ void cubes(const BDD &u, const std::string &path, std::string &result) return; } - mgr *mgr=u.node->mgr; + mini_bdd_mgrt *mgr=u.node->mgr; std::string path_low=path; std::string path_high=path; if(!path.empty()) { path_low+=" & "; path_high+=" & "; } @@ -438,7 +438,7 @@ void cubes(const BDD &u, const std::string &path, std::string &result) cubes(u.high(), path_high, result); } -std::string cubes(const BDD &u) +std::string cubes(const mini_bddt &u) { if(u.is_false()) return "false\n"; @@ -452,7 +452,7 @@ std::string cubes(const BDD &u) } } -bool OneSat(const BDD &v, std::map &assignment) +bool OneSat(const mini_bddt &v, std::map &assignment) { // http://www.ecs.umass.edu/ece/labs/vlsicad/ece667/reading/somenzi99bdd.pdf if(v.is_true()) diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index 3718988f90d..604ed419fef 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -24,76 +24,76 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -class BDD +class mini_bddt { public: - inline BDD(); - inline BDD(const BDD &x); - inline ~BDD(); + inline mini_bddt(); + inline mini_bddt(const mini_bddt &x); + inline ~mini_bddt(); // Boolean operators on BDDs - BDD operator !() const; - BDD operator ^(const BDD &) const; - BDD operator ==(const BDD &) const; - BDD operator &(const BDD &) const; - BDD operator |(const BDD &) const; + mini_bddt operator !() const; + mini_bddt operator ^(const mini_bddt &) const; + mini_bddt operator ==(const mini_bddt &) const; + mini_bddt operator &(const mini_bddt &) const; + mini_bddt operator |(const mini_bddt &) const; // copy operator - inline BDD &operator=(const BDD &); + inline mini_bddt &operator=(const mini_bddt &); inline bool is_constant() const; inline bool is_true() const; inline bool is_false() const; inline unsigned var() const; - inline const BDD &low() const; - inline const BDD &high() const; + inline const mini_bddt &low() const; + inline const mini_bddt &high() const; inline unsigned node_number() const; inline void clear(); bool is_initialized() const { return node!=0; } // internal - explicit inline BDD(class node *_node); - class node *node; + explicit inline mini_bddt(class mini_bdd_nodet *_node); + class mini_bdd_nodet *node; }; -class node +class mini_bdd_nodet { public: - class mgr *mgr; + class mini_bdd_mgrt *mgr; unsigned var, node_number, reference_counter; - BDD low, high; + mini_bddt low, high; - inline node( - class mgr *_mgr, + inline mini_bdd_nodet( + class mini_bdd_mgrt *_mgr, unsigned _var, unsigned _node_number, - const BDD &_low, const BDD &_high); + const mini_bddt &_low, const mini_bddt &_high); inline void add_reference(); void remove_reference(); }; -class mgr +class mini_bdd_mgrt { public: - mgr(); - ~mgr(); + mini_bdd_mgrt(); + ~mini_bdd_mgrt(); - BDD Var(const std::string &label); + mini_bddt Var(const std::string &label); void DumpDot(std::ostream &out, bool supress_zero=false) const; void DumpTikZ(std::ostream &out, bool supress_zero=false, bool node_numbers=true) const; void DumpTable(std::ostream &out) const; - inline const BDD &True() const; - inline const BDD &False() const; + inline const mini_bddt &True() const; + inline const mini_bddt &False() const; - friend class BDD; - friend class node; + friend class mini_bddt; + friend class mini_bdd_nodet; // create a node (consulting the reverse-map) - BDD mk(unsigned var, const BDD &low, const BDD &high); + mini_bddt mk(unsigned var, const mini_bddt &low, const mini_bddt &high); inline std::size_t number_of_nodes(); @@ -107,32 +107,32 @@ class mgr var_tablet var_table; protected: - typedef std::list nodest; + typedef std::list nodest; nodest nodes; - BDD true_bdd, false_bdd; + mini_bddt true_bdd, false_bdd; // this is our reverse-map for nodes struct reverse_keyt { unsigned var, low, high; inline reverse_keyt( - unsigned _var, const BDD &_low, const BDD &_high); + unsigned _var, const mini_bddt &_low, const mini_bddt &_high); }; friend bool operator < (const reverse_keyt &x, const reverse_keyt &y); - typedef std::map reverse_mapt; + typedef std::map reverse_mapt; reverse_mapt reverse_map; - typedef std::stack freet; + typedef std::stack freet; freet free; }; -BDD restrict(const BDD &u, unsigned var, const bool value); -BDD exists(const BDD &u, unsigned var); -BDD substitute(const BDD &where, unsigned var, const BDD &by_what); -std::string cubes(const BDD &u); -bool OneSat(const BDD &v, std::map &assignment); +mini_bddt restrict(const mini_bddt &u, unsigned var, const bool value); +mini_bddt exists(const mini_bddt &u, unsigned var); +mini_bddt substitute(const mini_bddt &where, unsigned var, const mini_bddt &by_what); +std::string cubes(const mini_bddt &u); +bool OneSat(const mini_bddt &v, std::map &assignment); // inline functions #include "miniBDD.inc" diff --git a/src/solvers/miniBDD/miniBDD.inc b/src/solvers/miniBDD/miniBDD.inc index bfde5742775..a48f56770cd 100644 --- a/src/solvers/miniBDD/miniBDD.inc +++ b/src/solvers/miniBDD/miniBDD.inc @@ -2,21 +2,21 @@ // inline functions -BDD::BDD():node(0) +mini_bddt::mini_bddt():node(0) { } -BDD::BDD(const BDD &x):node(x.node) +mini_bddt::mini_bddt(const mini_bddt &x):node(x.node) { if(is_initialized()) node->add_reference(); } -BDD::BDD(class node *_node):node(_node) +mini_bddt::mini_bddt(class mini_bdd_nodet *_node):node(_node) { if(is_initialized()) node->add_reference(); } -BDD &BDD::operator=(const BDD &x) +mini_bddt &mini_bddt::operator=(const mini_bddt &x) { assert(&x!=this); clear(); @@ -28,56 +28,56 @@ BDD &BDD::operator=(const BDD &x) return *this; } -BDD::~BDD() +mini_bddt::~mini_bddt() { clear(); } -bool BDD::is_constant() const +bool mini_bddt::is_constant() const { assert(is_initialized()); return node->node_number<=1; } -bool BDD::is_true() const +bool mini_bddt::is_true() const { assert(is_initialized()); return node->node_number==1; } -bool BDD::is_false() const +bool mini_bddt::is_false() const { assert(is_initialized()); return node->node_number==0; } -unsigned BDD::var() const +unsigned mini_bddt::var() const { assert(is_initialized()); return node->var; } -unsigned BDD::node_number() const +unsigned mini_bddt::node_number() const { assert(is_initialized()); return node->node_number; } -const BDD &BDD::low() const +const mini_bddt &mini_bddt::low() const { assert(is_initialized()); assert(node->node_number>=2); return node->low; } -const BDD &BDD::high() const +const mini_bddt &mini_bddt::high() const { assert(is_initialized()); assert(node->node_number>=2); return node->high; } -void BDD::clear() +void mini_bddt::clear() { if(is_initialized()) { @@ -86,43 +86,43 @@ void BDD::clear() } } -node::node( - class mgr *_mgr, +mini_bdd_nodet::mini_bdd_nodet( + class mini_bdd_mgrt *_mgr, unsigned _var, unsigned _node_number, - const BDD &_low, const BDD &_high): + const mini_bddt &_low, const mini_bddt &_high): mgr(_mgr), var(_var), node_number(_node_number), reference_counter(0), low(_low), high(_high) { } -mgr::var_table_entryt::var_table_entryt( +mini_bdd_mgrt::var_table_entryt::var_table_entryt( const std::string &_label):label(_label) { } -const BDD &mgr::True() const +const mini_bddt &mini_bdd_mgrt::True() const { return true_bdd; } -const BDD &mgr::False() const +const mini_bddt &mini_bdd_mgrt::False() const { return false_bdd; } -void node::add_reference() +void mini_bdd_nodet::add_reference() { reference_counter++; } -mgr::reverse_keyt::reverse_keyt( - unsigned _var, const BDD &_low, const BDD &_high): +mini_bdd_mgrt::reverse_keyt::reverse_keyt( + unsigned _var, const mini_bddt &_low, const mini_bddt &_high): var(_var), low(_low.node->node_number), high(_high.node->node_number) { } -std::size_t mgr::number_of_nodes() +std::size_t mini_bdd_mgrt::number_of_nodes() { return nodes.size()-free.size(); } diff --git a/src/solvers/prop/bdd_expr.cpp b/src/solvers/prop/bdd_expr.cpp index 434314b39d4..91e06dfb08a 100644 --- a/src/solvers/prop/bdd_expr.cpp +++ b/src/solvers/prop/bdd_expr.cpp @@ -25,7 +25,7 @@ Function: bdd_exprt::from_expr_rec \*******************************************************************/ -bdd_exprt::BDDt bdd_exprt::from_expr_rec(const exprt &expr) +mini_bddt bdd_exprt::from_expr_rec(const exprt &expr) { assert(expr.type().id()==ID_bool); @@ -40,8 +40,8 @@ bdd_exprt::BDDt bdd_exprt::from_expr_rec(const exprt &expr) assert(expr.operands().size()>=2); exprt bin_expr=make_binary(expr); - bdd_exprt::BDDt op0=from_expr_rec(bin_expr.op0()); - bdd_exprt::BDDt op1=from_expr_rec(bin_expr.op1()); + mini_bddt op0=from_expr_rec(bin_expr.op0()); + mini_bddt op1=from_expr_rec(bin_expr.op1()); return expr.id()==ID_and ? (op0&op1) : (expr.id()==ID_or ? (op0|op1) : (op0^op1)); @@ -50,8 +50,8 @@ bdd_exprt::BDDt bdd_exprt::from_expr_rec(const exprt &expr) { const implies_exprt &imp_expr=to_implies_expr(expr); - bdd_exprt::BDDt n_op0=!from_expr_rec(imp_expr.op0()); - bdd_exprt::BDDt op1=from_expr_rec(imp_expr.op1()); + mini_bddt n_op0=!from_expr_rec(imp_expr.op0()); + mini_bddt op1=from_expr_rec(imp_expr.op1()); return n_op0|op1; } @@ -61,8 +61,8 @@ bdd_exprt::BDDt bdd_exprt::from_expr_rec(const exprt &expr) { const equal_exprt &eq_expr=to_equal_expr(expr); - bdd_exprt::BDDt op0=from_expr_rec(eq_expr.op0()); - bdd_exprt::BDDt op1=from_expr_rec(eq_expr.op1()); + mini_bddt op0=from_expr_rec(eq_expr.op0()); + mini_bddt op1=from_expr_rec(eq_expr.op1()); return op0==op1; } @@ -70,8 +70,8 @@ bdd_exprt::BDDt bdd_exprt::from_expr_rec(const exprt &expr) { assert(expr.operands().size()==2); - bdd_exprt::BDDt op0=from_expr_rec(expr.op0()); - bdd_exprt::BDDt op1=from_expr_rec(expr.op1()); + mini_bddt op0=from_expr_rec(expr.op0()); + mini_bddt op1=from_expr_rec(expr.op1()); return op0==op1; } @@ -79,16 +79,16 @@ bdd_exprt::BDDt bdd_exprt::from_expr_rec(const exprt &expr) { const if_exprt &if_expr=to_if_expr(expr); - bdd_exprt::BDDt cond=from_expr_rec(if_expr.cond()); - bdd_exprt::BDDt t_case=from_expr_rec(if_expr.true_case()); - bdd_exprt::BDDt f_case=from_expr_rec(if_expr.false_case()); + mini_bddt cond=from_expr_rec(if_expr.cond()); + mini_bddt t_case=from_expr_rec(if_expr.true_case()); + mini_bddt f_case=from_expr_rec(if_expr.false_case()); return ((!cond)|t_case)&(cond|f_case); } else { std::pair entry= - expr_map.insert(std::make_pair(expr, bdd_exprt::BDDt())); + expr_map.insert(std::make_pair(expr, mini_bddt())); if(entry.second) { @@ -132,7 +132,7 @@ Function: bdd_exprt::as_expr \*******************************************************************/ -exprt bdd_exprt::as_expr(const bdd_exprt::BDDt &r) const +exprt bdd_exprt::as_expr(const mini_bddt &r) const { if(r.is_constant()) { diff --git a/src/solvers/prop/bdd_expr.h b/src/solvers/prop/bdd_expr.h index 608be1694e2..6d76437dc95 100644 --- a/src/solvers/prop/bdd_expr.h +++ b/src/solvers/prop/bdd_expr.h @@ -32,20 +32,18 @@ class bdd_exprt void from_expr(const exprt &expr); exprt as_expr() const; - typedef miniBDD::BDD BDDt; - protected: const namespacet &ns; - miniBDD::mgr bdd_mgr; - BDDt root; + mini_bdd_mgrt bdd_mgr; + mini_bddt root; - typedef std::unordered_map expr_mapt; + typedef std::unordered_map expr_mapt; expr_mapt expr_map; typedef std::map node_mapt; node_mapt node_map; - BDDt from_expr_rec(const exprt &expr); - exprt as_expr(const BDDt &r) const; + mini_bddt from_expr_rec(const exprt &expr); + exprt as_expr(const mini_bddt &r) const; }; #endif // CPROVER_SOLVERS_PROP_BDD_EXPR_H diff --git a/unit/miniBDD.cpp b/unit/miniBDD.cpp index d164fc31b44..d5b6fc93e24 100644 --- a/unit/miniBDD.cpp +++ b/unit/miniBDD.cpp @@ -13,12 +13,12 @@ Author: Daniel Kroening, kroening@kroening.com void test1() { - mgr mgr; + mini_bdd_mgrt mgr; - BDD x=mgr.Var("x"); - BDD y=mgr.Var("y"); - BDD z=mgr.Var("z"); - BDD f=(x&y&z)|(!x&!y&z); + mini_bddt x=mgr.Var("x"); + mini_bddt y=mgr.Var("y"); + mini_bddt z=mgr.Var("z"); + mini_bddt f=(x&y&z)|(!x&!y&z); y.clear(); x.clear(); z.clear(); @@ -29,14 +29,14 @@ void test1() void test2() { - mgr mgr; + mini_bdd_mgrt mgr; - BDD a=mgr.Var("a"); - BDD b=mgr.Var("b"); - BDD c=mgr.Var("c"); - BDD d=mgr.Var("d"); + mini_bddt a=mgr.Var("a"); + mini_bddt b=mgr.Var("b"); + mini_bddt c=mgr.Var("c"); + mini_bddt d=mgr.Var("d"); - BDD final=(a == b) & (c == d); + mini_bddt final=(a == b) & (c == d); a.clear(); b.clear(); @@ -48,9 +48,9 @@ void test2() void test3() { - mgr mgr; + mini_bdd_mgrt mgr; - BDD final=mgr.Var("x") & mgr.Var("y"); + mini_bddt final=mgr.Var("x") & mgr.Var("y"); mgr.DumpDot(std::cout); //mgr.DumpTikZ(std::cout); From 7f98a3bacf0ac589b48bfb983a6b3f512c96eaa8 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 09:09:47 +0100 Subject: [PATCH 04/47] miniBDD lint-cleaning: whitespace adjustments --- src/solvers/miniBDD/miniBDD.cpp | 29 ++++++++++++++++++----------- src/solvers/miniBDD/miniBDD.h | 22 ++++++++++++++-------- unit/miniBDD.cpp | 12 +++++++----- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/solvers/miniBDD/miniBDD.cpp b/src/solvers/miniBDD/miniBDD.cpp index a1f6c3fcd8a..06070d55a0a 100644 --- a/src/solvers/miniBDD/miniBDD.cpp +++ b/src/solvers/miniBDD/miniBDD.cpp @@ -185,7 +185,10 @@ class mini_bdd_applyt { } - mini_bddt operator()(const mini_bddt &x, const mini_bddt &y) { return APP(x, y); } + mini_bddt operator()(const mini_bddt &x, const mini_bddt &y) + { + return APP(x, y); + } protected: bool (*fkt)(bool, bool); @@ -234,24 +237,24 @@ bool equal_fkt(bool x, bool y) return x==y; } -mini_bddt mini_bddt::operator ==(const mini_bddt &other) const +mini_bddt mini_bddt::operator==(const mini_bddt &other) const { return mini_bdd_applyt(equal_fkt)(*this, other); } bool xor_fkt(bool x, bool y) { - return x ^ y; + return x^y; } -mini_bddt mini_bddt::operator ^(const mini_bddt &other) const +mini_bddt mini_bddt::operator^(const mini_bddt &other) const { return mini_bdd_applyt(xor_fkt)(*this, other); } -mini_bddt mini_bddt::operator !() const +mini_bddt mini_bddt::operator!() const { - return node->mgr->True() ^ *this; + return node->mgr->True()^*this; } bool and_fkt(bool x, bool y) @@ -259,7 +262,7 @@ bool and_fkt(bool x, bool y) return x && y; } -mini_bddt mini_bddt::operator &(const mini_bddt &other) const +mini_bddt mini_bddt::operator&(const mini_bddt &other) const { return mini_bdd_applyt(and_fkt)(*this, other); } @@ -269,7 +272,7 @@ bool or_fkt(bool x, bool y) return x || y; } -mini_bddt mini_bddt::operator |(const mini_bddt &other) const +mini_bddt mini_bddt::operator|(const mini_bddt &other) const { return mini_bdd_applyt(or_fkt)(*this, other); } @@ -287,7 +290,10 @@ mini_bdd_mgrt::~mini_bdd_mgrt() { } -mini_bddt mini_bdd_mgrt::mk(unsigned var, const mini_bddt &low, const mini_bddt &high) +mini_bddt mini_bdd_mgrt::mk( + unsigned var, + const mini_bddt &low, + const mini_bddt &high) { assert(var<=var_table.size()); @@ -325,8 +331,9 @@ mini_bddt mini_bdd_mgrt::mk(unsigned var, const mini_bddt &low, const mini_bddt } } -bool operator < (const mini_bdd_mgrt::reverse_keyt &x, - const mini_bdd_mgrt::reverse_keyt &y) +bool operator<( + const mini_bdd_mgrt::reverse_keyt &x, + const mini_bdd_mgrt::reverse_keyt &y) { if(x.vary.var) return false; diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index 604ed419fef..3d9664cfa36 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -32,11 +32,11 @@ class mini_bddt inline ~mini_bddt(); // Boolean operators on BDDs - mini_bddt operator !() const; - mini_bddt operator ^(const mini_bddt &) const; - mini_bddt operator ==(const mini_bddt &) const; - mini_bddt operator &(const mini_bddt &) const; - mini_bddt operator |(const mini_bddt &) const; + mini_bddt operator!() const; + mini_bddt operator^(const mini_bddt &) const; + mini_bddt operator==(const mini_bddt &) const; + mini_bddt operator&(const mini_bddt &) const; + mini_bddt operator|(const mini_bddt &) const; // copy operator inline mini_bddt &operator=(const mini_bddt &); @@ -83,7 +83,10 @@ class mini_bdd_mgrt mini_bddt Var(const std::string &label); void DumpDot(std::ostream &out, bool supress_zero=false) const; - void DumpTikZ(std::ostream &out, bool supress_zero=false, bool node_numbers=true) const; + void DumpTikZ( + std::ostream &out, + bool supress_zero=false, + bool node_numbers=true) const; void DumpTable(std::ostream &out) const; inline const mini_bddt &True() const; @@ -119,7 +122,7 @@ class mini_bdd_mgrt unsigned _var, const mini_bddt &_low, const mini_bddt &_high); }; - friend bool operator < (const reverse_keyt &x, const reverse_keyt &y); + friend bool operator<(const reverse_keyt &x, const reverse_keyt &y); typedef std::map reverse_mapt; reverse_mapt reverse_map; @@ -130,7 +133,10 @@ class mini_bdd_mgrt mini_bddt restrict(const mini_bddt &u, unsigned var, const bool value); mini_bddt exists(const mini_bddt &u, unsigned var); -mini_bddt substitute(const mini_bddt &where, unsigned var, const mini_bddt &by_what); +mini_bddt substitute( + const mini_bddt &where, + unsigned var, + const mini_bddt &by_what); std::string cubes(const mini_bddt &u); bool OneSat(const mini_bddt &v, std::map &assignment); diff --git a/unit/miniBDD.cpp b/unit/miniBDD.cpp index d5b6fc93e24..ecda45a4ff1 100644 --- a/unit/miniBDD.cpp +++ b/unit/miniBDD.cpp @@ -23,7 +23,7 @@ void test1() x.clear(); z.clear(); - //mgr.DumpDot(std::cout); + // mgr.DumpDot(std::cout); mgr.DumpTikZ(std::cout); } @@ -36,7 +36,7 @@ void test2() mini_bddt c=mgr.Var("c"); mini_bddt d=mgr.Var("d"); - mini_bddt final=(a == b) & (c == d); + mini_bddt final=(a==b)&(c==d); a.clear(); b.clear(); @@ -50,11 +50,13 @@ void test3() { mini_bdd_mgrt mgr; - mini_bddt final=mgr.Var("x") & mgr.Var("y"); + mini_bddt final=mgr.Var("x")&mgr.Var("y"); mgr.DumpDot(std::cout); - //mgr.DumpTikZ(std::cout); - //mgr.DumpTable(std::cout); + #if 0 + mgr.DumpTikZ(std::cout); + mgr.DumpTable(std::cout); + #endif } #include From 736886e648e93a1eb154f41d54c1243fa9d73374 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 10:21:34 +0100 Subject: [PATCH 05/47] char*/string -> dstring implicit conversion is permitted The linter should not warn about these. --- src/util/dstring.h | 2 ++ src/util/lispexpr.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/util/dstring.h b/src/util/dstring.h index cddf885265b..93843b40147 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -40,11 +40,13 @@ class dstring #endif // this one is not safe for static objects + // NOLINTNEXTLINE(runtime/explicit) inline dstring(const char *s):no(string_container[s]) { } // this one is not safe for static objects + // NOLINTNEXTLINE(runtime/explicit) inline dstring(const std::string &s):no(string_container[s]) { } diff --git a/src/util/lispexpr.h b/src/util/lispexpr.h index 703e057e680..dc48d3ad6f4 100644 --- a/src/util/lispexpr.h +++ b/src/util/lispexpr.h @@ -25,6 +25,7 @@ Author: Daniel Kroening, kroening@kroening.com class lispsymbolt:public std::string { public: + // NOLINTNEXTLINE(runtime/explicit) lispsymbolt(const char *a):std::string(a) { } @@ -33,6 +34,7 @@ class lispsymbolt:public std::string { } + // NOLINTNEXTLINE(runtime/explicit) lispsymbolt(const std::string &a):std::string(a) { } From c5bde871bdebc66920ab21f10c129b1f54d727fb Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 10:41:10 +0100 Subject: [PATCH 06/47] Remove duplicate includes --- src/ansi-c/c_typecheck_base.cpp | 1 - src/cegis/genetic/genetic_constant_strategy.cpp | 1 - src/cpp/parse.cpp | 4 ---- src/goto-diff/goto_diff_parse_options.cpp | 1 - src/goto-programs/remove_function_pointers.cpp | 1 - src/java_bytecode/java_entry_point.cpp | 1 + src/musketeer/fence_shared.cpp | 1 - src/pointer-analysis/value_set_dereference.cpp | 1 - src/solvers/flattening/boolbv.cpp | 1 - src/util/file_util.cpp | 4 ++-- src/util/tempfile.cpp | 4 ++-- 11 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/ansi-c/c_typecheck_base.cpp b/src/ansi-c/c_typecheck_base.cpp index 8d81099916e..f519c0915f3 100644 --- a/src/ansi-c/c_typecheck_base.cpp +++ b/src/ansi-c/c_typecheck_base.cpp @@ -9,7 +9,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include -#include #include "c_typecheck_base.h" #include "expr2c.h" diff --git a/src/cegis/genetic/genetic_constant_strategy.cpp b/src/cegis/genetic/genetic_constant_strategy.cpp index 1e27f8faf00..3285af700b5 100644 --- a/src/cegis/genetic/genetic_constant_strategy.cpp +++ b/src/cegis/genetic/genetic_constant_strategy.cpp @@ -20,7 +20,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include -#include namespace { diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index e07b21c55bf..f2f4527abbf 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -9432,10 +9432,6 @@ Function: Parser::operator() \*******************************************************************/ -#if 0 -#include -#endif - bool Parser::operator()() { number_of_errors=0; diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index b2a6ae5fd14..da9a6949436 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -31,7 +31,6 @@ Author: Peter Schrammel #include #include #include -#include #include diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 1baca8d11d5..a021e96f448 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -12,7 +12,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include -#include #include #include diff --git a/src/java_bytecode/java_entry_point.cpp b/src/java_bytecode/java_entry_point.cpp index d4d40beff3b..c3726576c5f 100644 --- a/src/java_bytecode/java_entry_point.cpp +++ b/src/java_bytecode/java_entry_point.cpp @@ -21,6 +21,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include + #include #include diff --git a/src/musketeer/fence_shared.cpp b/src/musketeer/fence_shared.cpp index 9e3a3c580f1..25fe7933ce6 100644 --- a/src/musketeer/fence_shared.cpp +++ b/src/musketeer/fence_shared.cpp @@ -15,7 +15,6 @@ Author: Vincent Nimal #include #include -#include #include #include diff --git a/src/pointer-analysis/value_set_dereference.cpp b/src/pointer-analysis/value_set_dereference.cpp index c1913567448..df1d163e1b0 100644 --- a/src/pointer-analysis/value_set_dereference.cpp +++ b/src/pointer-analysis/value_set_dereference.cpp @@ -10,7 +10,6 @@ Author: Daniel Kroening, kroening@kroening.com #ifdef DEBUG #include -#include #endif #include diff --git a/src/solvers/flattening/boolbv.cpp b/src/solvers/flattening/boolbv.cpp index ca602dcd6b6..9ece0450804 100644 --- a/src/solvers/flattening/boolbv.cpp +++ b/src/solvers/flattening/boolbv.cpp @@ -9,7 +9,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include -#include // abort() #include #include diff --git a/src/util/file_util.cpp b/src/util/file_util.cpp index a8c2200b0ba..71b9ecd1239 100644 --- a/src/util/file_util.cpp +++ b/src/util/file_util.cpp @@ -8,6 +8,8 @@ Date: January 2012 \*******************************************************************/ +#include + #if defined(__linux__) || \ defined(__FreeBSD_kernel__) || \ defined(__GNU__) || \ @@ -15,7 +17,6 @@ Date: January 2012 defined(__CYGWIN__) || \ defined(__MACH__) #include -#include #include #include #include @@ -25,7 +26,6 @@ Date: January 2012 #include #include #include -#include #define chdir _chdir #define popen _popen #define pclose _pclose diff --git a/src/util/tempfile.cpp b/src/util/tempfile.cpp index 143b702abf6..86d710b49d1 100644 --- a/src/util/tempfile.cpp +++ b/src/util/tempfile.cpp @@ -10,7 +10,6 @@ Author: Daniel Kroening #include #include #include -#include #include #include #define getpid _getpid @@ -18,6 +17,8 @@ Author: Daniel Kroening #define close _close #endif +#include + #include #include @@ -29,7 +30,6 @@ Author: Daniel Kroening defined(__MACH__) #include #include -#include #endif #include "tempfile.h" From 3d738f1ca02ca238f15dd58d9ae5a00cf1ecd29f Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 23:30:44 +0100 Subject: [PATCH 07/47] Mark timer functions const --- src/util/timer.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/timer.h b/src/util/timer.h index ef4e510fb90..2a99ab29970 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -27,27 +27,27 @@ class timert virtual void stop(); virtual void clear(); - virtual time_periodt total_time() + virtual time_periodt total_time() const { return _total_time; } - virtual fine_timet latest_time() + virtual fine_timet latest_time() const { return _latest_time; } - virtual long number_starts() + virtual long number_starts() const { return nr_starts; } - std::string output_total_time() + std::string output_total_time() const { return _total_time.as_string(); } - std::string output_latest_time() + std::string output_latest_time() const { return _latest_time.as_string(); } From 9f0c4e854d334e782c1eebef486fc9ea4f56fd48 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 11:51:40 +0100 Subject: [PATCH 08/47] Construct ieee_floatt from floatbv_typet --- src/ansi-c/literals/convert_float_literal.cpp | 4 +--- src/goto-programs/interpreter_evaluate.cpp | 8 +++----- src/solvers/flattening/boolbv.cpp | 15 +++++---------- src/solvers/flattening/boolbv_abs.cpp | 3 +-- src/solvers/flattening/boolbv_add_sub.cpp | 6 ++---- src/solvers/flattening/boolbv_bv_rel.cpp | 3 +-- src/solvers/flattening/boolbv_ieee_float_rel.cpp | 3 +-- src/solvers/flattening/boolbv_typecast.cpp | 6 ++---- src/solvers/flattening/boolbv_unary_minus.cpp | 6 ++---- src/solvers/floatbv/float_utils.h | 7 +++++++ src/solvers/smt2/smt2_conv.cpp | 3 +-- src/util/ieee_float.h | 11 +++++++++++ src/util/simplify_expr.cpp | 3 +-- src/util/simplify_expr_floatbv.cpp | 3 +-- 14 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/ansi-c/literals/convert_float_literal.cpp b/src/ansi-c/literals/convert_float_literal.cpp index 6eeaecb0dd8..d411eaad964 100644 --- a/src/ansi-c/literals/convert_float_literal.cpp +++ b/src/ansi-c/literals/convert_float_literal.cpp @@ -121,9 +121,7 @@ exprt convert_float_literal(const std::string &src) } else { - ieee_floatt a; - - a.spec=to_floatbv_type(result.type()); + ieee_floatt a(to_floatbv_type(result.type())); if(base==10) a.from_base10(significand, exponent); diff --git a/src/goto-programs/interpreter_evaluate.cpp b/src/goto-programs/interpreter_evaluate.cpp index 57c761ebc6a..b73d1c61b43 100644 --- a/src/goto-programs/interpreter_evaluate.cpp +++ b/src/goto-programs/interpreter_evaluate.cpp @@ -268,8 +268,7 @@ void interpretert::evaluate( } else if(expr.type().id()==ID_floatbv) { - ieee_floatt f; - f.spec=to_floatbv_type(expr.type()); + ieee_floatt f(to_floatbv_type(expr.type())); f.from_integer(1); result=f.pack(); } @@ -294,9 +293,8 @@ void interpretert::evaluate( } else if(expr.type().id()==ID_floatbv) { - ieee_floatt f1, f2; - f1.spec=to_floatbv_type(expr.type()); - f2.spec=to_floatbv_type(it->type()); + ieee_floatt f1(to_floatbv_type(expr.type())); + ieee_floatt f2(to_floatbv_type(it->type())); f1.unpack(result); f2.unpack(tmp.front()); f1*=f2; diff --git a/src/solvers/flattening/boolbv.cpp b/src/solvers/flattening/boolbv.cpp index 9ece0450804..cbb6e01254c 100644 --- a/src/solvers/flattening/boolbv.cpp +++ b/src/solvers/flattening/boolbv.cpp @@ -348,8 +348,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr) assert(expr.operands().size()==2); bvt bv0=convert_bitvector(expr.op0()); bvt bv1=convert_bitvector(expr.op1()); - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.type()); + float_utilst float_utils(prop, to_floatbv_type(expr.type())); bvt bv=expr.id()==ID_float_debug1? float_utils.debug1(bv0, bv1): float_utils.debug2(bv0, bv1); @@ -643,8 +642,7 @@ literalt boolbvt::convert_rest(const exprt &expr) if(expr.op0().type().id()==ID_floatbv) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.op0().type()); + float_utilst float_utils(prop, to_floatbv_type(expr.op0().type())); return float_utils.is_NaN(bv); } else if(expr.op0().type().id()==ID_fixedbv) @@ -659,8 +657,7 @@ literalt boolbvt::convert_rest(const exprt &expr) if(expr.op0().type().id()==ID_floatbv) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.op0().type()); + float_utilst float_utils(prop, to_floatbv_type(expr.op0().type())); return prop.land( !float_utils.is_infinity(bv), !float_utils.is_NaN(bv)); @@ -677,8 +674,7 @@ literalt boolbvt::convert_rest(const exprt &expr) if(expr.op0().type().id()==ID_floatbv) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.op0().type()); + float_utilst float_utils(prop, to_floatbv_type(expr.op0().type())); return float_utils.is_infinity(bv); } else if(expr.op0().type().id()==ID_fixedbv) @@ -693,8 +689,7 @@ literalt boolbvt::convert_rest(const exprt &expr) if(expr.op0().type().id()==ID_floatbv) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.op0().type()); + float_utilst float_utils(prop, to_floatbv_type(expr.op0().type())); return float_utils.is_normal(bv); } else if(expr.op0().type().id()==ID_fixedbv) diff --git a/src/solvers/flattening/boolbv_abs.cpp b/src/solvers/flattening/boolbv_abs.cpp index 2ff88b35510..0a9f7a9c4a5 100644 --- a/src/solvers/flattening/boolbv_abs.cpp +++ b/src/solvers/flattening/boolbv_abs.cpp @@ -54,8 +54,7 @@ bvt boolbvt::convert_abs(const exprt &expr) } else if(bvtype==IS_FLOAT) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.type()); + float_utilst float_utils(prop, to_floatbv_type(expr.type())); return float_utils.abs(op_bv); } diff --git a/src/solvers/flattening/boolbv_add_sub.cpp b/src/solvers/flattening/boolbv_add_sub.cpp index fa0e936602e..38a7effc5af 100644 --- a/src/solvers/flattening/boolbv_add_sub.cpp +++ b/src/solvers/flattening/boolbv_add_sub.cpp @@ -127,8 +127,7 @@ bvt boolbvt::convert_add_sub(const exprt &expr) if(type.subtype().id()==ID_floatbv) { // needs to change due to rounding mode - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(subtype); + float_utilst float_utils(prop, to_floatbv_type(subtype)); tmp_result=float_utils.add_sub(tmp_result, tmp_op, subtract); } else @@ -146,8 +145,7 @@ bvt boolbvt::convert_add_sub(const exprt &expr) else if(type.id()==ID_floatbv) { // needs to change due to rounding mode - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(arithmetic_type); + float_utilst float_utils(prop, to_floatbv_type(arithmetic_type)); bv=float_utils.add_sub(bv, op, subtract); } else if(no_overflow) diff --git a/src/solvers/flattening/boolbv_bv_rel.cpp b/src/solvers/flattening/boolbv_bv_rel.cpp index 58520d0ec97..901cd31fa04 100644 --- a/src/solvers/flattening/boolbv_bv_rel.cpp +++ b/src/solvers/flattening/boolbv_bv_rel.cpp @@ -46,8 +46,7 @@ literalt boolbvt::convert_bv_rel(const exprt &expr) { if(bvtype0==IS_FLOAT) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(op0.type()); + float_utilst float_utils(prop, to_floatbv_type(op0.type())); if(rel==ID_le) return float_utils.relation(bv0, float_utilst::LE, bv1); diff --git a/src/solvers/flattening/boolbv_ieee_float_rel.cpp b/src/solvers/flattening/boolbv_ieee_float_rel.cpp index 33ce7e76746..bbdea7aea13 100644 --- a/src/solvers/flattening/boolbv_ieee_float_rel.cpp +++ b/src/solvers/flattening/boolbv_ieee_float_rel.cpp @@ -44,8 +44,7 @@ literalt boolbvt::convert_ieee_float_rel(const exprt &expr) if(bv0.size()==bv1.size() && !bv0.empty() && bvtype0==IS_FLOAT && bvtype1==IS_FLOAT) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(op0.type()); + float_utilst float_utils(prop, to_floatbv_type(op0.type())); if(rel==ID_ieee_float_equal) return float_utils.relation(bv0, float_utilst::EQ, bv1); diff --git a/src/solvers/flattening/boolbv_typecast.cpp b/src/solvers/flattening/boolbv_typecast.cpp index d193cd9d63a..5cd2e1cdf6d 100644 --- a/src/solvers/flattening/boolbv_typecast.cpp +++ b/src/solvers/flattening/boolbv_typecast.cpp @@ -204,8 +204,7 @@ bool boolbvt::type_conversion( // bool to float // build a one - ieee_floatt f; - f.spec=to_floatbv_type(dest_type); + ieee_floatt f(to_floatbv_type(dest_type)); f.from_integer(1); dest=convert_bv(f.to_expr()); @@ -498,8 +497,7 @@ bool boolbvt::type_conversion( if(src_bvtype==IS_FLOAT) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(src_type); + float_utilst float_utils(prop, to_floatbv_type(src_type)); dest[0]=!float_utils.is_zero(src); } else if(src_bvtype==IS_C_BOOL) diff --git a/src/solvers/flattening/boolbv_unary_minus.cpp b/src/solvers/flattening/boolbv_unary_minus.cpp index 2eb285a48d5..20a05b32df1 100644 --- a/src/solvers/flattening/boolbv_unary_minus.cpp +++ b/src/solvers/flattening/boolbv_unary_minus.cpp @@ -81,8 +81,7 @@ bvt boolbvt::convert_unary_minus(const unary_exprt &expr) if(type.subtype().id()==ID_floatbv) { - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(subtype); + float_utilst float_utils(prop, to_floatbv_type(subtype)); tmp_result=float_utils.negate(tmp_op); } else @@ -109,8 +108,7 @@ bvt boolbvt::convert_unary_minus(const unary_exprt &expr) else if(bvtype==IS_FLOAT && op_bvtype==IS_FLOAT) { assert(!no_overflow); - float_utilst float_utils(prop); - float_utils.spec=to_floatbv_type(expr.type()); + float_utilst float_utils(prop, to_floatbv_type(expr.type())); return float_utils.negate(op_bv); } else if((op_bvtype==IS_SIGNED || op_bvtype==IS_UNSIGNED) && diff --git a/src/solvers/floatbv/float_utils.h b/src/solvers/floatbv/float_utils.h index a0204236e91..6d83758bd94 100644 --- a/src/solvers/floatbv/float_utils.h +++ b/src/solvers/floatbv/float_utils.h @@ -69,6 +69,13 @@ class float_utilst { } + float_utilst(propt &_prop, const floatbv_typet &type): + spec(ieee_float_spect(type)), + prop(_prop), + bv_utils(_prop) + { + } + void set_rounding_mode(const bvt &); virtual ~float_utilst() diff --git a/src/solvers/smt2/smt2_conv.cpp b/src/solvers/smt2/smt2_conv.cpp index 32df575ff84..e3e3a983c58 100644 --- a/src/solvers/smt2/smt2_conv.cpp +++ b/src/solvers/smt2/smt2_conv.cpp @@ -2466,8 +2466,7 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) { constant_exprt val(dest_type); - ieee_floatt a; - a.spec=to_floatbv_type(dest_type); + ieee_floatt a(to_floatbv_type(dest_type)); mp_integer significand; mp_integer exponent; diff --git a/src/util/ieee_float.h b/src/util/ieee_float.h index ba6ea14bfec..dcb4c643e7f 100644 --- a/src/util/ieee_float.h +++ b/src/util/ieee_float.h @@ -131,6 +131,17 @@ class ieee_floatt { } + explicit ieee_floatt(const floatbv_typet &type): + rounding_mode(ROUND_TO_EVEN), + spec(ieee_float_spect(type)), + sign_flag(false), + exponent(0), + fraction(0), + NaN_flag(false), + infinity_flag(false) + { + } + ieee_floatt(): rounding_mode(ROUND_TO_EVEN), sign_flag(false), exponent(0), fraction(0), diff --git a/src/util/simplify_expr.cpp b/src/util/simplify_expr.cpp index 1c8dfd226c2..0dfa962e090 100644 --- a/src/util/simplify_expr.cpp +++ b/src/util/simplify_expr.cpp @@ -639,8 +639,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr) const floatbv_typet &f_expr_type= to_floatbv_type(expr_type); - ieee_floatt f; - f.spec=f_expr_type; + ieee_floatt f(f_expr_type); f.from_integer(int_value); expr=f.to_expr(); diff --git a/src/util/simplify_expr_floatbv.cpp b/src/util/simplify_expr_floatbv.cpp index 4a7d804266a..6ac02064596 100644 --- a/src/util/simplify_expr_floatbv.cpp +++ b/src/util/simplify_expr_floatbv.cpp @@ -290,9 +290,8 @@ bool simplify_exprt::simplify_floatbv_typecast(exprt &expr) { if(dest_type.id()==ID_floatbv) // int to float { - ieee_floatt result; + ieee_floatt result(to_floatbv_type(dest_type)); result.rounding_mode=(ieee_floatt::rounding_modet)integer2size_t(rounding_mode); - result.spec=to_floatbv_type(dest_type); result.from_integer(value); expr=result.to_expr(); return false; From 839e84f0ae7a2bce9f4901590e742c149d031b71 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 12:08:00 +0100 Subject: [PATCH 09/47] Do not use implicit conversion --- src/goto-programs/interpreter_evaluate.cpp | 6 +++--- src/solvers/flattening/boolbv_floatbv_op.cpp | 19 +++++++++++-------- src/solvers/flattening/boolbv_typecast.cpp | 4 ++-- src/solvers/refinement/refine_arithmetic.cpp | 2 +- src/util/bv_arithmetic.cpp | 2 +- src/util/bv_arithmetic.h | 5 +++++ src/util/fixedbv.cpp | 2 +- src/util/ieee_float.cpp | 2 +- src/util/rational_tools.cpp | 11 ++++++----- src/util/simplify_expr.cpp | 9 +++++---- src/util/simplify_expr_floatbv.cpp | 3 ++- src/util/simplify_expr_int.cpp | 6 ++++-- 12 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/goto-programs/interpreter_evaluate.cpp b/src/goto-programs/interpreter_evaluate.cpp index b73d1c61b43..9850f43ba81 100644 --- a/src/goto-programs/interpreter_evaluate.cpp +++ b/src/goto-programs/interpreter_evaluate.cpp @@ -262,7 +262,7 @@ void interpretert::evaluate( if(expr.type().id()==ID_fixedbv) { fixedbvt f; - f.spec=to_fixedbv_type(expr.type()); + f.spec=fixedbv_spect(to_fixedbv_type(expr.type())); f.from_integer(1); result=f.get_value(); } @@ -284,8 +284,8 @@ void interpretert::evaluate( if(expr.type().id()==ID_fixedbv) { fixedbvt f1, f2; - f1.spec=to_fixedbv_type(expr.type()); - f2.spec=to_fixedbv_type(it->type()); + f1.spec=fixedbv_spect(to_fixedbv_type(expr.type())); + f2.spec=fixedbv_spect(to_fixedbv_type(it->type())); f1.set_value(result); f2.set_value(tmp.front()); f1*=f2; diff --git a/src/solvers/flattening/boolbv_floatbv_op.cpp b/src/solvers/flattening/boolbv_floatbv_op.cpp index f05a8b39b5d..087faa0485a 100644 --- a/src/solvers/flattening/boolbv_floatbv_op.cpp +++ b/src/solvers/flattening/boolbv_floatbv_op.cpp @@ -48,33 +48,36 @@ bvt boolbvt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) if(src_type.id()==ID_floatbv && dest_type.id()==ID_floatbv) { - float_utils.spec=to_floatbv_type(src_type); - return float_utils.conversion(bv0, to_floatbv_type(dest_type)); + float_utils.spec=ieee_float_spect(to_floatbv_type(src_type)); + return + float_utils.conversion( + bv0, + ieee_float_spect(to_floatbv_type(dest_type))); } else if(src_type.id()==ID_signedbv && dest_type.id()==ID_floatbv) { - float_utils.spec=to_floatbv_type(dest_type); + float_utils.spec=ieee_float_spect(to_floatbv_type(dest_type)); return float_utils.from_signed_integer(bv0); } else if(src_type.id()==ID_unsignedbv && dest_type.id()==ID_floatbv) { - float_utils.spec=to_floatbv_type(dest_type); + float_utils.spec=ieee_float_spect(to_floatbv_type(dest_type)); return float_utils.from_unsigned_integer(bv0); } else if(src_type.id()==ID_floatbv && dest_type.id()==ID_signedbv) { std::size_t dest_width=to_signedbv_type(dest_type).get_width(); - float_utils.spec=to_floatbv_type(src_type); + float_utils.spec=ieee_float_spect(to_floatbv_type(src_type)); return float_utils.to_signed_integer(bv0, dest_width); } else if(src_type.id()==ID_floatbv && dest_type.id()==ID_unsignedbv) { std::size_t dest_width=to_unsignedbv_type(dest_type).get_width(); - float_utils.spec=to_floatbv_type(src_type); + float_utils.spec=ieee_float_spect(to_floatbv_type(src_type)); return float_utils.to_unsigned_integer(bv0, dest_width); } else @@ -122,7 +125,7 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr) if(type.id()==ID_floatbv) { - float_utils.spec=to_floatbv_type(expr.type()); + float_utils.spec=ieee_float_spect(to_floatbv_type(expr.type())); if(expr.id()==ID_floatbv_plus) return float_utils.add_sub(bv0, bv1, false); @@ -143,7 +146,7 @@ bvt boolbvt::convert_floatbv_op(const exprt &expr) if(subtype.id()==ID_floatbv) { - float_utils.spec=to_floatbv_type(subtype); + float_utils.spec=ieee_float_spect(to_floatbv_type(subtype)); std::size_t width=boolbv_width(type); std::size_t sub_width=boolbv_width(subtype); diff --git a/src/solvers/flattening/boolbv_typecast.cpp b/src/solvers/flattening/boolbv_typecast.cpp index 5cd2e1cdf6d..c7ab6410214 100644 --- a/src/solvers/flattening/boolbv_typecast.cpp +++ b/src/solvers/flattening/boolbv_typecast.cpp @@ -183,13 +183,13 @@ bool boolbvt::type_conversion( case IS_SIGNED: // signed to float case IS_C_ENUM: - float_utils.spec=to_floatbv_type(dest_type); + float_utils.spec=ieee_float_spect(to_floatbv_type(dest_type)); dest=float_utils.from_signed_integer(src); return false; case IS_UNSIGNED: // unsigned to float case IS_C_BOOL: // _Bool to float - float_utils.spec=to_floatbv_type(dest_type); + float_utils.spec=ieee_float_spect(to_floatbv_type(dest_type)); dest=float_utils.from_unsigned_integer(src); return false; diff --git a/src/solvers/refinement/refine_arithmetic.cpp b/src/solvers/refinement/refine_arithmetic.cpp index eb774866c02..58c0b7f4f53 100644 --- a/src/solvers/refinement/refine_arithmetic.cpp +++ b/src/solvers/refinement/refine_arithmetic.cpp @@ -478,7 +478,7 @@ void bv_refinementt::check_UNSAT(approximationt &a) if(a.expr.type().id()==ID_floatbv) { const floatbv_typet &floatbv_type=to_floatbv_type(a.expr.type()); - ieee_float_spect spec=floatbv_type; + ieee_float_spect spec(floatbv_type); a.under_assumptions.reserve(a.op0_bv.size()+a.op1_bv.size()); diff --git a/src/util/bv_arithmetic.cpp b/src/util/bv_arithmetic.cpp index 93c5cb3ce9c..2b0d9455e36 100644 --- a/src/util/bv_arithmetic.cpp +++ b/src/util/bv_arithmetic.cpp @@ -471,6 +471,6 @@ Function: bv_arithmetict::from_expr void bv_arithmetict::from_expr(const exprt &expr) { assert(expr.is_constant()); - spec=expr.type(); + spec=bv_spect(expr.type()); value=binary2integer(expr.get_string(ID_value), spec.is_signed); } diff --git a/src/util/bv_arithmetic.h b/src/util/bv_arithmetic.h index 888cdd2606c..30857dc8ca2 100644 --- a/src/util/bv_arithmetic.h +++ b/src/util/bv_arithmetic.h @@ -38,6 +38,11 @@ class bv_spect mp_integer min_value() const; typet to_type() const; + + bool operator==(const bv_spect &other) const + { + return width==other.width && is_signed==other.is_signed; + } }; class bv_arithmetict diff --git a/src/util/fixedbv.cpp b/src/util/fixedbv.cpp index 9d1fee75d64..3162b8719d0 100644 --- a/src/util/fixedbv.cpp +++ b/src/util/fixedbv.cpp @@ -60,7 +60,7 @@ Function: fixedbvt::from_expr void fixedbvt::from_expr(const constant_exprt &expr) { - spec=to_fixedbv_type(expr.type()); + spec=fixedbv_spect(to_fixedbv_type(expr.type())); v=binary2integer(id2string(expr.get_value()), true); } diff --git a/src/util/ieee_float.cpp b/src/util/ieee_float.cpp index 6ad3e417e39..f1768c284ca 100644 --- a/src/util/ieee_float.cpp +++ b/src/util/ieee_float.cpp @@ -1423,7 +1423,7 @@ Function: ieee_floatt::from_expr void ieee_floatt::from_expr(const constant_exprt &expr) { - spec=to_floatbv_type(expr.type()); + spec=ieee_float_spect(to_floatbv_type(expr.type())); unpack(binary2integer(id2string(expr.get_value()), false)); } diff --git a/src/util/rational_tools.cpp b/src/util/rational_tools.cpp index 22b5263a485..167e2e7e3f0 100644 --- a/src/util/rational_tools.cpp +++ b/src/util/rational_tools.cpp @@ -81,17 +81,18 @@ bool to_rational(const exprt &expr, rationalt &rational_value) switch(mode) { case 0: - rational_value=string2integer(no1); + rational_value=rationalt(string2integer(no1)); break; case '.': - rational_value=string2integer(no1); - rational_value+=rationalt(string2integer(no2))/power10(no2.size()); + rational_value=rationalt(string2integer(no1)); + rational_value+= + rationalt(string2integer(no2))/rationalt(power10(no2.size())); break; case '/': - rational_value=string2integer(no1); - rational_value/=string2integer(no2); + rational_value=rationalt(string2integer(no1)); + rational_value/=rationalt(string2integer(no2)); break; default: diff --git a/src/util/simplify_expr.cpp b/src/util/simplify_expr.cpp index 0dfa962e090..a5f9b69c943 100644 --- a/src/util/simplify_expr.cpp +++ b/src/util/simplify_expr.cpp @@ -626,7 +626,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr) to_fixedbv_type(expr_type); fixedbvt f; - f.spec=f_expr_type; + f.spec=fixedbv_spect(f_expr_type); f.from_integer(int_value); expr=f.to_expr(); @@ -648,7 +648,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr) if(expr_type_id==ID_rational) { - rationalt r=int_value; + rationalt r(int_value); expr=from_rational(r); return false; } @@ -668,7 +668,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr) { // fixedbv to fixedbv fixedbvt f(to_constant_expr(expr.op0())); - f.round(to_fixedbv_type(expr_type)); + f.round(fixedbv_spect(to_fixedbv_type(expr_type))); expr=f.to_expr(); return false; } @@ -687,7 +687,8 @@ bool simplify_exprt::simplify_typecast(exprt &expr) else if(expr_type_id==ID_floatbv) { // float to double or double to float - f.change_spec(to_floatbv_type(expr_type)); + ieee_floatt f(to_constant_expr(expr.op0())); + f.change_spec(ieee_float_spect(to_floatbv_type(expr_type))); expr=f.to_expr(); return false; } diff --git a/src/util/simplify_expr_floatbv.cpp b/src/util/simplify_expr_floatbv.cpp index 6ac02064596..d798505a36d 100644 --- a/src/util/simplify_expr_floatbv.cpp +++ b/src/util/simplify_expr_floatbv.cpp @@ -265,7 +265,8 @@ bool simplify_exprt::simplify_floatbv_typecast(exprt &expr) { ieee_floatt result(to_constant_expr(op0)); result.rounding_mode=(ieee_floatt::rounding_modet)integer2size_t(rounding_mode); - result.change_spec(to_floatbv_type(dest_type)); + result.change_spec( + ieee_float_spect(to_floatbv_type(dest_type))); expr=result.to_expr(); return false; } diff --git a/src/util/simplify_expr_int.cpp b/src/util/simplify_expr_int.cpp index ffb51d7a328..8c19236e0d9 100644 --- a/src/util/simplify_expr_int.cpp +++ b/src/util/simplify_expr_int.cpp @@ -1888,9 +1888,11 @@ bool simplify_exprt::simplify_inequality_constant(exprt &expr) { ieee_floatt const_val(to_constant_expr(expr.op1())); ieee_floatt const_val_converted=const_val; - const_val_converted.change_spec(to_floatbv_type(ns.follow(expr.op0().op0().type()))); + const_val_converted.change_spec( + ieee_float_spect(to_floatbv_type(ns.follow(expr.op0().op0().type())))); ieee_floatt const_val_converted_back=const_val_converted; - const_val_converted_back.change_spec(to_floatbv_type(ns.follow(expr.op0().type()))); + const_val_converted_back.change_spec( + ieee_float_spect(to_floatbv_type(ns.follow(expr.op0().type())))); if(const_val_converted_back==const_val) { exprt result=expr; From 61f747ddc46d031ac5240c036012226c40168b84 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 11:52:24 +0100 Subject: [PATCH 10/47] Use member operators instead of global-scope friends --- src/analyses/local_bitvector_analysis.h | 28 +-- src/ansi-c/c_qualifiers.h | 32 ++- src/ansi-c/c_storage_spec.h | 48 ++--- src/ansi-c/c_typecast.cpp | 2 +- src/ansi-c/string_constant.h | 25 +-- src/cpp/cpp_typecheck_resolve.h | 11 +- src/goto-cc/xml_binaries/xml_irep_hashing.h | 2 +- src/goto-instrument/call_sequences.cpp | 25 +-- src/goto-instrument/object_id.h | 16 +- src/goto-instrument/points_to.h | 15 +- src/goto-instrument/wmm/abstract_event.h | 13 +- .../java_bytecode_convert_method.cpp | 13 +- src/java_bytecode/java_entry_point.cpp | 2 +- src/pointer-analysis/value_set_analysis.h | 20 +- src/solvers/miniBDD/miniBDD.cpp | 16 +- src/solvers/miniBDD/miniBDD.h | 4 +- src/solvers/prop/literal.h | 38 ++-- src/solvers/qbf/qdimacs_cnf.cpp | 7 +- src/solvers/qbf/qdimacs_cnf.h | 7 +- src/util/bv_arithmetic.cpp | 40 ++-- src/util/bv_arithmetic.h | 28 +-- src/util/dstring.h | 38 ++-- src/util/expr.cpp | 17 -- src/util/expr.h | 2 - src/util/fixedbv.h | 19 +- src/util/guard.h | 2 - src/util/ieee_float.cpp | 136 ++++++------ src/util/ieee_float.h | 51 ++--- src/util/irep.cpp | 52 ++--- src/util/irep.h | 16 +- src/util/lispexpr.h | 55 ++--- src/util/rational.cpp | 23 +- src/util/rational.h | 67 +++--- src/util/rational_tools.cpp | 5 +- src/util/simplify_expr_floatbv.cpp | 4 +- src/util/std_code.h | 141 ++++++------ src/util/std_expr.h | 202 ++++++++---------- src/util/std_types.h | 72 +++---- src/util/string_container.cpp | 10 +- src/util/string_container.h | 4 +- src/util/threeval.h | 32 +-- src/util/timer.h | 10 +- 42 files changed, 637 insertions(+), 713 deletions(-) diff --git a/src/analyses/local_bitvector_analysis.h b/src/analyses/local_bitvector_analysis.h index ad0035b9e5e..aa0e3570922 100644 --- a/src/analyses/local_bitvector_analysis.h +++ b/src/analyses/local_bitvector_analysis.h @@ -167,20 +167,14 @@ class local_bitvector_analysist } void print(std::ostream &) const; - }; - - friend std::ostream & operator << (std::ostream &out, const flagst f) - { - f.print(out); - return out; - } - inline friend flagst operator|(const flagst f1, const flagst f2) - { - flagst result=f1; - result.bits|=f2.bits; - return result; - } + inline flagst operator|(const flagst other) const + { + flagst result(*this); + result.bits|=other.bits; + return result; + } + }; flagst get( const goto_programt::const_targett t, @@ -222,4 +216,12 @@ class local_bitvector_analysist bool is_tracked(const irep_idt &identifier); }; +inline std::ostream &operator<<( + std::ostream &out, + const local_bitvector_analysist::flagst &flags) +{ + flags.print(out); + return out; +} + #endif // CPROVER_ANALYSES_LOCAL_BITVECTOR_ANALYSIS_H diff --git a/src/ansi-c/c_qualifiers.h b/src/ansi-c/c_qualifiers.h index 3d0da08b8a6..a499255cc55 100644 --- a/src/ansi-c/c_qualifiers.h +++ b/src/ansi-c/c_qualifiers.h @@ -68,25 +68,21 @@ class c_qualifierst // is_transparent_union isn't checked } - friend bool operator == ( - const c_qualifierst &a, - const c_qualifierst &b) + bool operator==(const c_qualifierst &other) const { - return a.is_constant==b.is_constant && - a.is_volatile==b.is_volatile && - a.is_restricted==b.is_restricted && - a.is_atomic==b.is_atomic && - a.is_ptr32==b.is_ptr32 && - a.is_ptr64==b.is_ptr64 && - a.is_transparent_union==b.is_transparent_union && - a.is_noreturn==b.is_noreturn; + return is_constant==other.is_constant && + is_volatile==other.is_volatile && + is_restricted==other.is_restricted && + is_atomic==other.is_atomic && + is_ptr32==other.is_ptr32 && + is_ptr64==other.is_ptr64 && + is_transparent_union==other.is_transparent_union && + is_noreturn==other.is_noreturn; } - friend bool operator != ( - const c_qualifierst &a, - const c_qualifierst &b) + bool operator!=(const c_qualifierst &other) const { - return !(a==b); + return !(*this==other); } c_qualifierst &operator += ( @@ -103,10 +99,10 @@ class c_qualifierst return *this; } - friend unsigned count(const c_qualifierst &q) + unsigned count() const { - return q.is_constant+q.is_volatile+q.is_restricted+q.is_atomic+ - q.is_ptr32+q.is_ptr64+q.is_noreturn; + return is_constant+is_volatile+is_restricted+is_atomic+ + is_ptr32+is_ptr64+is_noreturn; } }; diff --git a/src/ansi-c/c_storage_spec.h b/src/ansi-c/c_storage_spec.h index 9394552b5ca..d735e578426 100644 --- a/src/ansi-c/c_storage_spec.h +++ b/src/ansi-c/c_storage_spec.h @@ -49,42 +49,36 @@ class c_storage_spect irep_idt asm_label; irep_idt section; - friend bool operator == ( - const c_storage_spect &a, - const c_storage_spect &b) + bool operator==(const c_storage_spect &other) const { - return a.is_typedef==b.is_typedef && - a.is_extern==b.is_extern && - a.is_static==b.is_static && - a.is_register==b.is_register && - a.is_thread_local==b.is_thread_local && - a.is_inline==b.is_inline && - a.is_weak==b.is_weak && - a.alias==b.alias && - a.asm_label==b.asm_label && - a.section==b.section; + return is_typedef==other.is_typedef && + is_extern==other.is_extern && + is_static==other.is_static && + is_register==other.is_register && + is_thread_local==other.is_thread_local && + is_inline==other.is_inline && + is_weak==other.is_weak && + alias==other.alias && + asm_label==other.asm_label && + section==other.section; } - friend bool operator != ( - const c_storage_spect &a, - const c_storage_spect &b) + bool operator!=(const c_storage_spect &other) const { - return !(a==b); + return !(*this==other); } - friend c_storage_spect &operator |= ( - c_storage_spect &a, - const c_storage_spect &b) + c_storage_spect &operator|=(const c_storage_spect &other) { - a.is_typedef |=b.is_typedef; - a.is_extern |=b.is_extern; - a.is_static |=b.is_static; - a.is_register |=b.is_register; - a.is_inline |=b.is_inline; - a.is_thread_local |=b.is_thread_local; + is_typedef |=other.is_typedef; + is_extern |=other.is_extern; + is_static |=other.is_static; + is_register |=other.is_register; + is_inline |=other.is_inline; + is_thread_local |=other.is_thread_local; // attributes belong to the declarator, don't replace them - return a; + return *this; } void read(const typet &type); diff --git a/src/ansi-c/c_typecast.cpp b/src/ansi-c/c_typecast.cpp index 06698fbd564..d8ac037de77 100644 --- a/src/ansi-c/c_typecast.cpp +++ b/src/ansi-c/c_typecast.cpp @@ -620,7 +620,7 @@ void c_typecastt::implicit_typecast_followed( // build union constructor exprt union_expr(ID_union, orig_dest_type); union_expr.move_to_operands(expr); - if(!full_eq(src_type, src_type_no_const)) + if(!src_type.full_eq(src_type_no_const)) do_typecast(union_expr.op0(), src_type_no_const); union_expr.set(ID_component_name, comp.get_name()); expr=union_expr; diff --git a/src/ansi-c/string_constant.h b/src/ansi-c/string_constant.h index ad38fa2dc43..060459f7d0c 100644 --- a/src/ansi-c/string_constant.h +++ b/src/ansi-c/string_constant.h @@ -18,18 +18,6 @@ class string_constantt:public exprt string_constantt(); explicit string_constantt(const irep_idt &value); - friend inline const string_constantt &to_string_constant(const exprt &expr) - { - assert(expr.id()==ID_string_constant); - return static_cast(expr); - } - - friend inline string_constantt &to_string_constant(exprt &expr) - { - assert(expr.id()==ID_string_constant); - return static_cast(expr); - } - void set_value(const irep_idt &value); inline const irep_idt &get_value() const @@ -41,7 +29,16 @@ class string_constantt:public exprt bool from_array_expr(const array_exprt &); }; -const string_constantt &to_string_constant(const exprt &expr); -string_constantt &to_string_constant(exprt &expr); +inline const string_constantt &to_string_constant(const exprt &expr) +{ + assert(expr.id()==ID_string_constant); + return static_cast(expr); +} + +inline string_constantt &to_string_constant(exprt &expr) +{ + assert(expr.id()==ID_string_constant); + return static_cast(expr); +} #endif // CPROVER_ANSI_C_STRING_CONSTANT_H diff --git a/src/cpp/cpp_typecheck_resolve.h b/src/cpp/cpp_typecheck_resolve.h index 108bb8c1db6..fb587c93b80 100644 --- a/src/cpp/cpp_typecheck_resolve.h +++ b/src/cpp/cpp_typecheck_resolve.h @@ -146,13 +146,12 @@ class cpp_typecheck_resolvet id(_id) { } - }; - - inline friend bool operator < (const matcht &m1, const matcht &m2) - { - return m1.costfirst==e2.f->first && - e1.return_address==e2.return_address; - } + bool operator==(const call_stack_entryt &other) const + { + return + f->first==other.f->first && + return_address==other.return_address; + } + }; struct statet { @@ -189,12 +189,13 @@ class check_call_sequencet std::vector call_stack; unsigned index; - friend bool operator==(const statet &s1, const statet &s2) + bool operator==(const statet &other) const { - return s1.f->first==s2.f->first && - s1.pc==s2.pc && - s1.call_stack==s2.call_stack && - s1.index==s2.index; + return + f->first==other.f->first && + pc==other.pc && + call_stack==other.call_stack && + index==other.index; } }; diff --git a/src/goto-instrument/object_id.h b/src/goto-instrument/object_id.h index eb804de26d7..336585d7260 100644 --- a/src/goto-instrument/object_id.h +++ b/src/goto-instrument/object_id.h @@ -30,22 +30,26 @@ class object_idt id=identifier; } - friend std::ostream &operator << (std::ostream &out, const object_idt &x) + inline bool operator<(const object_idt &other) const { - return out << x.id; + return id < other.id; } - friend inline bool operator < (const object_idt &a, const object_idt &b) + const irep_idt &get_id() const { - return a.id < b.id; + return id; } protected: irep_idt id; }; -inline std::ostream &operator << (std::ostream &, const object_idt &); -inline bool operator < (const object_idt &a, const object_idt &b); +inline std::ostream &operator<<( + std::ostream &out, + const object_idt &object_id) +{ + return out << object_id.get_id(); +} typedef std::set object_id_sett; diff --git a/src/goto-instrument/points_to.h b/src/goto-instrument/points_to.h index 5b605cee337..45c87c1a1cd 100644 --- a/src/goto-instrument/points_to.h +++ b/src/goto-instrument/points_to.h @@ -49,13 +49,6 @@ class points_tot void output(std::ostream &out) const; - inline friend std::ostream &operator << ( - std::ostream &out, const points_tot &points_to) - { - points_to.output(out); - return out; - } - protected: typedef cfg_baset cfgt; cfgt cfg; @@ -69,6 +62,12 @@ class points_tot const object_id_sett empty_set; }; -std::ostream &operator << (std::ostream &, const points_tot &); +inline std::ostream &operator<<( + std::ostream &out, + const points_tot &points_to) +{ + points_to.output(out); + return out; +} #endif // CPROVER_GOTO_INSTRUMENT_POINTS_TO_H diff --git a/src/goto-instrument/wmm/abstract_event.h b/src/goto-instrument/wmm/abstract_event.h index c94708f30fe..f30b3686b1e 100644 --- a/src/goto-instrument/wmm/abstract_event.h +++ b/src/goto-instrument/wmm/abstract_event.h @@ -91,11 +91,6 @@ class abstract_eventt:public graph_nodet inline bool is_fence() const { return operation==Fence || operation==Lwfence || operation==ASMfence;} - friend std::ostream& operator<<(std::ostream& s, const abstract_eventt& e) - { - return s << e.get_operation() << e.variable; - } - /* checks the safety of the pair locally (i.e., w/o taking fences or dependencies into account -- use is_unsafe on the whole critical cycle for this) */ @@ -152,4 +147,12 @@ class abstract_eventt:public graph_nodet return value; } }; + +inline std::ostream& operator<<( + std::ostream& s, + const abstract_eventt &e) +{ + return s << e.get_operation() << e.variable; +} + #endif // CPROVER_GOTO_INSTRUMENT_WMM_ABSTRACT_EVENT_H diff --git a/src/java_bytecode/java_bytecode_convert_method.cpp b/src/java_bytecode/java_bytecode_convert_method.cpp index f9cb121091b..86b717e98b4 100644 --- a/src/java_bytecode/java_bytecode_convert_method.cpp +++ b/src/java_bytecode/java_bytecode_convert_method.cpp @@ -41,21 +41,26 @@ class patternt } // match with '?' - friend bool operator==(const irep_idt &what, const patternt &pattern) + bool operator==(const irep_idt &what) const { for(std::size_t i=0; iy.var) return false; - if(x.lowy.low) return false; - return x.highother.var || low>other.low) + return false; + + return high reverse_mapt; reverse_mapt reverse_map; diff --git a/src/solvers/prop/literal.h b/src/solvers/prop/literal.h index a15cb3aabc8..a11b4ff2a45 100644 --- a/src/solvers/prop/literal.h +++ b/src/solvers/prop/literal.h @@ -39,34 +39,34 @@ class literalt set(v, sign); } - friend inline bool operator ==(const literalt a, const literalt b) + inline bool operator==(const literalt other) const { - return a.l==b.l; + return l==other.l; } - friend inline bool operator !=(const literalt a, const literalt b) + inline bool operator!=(const literalt other) const { - return a.l!=b.l; + return l!=other.l; } // for sets - friend inline bool operator <(const literalt a, const literalt b) + inline bool operator<(const literalt other) const { - return a.l>1; @@ -190,10 +182,14 @@ class literalt std::ostream & operator << (std::ostream &out, literalt l); // constants -literalt const_literal(bool value); +inline literalt const_literal(bool value) +{ + return literalt(literalt::const_var_no(), value); +} + +inline literalt neg(literalt a) { return !a; } +inline literalt pos(literalt a) { return a; } -literalt neg(literalt a); -literalt pos(literalt a); // bit-vectors typedef std::vector bvt; diff --git a/src/solvers/qbf/qdimacs_cnf.cpp b/src/solvers/qbf/qdimacs_cnf.cpp index 6899921fccd..380f31ec12a 100644 --- a/src/solvers/qbf/qdimacs_cnf.cpp +++ b/src/solvers/qbf/qdimacs_cnf.cpp @@ -87,7 +87,7 @@ void qdimacs_cnft::write_prefix(std::ostream &out) const /*******************************************************************\ -Function: operator== +Function: qdimacs_cnft::operator== Inputs: @@ -97,10 +97,9 @@ Function: operator== \*******************************************************************/ -bool operator==(const qdimacs_cnft &a, const qdimacs_cnft &b) +bool qdimacs_cnft::operator==(const qdimacs_cnft &other) const { - return a.quantifiers==b.quantifiers && - a.clauses==b.clauses; + return quantifiers==other.quantifiers && clauses==other.clauses; } /*******************************************************************\ diff --git a/src/solvers/qbf/qdimacs_cnf.h b/src/solvers/qbf/qdimacs_cnf.h index 5e4b342836a..0ccccc3aa04 100644 --- a/src/solvers/qbf/qdimacs_cnf.h +++ b/src/solvers/qbf/qdimacs_cnf.h @@ -44,9 +44,9 @@ class qdimacs_cnft:public dimacs_cnft { } - friend bool operator==(const quantifiert &a, const quantifiert &b) + bool operator==(const quantifiert &other) const { - return a.type==b.type && a.var_no==b.var_no; + return type==other.type && var_no==other.var_no; } size_t hash() const @@ -85,7 +85,8 @@ class qdimacs_cnft:public dimacs_cnft virtual void set_quantifier(const quantifiert::typet type, const literalt l); void copy_to(qdimacs_cnft &cnf) const; - friend bool operator==(const qdimacs_cnft &a, const qdimacs_cnft &b); + bool operator==(const qdimacs_cnft &other) const; + size_t hash() const; protected: diff --git a/src/util/bv_arithmetic.cpp b/src/util/bv_arithmetic.cpp index 2b0d9455e36..6478e4ac2f3 100644 --- a/src/util/bv_arithmetic.cpp +++ b/src/util/bv_arithmetic.cpp @@ -331,14 +331,14 @@ Function: operator < \*******************************************************************/ -bool operator < (const bv_arithmetict &a, const bv_arithmetict &b) +bool bv_arithmetict::operator<(const bv_arithmetict &other) { - return a.value +Function: bv_arithmetict::operator> Inputs: @@ -365,14 +365,14 @@ Function: operator > \*******************************************************************/ -bool operator > (const bv_arithmetict &a, const bv_arithmetict &b) +bool bv_arithmetict::operator>(const bv_arithmetict &other) { - return a.value>b.value; + return value>other.value; } /*******************************************************************\ -Function: operator >= +Function: bv_arithmetict::operator>= Inputs: @@ -382,14 +382,14 @@ Function: operator >= \*******************************************************************/ -bool operator >=(const bv_arithmetict &a, const bv_arithmetict &b) +bool bv_arithmetict::operator>=(const bv_arithmetict &other) { - return a.value>=b.value; + return value>=other.value; } /*******************************************************************\ -Function: operator == +Function: bv_arithmetict::operator== Inputs: @@ -399,14 +399,14 @@ Function: operator == \*******************************************************************/ -bool operator ==(const bv_arithmetict &a, const bv_arithmetict &b) +bool bv_arithmetict::operator==(const bv_arithmetict &other) { - return a.value==b.value; + return value==other.value; } /*******************************************************************\ -Function: operator == +Function: bv_arithmetict::operator== Inputs: @@ -416,14 +416,14 @@ Function: operator == \*******************************************************************/ -bool operator ==(const bv_arithmetict &a, int i) +bool bv_arithmetict::operator==(int i) { - return a.value==i; + return value==i; } /*******************************************************************\ -Function: operator != +Function: bv_arithmetict::operator!= Inputs: @@ -433,9 +433,9 @@ Function: operator != \*******************************************************************/ -bool operator !=(const bv_arithmetict &a, const bv_arithmetict &b) +bool bv_arithmetict::operator!=(const bv_arithmetict &other) { - return a.value!=b.value; + return value!=other.value; } /*******************************************************************\ diff --git a/src/util/bv_arithmetic.h b/src/util/bv_arithmetic.h index 30857dc8ca2..d054214e8aa 100644 --- a/src/util/bv_arithmetic.h +++ b/src/util/bv_arithmetic.h @@ -99,17 +99,17 @@ class bv_arithmetict bv_arithmetict &operator -= (const bv_arithmetict &other); bv_arithmetict &operator %= (const bv_arithmetict &other); - friend bool operator < (const bv_arithmetict &a, const bv_arithmetict &b); - friend bool operator <=(const bv_arithmetict &a, const bv_arithmetict &b); - friend bool operator > (const bv_arithmetict &a, const bv_arithmetict &b); - friend bool operator >=(const bv_arithmetict &a, const bv_arithmetict &b); - friend bool operator ==(const bv_arithmetict &a, const bv_arithmetict &b); - friend bool operator !=(const bv_arithmetict &a, const bv_arithmetict &b); - friend bool operator ==(const bv_arithmetict &a, int i); - - friend std::ostream& operator << (std::ostream &out, const bv_arithmetict &f) + bool operator<(const bv_arithmetict &other); + bool operator<=(const bv_arithmetict &other); + bool operator>(const bv_arithmetict &other); + bool operator>=(const bv_arithmetict &other); + bool operator==(const bv_arithmetict &other); + bool operator!=(const bv_arithmetict &other); + bool operator==(int i); + + std::ostream& operator<<(std::ostream &out) { - return out << f.to_ansi_c_string(); + return out << to_ansi_c_string(); } // turn into natural number representation @@ -124,12 +124,4 @@ class bv_arithmetict void adjust(); }; -bool operator < (const bv_arithmetict &a, const bv_arithmetict &b); -bool operator <=(const bv_arithmetict &a, const bv_arithmetict &b); -bool operator > (const bv_arithmetict &a, const bv_arithmetict &b); -bool operator >=(const bv_arithmetict &a, const bv_arithmetict &b); -bool operator ==(const bv_arithmetict &a, const bv_arithmetict &b); -bool operator !=(const bv_arithmetict &a, const bv_arithmetict &b); -std::ostream& operator << (std::ostream &, const bv_arithmetict &); - #endif // CPROVER_UTIL_BV_ARITHMETIC_H diff --git a/src/util/dstring.h b/src/util/dstring.h index 93843b40147..49f3d0da483 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -104,11 +104,6 @@ class dstring return as_string().compare(b.as_string()); } - inline friend bool ordering(const dstring &a, const dstring &b) - { - return a.no (const fixedbvt &a, const fixedbvt &b) { return a.v>b.v; } - friend bool operator >=(const fixedbvt &a, const fixedbvt &b) { return a.v>=b.v; } - friend bool operator ==(const fixedbvt &a, const fixedbvt &b) { return a.v==b.v; } - friend bool operator !=(const fixedbvt &a, const fixedbvt &b) { return a.v!=b.v; } + bool operator<(const fixedbvt &other) const { return v(const fixedbvt &other) const { return v>other.v; } + bool operator>=(const fixedbvt &other) const { return v>=other.v; } + bool operator==(const fixedbvt &other) const { return v==other.v; } + bool operator!=(const fixedbvt &other) const { return v!=other.v; } const mp_integer &get_value() const { return v; } void set_value(const mp_integer &_v) { v=_v; } @@ -89,11 +89,4 @@ class fixedbvt mp_integer v; }; -bool operator < (const fixedbvt &a, const fixedbvt &b); -bool operator <=(const fixedbvt &a, const fixedbvt &b); -bool operator > (const fixedbvt &a, const fixedbvt &b); -bool operator >=(const fixedbvt &a, const fixedbvt &b); -bool operator ==(const fixedbvt &a, const fixedbvt &b); -bool operator !=(const fixedbvt &a, const fixedbvt &b); - #endif // CPROVER_UTIL_FIXEDBV_H diff --git a/src/util/guard.h b/src/util/guard.h index 7344fc10d2e..fe9fa500f69 100644 --- a/src/util/guard.h +++ b/src/util/guard.h @@ -66,8 +66,6 @@ class guardt:public exprt guard_list.swap(g.guard_list); } - friend std::ostream &operator << (std::ostream &out, const guardt &g); - size_type size() const { return guard_list.size(); diff --git a/src/util/ieee_float.cpp b/src/util/ieee_float.cpp index f1768c284ca..556008d6515 100644 --- a/src/util/ieee_float.cpp +++ b/src/util/ieee_float.cpp @@ -1148,7 +1148,7 @@ ieee_floatt &ieee_floatt::operator -= (const ieee_floatt &other) /*******************************************************************\ -Function: operator < +Function: ieee_floatt::operator< Inputs: @@ -1158,54 +1158,54 @@ Function: operator < \*******************************************************************/ -bool operator < (const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::operator<(const ieee_floatt &other) const { - if(a.NaN_flag || b.NaN_flag) return false; + if(NaN_flag || other.NaN_flag) return false; // check both zero? - if(a.is_zero() && b.is_zero()) + if(is_zero() && other.is_zero()) return false; // one of them zero? - if(a.is_zero()) - return !b.sign_flag; - else if(b.is_zero()) - return a.sign_flag; + if(is_zero()) + return !other.sign_flag; + else if(other.is_zero()) + return sign_flag; // check sign - if(a.sign_flag!=b.sign_flag) - return a.sign_flag; + if(sign_flag!=other.sign_flag) + return sign_flag; // handle infinity - if(a.infinity_flag) + if(infinity_flag) { - if(b.infinity_flag) + if(other.infinity_flag) return false; else - return a.sign_flag; + return sign_flag; } - else if(b.infinity_flag) - return !a.sign_flag; + else if(other.infinity_flag) + return !sign_flag; // check exponent - if(a.exponent!=b.exponent) + if(exponent!=other.exponent) { - if(a.sign_flag) // both negative - return a.exponent>b.exponent; + if(sign_flag) // both negative + return exponent>other.exponent; else - return a.exponentb.fraction; + if(sign_flag) // both negative + return fraction>other.fraction; else - return a.fraction +Function: ieee_floatt::operator> Inputs: @@ -1248,14 +1249,14 @@ Function: operator > \*******************************************************************/ -bool operator > (const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::operator>(const ieee_floatt &other) const { - return b < a; + return other<*this; } /*******************************************************************\ -Function: operator >= +Function: ieee_floatt::operator>= Inputs: @@ -1265,14 +1266,14 @@ Function: operator >= \*******************************************************************/ -bool operator >=(const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::operator>=(const ieee_floatt &other) const { - return b <= a; + return other<=*this; } /*******************************************************************\ -Function: operator == +Function: ieee_floatt::operator== Inputs: @@ -1282,29 +1283,31 @@ Function: operator == \*******************************************************************/ -bool operator ==(const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::operator==(const ieee_floatt &other) const { // packed equality! - if(a.NaN_flag && b.NaN_flag) + if(NaN_flag && other.NaN_flag) return true; - else if(a.NaN_flag || b.NaN_flag) + else if(NaN_flag || other.NaN_flag) return false; - if(a.infinity_flag && b.infinity_flag && - a.sign_flag == b.sign_flag) return true; - else if(a.infinity_flag || b.infinity_flag) + if(infinity_flag && other.infinity_flag && + sign_flag==other.sign_flag) + return true; + else if(infinity_flag || other.infinity_flag) return false; //if(a.is_zero() && b.is_zero()) return true; - return a.exponent==b.exponent && - a.fraction==b.fraction && - a.sign_flag==b.sign_flag; + return + exponent==other.exponent && + fraction==other.fraction && + sign_flag==other.sign_flag; } /*******************************************************************\ -Function: ieee_equal +Function: ieee_floatt::ieee_equal Inputs: @@ -1314,17 +1317,17 @@ Function: ieee_equal \*******************************************************************/ -bool ieee_equal(const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::ieee_equal(const ieee_floatt &other) const { - if(a.NaN_flag || b.NaN_flag) return false; - if(a.is_zero() && b.is_zero()) return true; - assert(a.spec==b.spec); - return a==b; + if(NaN_flag || other.NaN_flag) return false; + if(is_zero() && other.is_zero()) return true; + assert(spec==other.spec); + return *this==other; } /*******************************************************************\ -Function: operator == +Function: ieee_floatt::operator== Inputs: @@ -1334,17 +1337,16 @@ Function: operator == \*******************************************************************/ -bool operator ==(const ieee_floatt &a, int i) +bool ieee_floatt::operator==(int i) const { - ieee_floatt other; - other.spec=a.spec; + ieee_floatt other(spec); other.from_integer(i); - return a==other; + return *this==other; } /*******************************************************************\ -Function: operator != +Function: ieee_floatt::operator!= Inputs: @@ -1354,9 +1356,9 @@ Function: operator != \*******************************************************************/ -bool operator !=(const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::operator!=(const ieee_floatt &other) const { - return !(a==b); + return !(*this==other); } /*******************************************************************\ @@ -1371,12 +1373,12 @@ Function: ieee_not_equal \*******************************************************************/ -bool ieee_not_equal(const ieee_floatt &a, const ieee_floatt &b) +bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const { - if(a.NaN_flag || b.NaN_flag) return true; // !!! - if(a.is_zero() && b.is_zero()) return false; - assert(a.spec==b.spec); - return a!=b; + if(NaN_flag || other.NaN_flag) return true; // !!! + if(is_zero() && other.is_zero()) return false; + assert(spec==other.spec); + return *this!=other; } /*******************************************************************\ diff --git a/src/util/ieee_float.h b/src/util/ieee_float.h index dcb4c643e7f..03f63771772 100644 --- a/src/util/ieee_float.h +++ b/src/util/ieee_float.h @@ -92,22 +92,17 @@ class ieee_float_spect return result; } - inline friend bool operator == ( - const ieee_float_spect &a, const ieee_float_spect &b) + inline bool operator==(const ieee_float_spect &other) const { - return a.f==b.f && a.e==b.e && a.x86_extended==b.x86_extended; + return f==other.f && e==other.e && x86_extended==other.x86_extended; } - inline friend bool operator != ( - const ieee_float_spect &a, const ieee_float_spect &b) + inline bool operator!=(const ieee_float_spect &other) const { - return !(a==b); + return !(*this==other); } }; -bool operator == (const ieee_float_spect &a, const ieee_float_spect &b); -bool operator != (const ieee_float_spect &a, const ieee_float_spect &b); - class ieee_floatt { public: @@ -256,11 +251,6 @@ class ieee_floatt std::string to_string_scientific(std::size_t precision) const; std::string format(const format_spect &format_spec) const; - friend inline std::ostream& operator << (std::ostream &out, const ieee_floatt &f) - { - return out << f.to_ansi_c_string(); - } - // expressions constant_exprt to_expr() const; void from_expr(const constant_exprt &expr); @@ -271,20 +261,20 @@ class ieee_floatt ieee_floatt &operator += (const ieee_floatt &other); ieee_floatt &operator -= (const ieee_floatt &other); - friend bool operator < (const ieee_floatt &a, const ieee_floatt &b); - friend bool operator <=(const ieee_floatt &a, const ieee_floatt &b); - friend bool operator > (const ieee_floatt &a, const ieee_floatt &b); - friend bool operator >=(const ieee_floatt &a, const ieee_floatt &b); + bool operator<(const ieee_floatt &other) const; + bool operator<=(const ieee_floatt &other) const; + bool operator>(const ieee_floatt &other) const; + bool operator>=(const ieee_floatt &other) const; // warning: these do packed equality, not IEEE equality // e.g., NAN==NAN - friend bool operator ==(const ieee_floatt &a, const ieee_floatt &b); - friend bool operator !=(const ieee_floatt &a, const ieee_floatt &b); - friend bool operator ==(const ieee_floatt &a, int i); + bool operator==(const ieee_floatt &other) const; + bool operator!=(const ieee_floatt &other) const; + bool operator==(int i) const; // these do IEEE equality, i.e., NAN!=NAN - friend bool ieee_equal(const ieee_floatt &a, const ieee_floatt &b); - friend bool ieee_not_equal(const ieee_floatt &a, const ieee_floatt &b); + bool ieee_equal(const ieee_floatt &other) const; + bool ieee_not_equal(const ieee_floatt &other) const; protected: void divide_and_round(mp_integer &fraction, const mp_integer &factor); @@ -301,14 +291,11 @@ class ieee_floatt static mp_integer base10_digits(const mp_integer &src); }; -bool operator < (const ieee_floatt &a, const ieee_floatt &b); -bool operator <=(const ieee_floatt &a, const ieee_floatt &b); -bool operator > (const ieee_floatt &a, const ieee_floatt &b); -bool operator >=(const ieee_floatt &a, const ieee_floatt &b); -bool operator ==(const ieee_floatt &a, const ieee_floatt &b); -bool operator !=(const ieee_floatt &a, const ieee_floatt &b); -std::ostream& operator << (std::ostream &, const ieee_floatt &); -bool ieee_equal(const ieee_floatt &a, const ieee_floatt &b); -bool ieee_not_equal(const ieee_floatt &a, const ieee_floatt &b); +inline std::ostream& operator<<( + std::ostream &out, + const ieee_floatt &f) +{ + return out << f.to_ansi_c_string(); +} #endif // CPROVER_UTIL_IEEE_FLOAT_H diff --git a/src/util/irep.cpp b/src/util/irep.cpp index 3adafe3d885..a5aad8b258a 100644 --- a/src/util/irep.cpp +++ b/src/util/irep.cpp @@ -557,7 +557,7 @@ irept &irept::add(const irep_namet &name, const irept &irep) /*******************************************************************\ -Function: operator== +Function: irept::operator== Inputs: @@ -572,18 +572,18 @@ unsigned long long irep_cmp_cnt=0; unsigned long long irep_cmp_ne_cnt=0; #endif -bool operator==(const irept &i1, const irept &i2) +bool irept::operator==(const irept &other) const { #ifdef IREP_HASH_STATS ++irep_cmp_cnt; #endif #ifdef SHARING - if(i1.data==i2.data) return true; + if(data==other.data) return true; #endif - if(i1.id()!=i2.id() || - i1.get_sub()!=i2.get_sub() || // recursive call - i1.get_named_sub()!=i2.get_named_sub()) // recursive call + if(id()!=other.id() || + get_sub()!=other.get_sub() || // recursive call + get_named_sub()!=other.get_named_sub()) // recursive call { #ifdef IREP_HASH_STATS ++irep_cmp_ne_cnt; @@ -598,7 +598,7 @@ bool operator==(const irept &i1, const irept &i2) /*******************************************************************\ -Function: full_eq +Function: irept::full_eq Inputs: @@ -608,27 +608,27 @@ Function: full_eq \*******************************************************************/ -bool full_eq(const irept &i1, const irept &i2) +bool irept::full_eq(const irept &other) const { #ifdef SHARING - if(i1.data==i2.data) return true; + if(data==other.data) return true; #endif - if(i1.id()!=i2.id()) return false; + if(id()!=other.id()) return false; - const irept::subt &i1_sub=i1.get_sub(); - const irept::subt &i2_sub=i2.get_sub(); - const irept::named_subt &i1_named_sub=i1.get_named_sub(); - const irept::named_subt &i2_named_sub=i2.get_named_sub(); - const irept::named_subt &i1_comments=i1.get_comments(); - const irept::named_subt &i2_comments=i2.get_comments(); + const irept::subt &i1_sub=get_sub(); + const irept::subt &i2_sub=other.get_sub(); + const irept::named_subt &i1_named_sub=get_named_sub(); + const irept::named_subt &i2_named_sub=other.get_named_sub(); + const irept::named_subt &i1_comments=get_comments(); + const irept::named_subt &i2_comments=other.get_comments(); if(i1_sub.size() !=i2_sub.size()) return false; if(i1_named_sub.size()!=i2_named_sub.size()) return false; if(i1_comments.size() !=i2_comments.size()) return false; - for(unsigned i=0; ifirst!=i2_it->first || - !full_eq(i1_it->second, i2_it->second)) + !i1_it->second.full_eq(i2_it->second)) return false; } @@ -647,7 +647,7 @@ bool full_eq(const irept &i1, const irept &i2) for(; i1_it!=i1_comments.end(); i1_it++, i2_it++) if(i1_it->first!=i2_it->first || - !full_eq(i1_it->second, i2_it->second)) + !i1_it->second.full_eq(i2_it->second)) return false; } @@ -656,7 +656,7 @@ bool full_eq(const irept &i1, const irept &i2) /*******************************************************************\ -Function: ordering +Function: irept::ordering Inputs: @@ -666,9 +666,9 @@ Function: ordering \*******************************************************************/ -bool ordering(const irept &X, const irept &Y) +bool irept::ordering(const irept &other) const { - return X.compare(Y)<0; + return compare(other)<0; #if 0 if(X.data { @@ -87,14 +87,15 @@ class lispexprt:public std::vector type=Symbol; value="nil"; } - - friend std::ostream& operator<< (std::ostream& out, const lispexprt &expr) - { - out << expr.expr2string(); - return out; - } }; +inline std::ostream& operator<<( + std::ostream &out, + const lispexprt &expr) +{ + return out << expr.expr2string(); +} + std::string escape(const std::string &s); int test_lispexpr(); diff --git a/src/util/rational.cpp b/src/util/rational.cpp index 78f59533106..01c9b60a185 100644 --- a/src/util/rational.cpp +++ b/src/util/rational.cpp @@ -55,6 +55,24 @@ rationalt &rationalt::operator-=(const rationalt &n) /*******************************************************************\ +Function: rationalt::operator-= + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +rationalt &rationalt::operator-() +{ + numerator.negate(); + return *this; +} + +/*******************************************************************\ + Function: rationalt::operator*= Inputs: @@ -201,7 +219,8 @@ Function: operator<< std::ostream& operator<<(std::ostream& out, const rationalt &a) { - std::string d=integer2string(a.numerator); - if(a.denominator!=1) d+="/"+integer2string(a.denominator); + std::string d=integer2string(a.get_numerator()); + if(a.get_denominator()!=1) + d+="/"+integer2string(a.get_denominator()); return out << d; } diff --git a/src/util/rational.h b/src/util/rational.h index 9fe0dd79254..c88c9d9f324 100644 --- a/src/util/rational.h +++ b/src/util/rational.h @@ -33,6 +33,7 @@ class rationalt rationalt &operator+=(const rationalt &n); rationalt &operator-=(const rationalt &n); + rationalt &operator-(); rationalt &operator*=(const rationalt &n); rationalt &operator/=(const rationalt &n); @@ -85,44 +86,52 @@ class rationalt void invert(); - friend rationalt operator+(const rationalt &a, const rationalt &b) + const mp_integer& get_numerator() const { - rationalt tmp(a); - tmp+=b; - return tmp; + return numerator; } - friend rationalt operator-(const rationalt &a, const rationalt &b) + const mp_integer& get_denominator() const { - rationalt tmp(a); - tmp-=b; - return tmp; + return denominator; } +}; - friend rationalt operator-(const rationalt &a) - { - rationalt tmp(a); - tmp.numerator.negate(); - return tmp; - } +inline rationalt operator+(const rationalt &a, const rationalt &b) +{ + rationalt tmp(a); + tmp+=b; + return tmp; +} - friend rationalt operator*(const rationalt &a, const rationalt &b) - { - rationalt tmp(a); - tmp*=b; - return tmp; - } +inline rationalt operator-(const rationalt &a, const rationalt &b) +{ + rationalt tmp(a); + tmp-=b; + return tmp; +} - friend rationalt operator/(const rationalt &a, const rationalt &b) - { - rationalt tmp(a); - tmp/=b; - return tmp; - } +inline rationalt operator-(const rationalt &a) +{ + rationalt tmp(a); + return -tmp; +} - friend std::ostream& operator<< (std::ostream& out, const rationalt &a); - friend constant_exprt from_rational(const rationalt &n); -}; +inline rationalt operator*(const rationalt &a, const rationalt &b) +{ + rationalt tmp(a); + tmp*=b; + return tmp; +} + +inline rationalt operator/(const rationalt &a, const rationalt &b) +{ + rationalt tmp(a); + tmp/=b; + return tmp; +} + +std::ostream& operator<<(std::ostream& out, const rationalt &a); rationalt inverse(const rationalt &n); diff --git a/src/util/rational_tools.cpp b/src/util/rational_tools.cpp index 167e2e7e3f0..b31818daebd 100644 --- a/src/util/rational_tools.cpp +++ b/src/util/rational_tools.cpp @@ -116,8 +116,9 @@ Function: from_rational constant_exprt from_rational(const rationalt &a) { - std::string d=integer2string(a.numerator); - if(a.denominator!=1) d+="/"+integer2string(a.denominator); + std::string d=integer2string(a.get_numerator()); + if(a.get_denominator()!=1) + d+="/"+integer2string(a.get_denominator()); constant_exprt result; result.type()=rational_typet(); result.set_value(d); diff --git a/src/util/simplify_expr_floatbv.cpp b/src/util/simplify_expr_floatbv.cpp index d798505a36d..a0ee87643ca 100644 --- a/src/util/simplify_expr_floatbv.cpp +++ b/src/util/simplify_expr_floatbv.cpp @@ -433,9 +433,9 @@ bool simplify_exprt::simplify_ieee_float_relation(exprt &expr) ieee_floatt f1(to_constant_expr(expr.op1())); if(expr.id()==ID_ieee_float_notequal) - expr.make_bool(ieee_not_equal(f0, f1)); + expr.make_bool(f0.ieee_not_equal(f1)); else if(expr.id()==ID_ieee_float_equal) - expr.make_bool(ieee_equal(f0, f1)); + expr.make_bool(f0.ieee_equal(f1)); else assert(false); diff --git a/src/util/std_code.h b/src/util/std_code.h index 2f58d71352e..cf658154483 100644 --- a/src/util/std_code.h +++ b/src/util/std_code.h @@ -210,25 +210,21 @@ class code_declt:public codet } const irep_idt &get_identifier() const; - - friend inline const code_declt &to_code_decl(const codet &code) - { - // will be size()==1 in the future - assert(code.get_statement()==ID_decl && code.operands().size()>=1); - return static_cast(code); - } - - friend inline code_declt &to_code_decl(codet &code) - { - // will be size()==1 in the future - assert(code.get_statement()==ID_decl && code.operands().size()>=1); - return static_cast(code); - } - }; -const code_declt &to_code_decl(const codet &code); -code_declt &to_code_decl(codet &code); +inline const code_declt &to_code_decl(const codet &code) +{ + // will be size()==1 in the future + assert(code.get_statement()==ID_decl && code.operands().size()>=1); + return static_cast(code); +} + +inline code_declt &to_code_decl(codet &code) +{ + // will be size()==1 in the future + assert(code.get_statement()==ID_decl && code.operands().size()>=1); + return static_cast(code); +} /*! \brief A removal of a local variable */ @@ -256,23 +252,19 @@ class code_deadt:public codet } const irep_idt &get_identifier() const; - - friend inline const code_deadt &to_code_dead(const codet &code) - { - assert(code.get_statement()==ID_dead && code.operands().size()==1); - return static_cast(code); - } - - friend inline code_deadt &to_code_dead(codet &code) - { - assert(code.get_statement()==ID_dead && code.operands().size()==1); - return static_cast(code); - } - }; -const code_deadt &to_code_dead(const codet &code); -code_deadt &to_code_dead(codet &code); +inline const code_deadt &to_code_dead(const codet &code) +{ + assert(code.get_statement()==ID_dead && code.operands().size()==1); + return static_cast(code); +} + +inline code_deadt &to_code_dead(codet &code) +{ + assert(code.get_statement()==ID_dead && code.operands().size()==1); + return static_cast(code); +} /*! \brief An assumption */ @@ -972,20 +964,6 @@ class code_expressiont:public codet copy_to_operands(expr); } - inline friend code_expressiont &to_code_expression(codet &code) - { - assert(code.get_statement()==ID_expression && - code.operands().size()==1); - return static_cast(code); - } - - inline friend const code_expressiont &to_code_expression(const codet &code) - { - assert(code.get_statement()==ID_expression && - code.operands().size()==1); - return static_cast(code); - } - inline const exprt &expression() const { return op0(); @@ -997,8 +975,19 @@ class code_expressiont:public codet } }; -code_expressiont &to_code_expression(codet &code); -const code_expressiont &to_code_expression(const codet &code); +inline code_expressiont &to_code_expression(codet &code) +{ + assert(code.get_statement()==ID_expression && + code.operands().size()==1); + return static_cast(code); +} + +inline const code_expressiont &to_code_expression(const codet &code) +{ + assert(code.get_statement()==ID_expression && + code.operands().size()==1); + return static_cast(code); +} /*! \brief An expression containing a side effect */ @@ -1017,18 +1006,6 @@ class side_effect_exprt:public exprt set_statement(statement); } - inline friend side_effect_exprt &to_side_effect_expr(exprt &expr) - { - assert(expr.id()==ID_side_effect); - return static_cast(expr); - } - - inline friend const side_effect_exprt &to_side_effect_expr(const exprt &expr) - { - assert(expr.id()==ID_side_effect); - return static_cast(expr); - } - inline const irep_idt &get_statement() const { return get(ID_statement); @@ -1040,8 +1017,17 @@ class side_effect_exprt:public exprt } }; -side_effect_exprt &to_side_effect_expr(exprt &expr); -const side_effect_exprt &to_side_effect_expr(const exprt &expr); +inline side_effect_exprt &to_side_effect_expr(exprt &expr) +{ + assert(expr.id()==ID_side_effect); + return static_cast(expr); +} + +inline const side_effect_exprt &to_side_effect_expr(const exprt &expr) +{ + assert(expr.id()==ID_side_effect); + return static_cast(expr); +} /*! \brief A side effect that returns a non-deterministically chosen value */ @@ -1088,24 +1074,23 @@ class side_effect_expr_function_callt:public side_effect_exprt { return op1().operands(); } - - inline friend side_effect_expr_function_callt &to_side_effect_expr_function_call(exprt &expr) - { - assert(expr.id()==ID_side_effect); - assert(expr.get(ID_statement)==ID_function_call); - return static_cast(expr); - } - - inline friend const side_effect_expr_function_callt &to_side_effect_expr_function_call(const exprt &expr) - { - assert(expr.id()==ID_side_effect); - assert(expr.get(ID_statement)==ID_function_call); - return static_cast(expr); - } }; -side_effect_expr_function_callt &to_side_effect_expr_function_call(exprt &expr); -const side_effect_expr_function_callt &to_side_effect_expr_function_call(const exprt &expr); +inline side_effect_expr_function_callt + &to_side_effect_expr_function_call(exprt &expr) +{ + assert(expr.id()==ID_side_effect); + assert(expr.get(ID_statement)==ID_function_call); + return static_cast(expr); +} + +inline const side_effect_expr_function_callt + &to_side_effect_expr_function_call(const exprt &expr) +{ + assert(expr.id()==ID_side_effect); + assert(expr.get(ID_statement)==ID_function_call); + return static_cast(expr); +} /*! \brief A side effect that throws an exception */ diff --git a/src/util/std_expr.h b/src/util/std_expr.h index 3189b040785..72b837f44cf 100644 --- a/src/util/std_expr.h +++ b/src/util/std_expr.h @@ -1074,18 +1074,6 @@ class index_exprt:public exprt { return op1(); } - - friend inline const index_exprt &to_index_expr(const exprt &expr) - { - assert(expr.id()==ID_index && expr.operands().size()==2); - return static_cast(expr); - } - - friend inline index_exprt &to_index_expr(exprt &expr) - { - assert(expr.id()==ID_index && expr.operands().size()==2); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to an \ref index_exprt @@ -1098,11 +1086,20 @@ class index_exprt:public exprt * * \ingroup gr_std_expr */ -const index_exprt &to_index_expr(const exprt &expr); +inline const index_exprt &to_index_expr(const exprt &expr) +{ + assert(expr.id()==ID_index && expr.operands().size()==2); + return static_cast(expr); +} + /*! \copydoc to_index_expr(const exprt &) * \ingroup gr_std_expr */ -index_exprt &to_index_expr(exprt &expr); +inline index_exprt &to_index_expr(exprt &expr) +{ + assert(expr.id()==ID_index && expr.operands().size()==2); + return static_cast(expr); +} /*! \brief array constructor from single element */ @@ -1128,18 +1125,6 @@ class array_of_exprt:public unary_exprt { return op0(); } - - friend inline const array_of_exprt &to_array_of_expr(const exprt &expr) - { - assert(expr.id()==ID_array_of && expr.operands().size()==1); - return static_cast(expr); - } - - friend inline array_of_exprt &to_array_of_expr(exprt &expr) - { - assert(expr.id()==ID_array_of && expr.operands().size()==1); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to an \ref array_of_exprt @@ -1152,11 +1137,20 @@ class array_of_exprt:public unary_exprt * * \ingroup gr_std_expr */ -const array_of_exprt &to_array_of_expr(const exprt &expr); +inline const array_of_exprt &to_array_of_expr(const exprt &expr) +{ + assert(expr.id()==ID_array_of && expr.operands().size()==1); + return static_cast(expr); +} + /*! \copydoc to_array_of_expr(const exprt &) * \ingroup gr_std_expr */ -array_of_exprt &to_array_of_expr(exprt &expr); +inline array_of_exprt &to_array_of_expr(exprt &expr) +{ + assert(expr.id()==ID_array_of && expr.operands().size()==1); + return static_cast(expr); +} /*! \brief array constructor from list of elements */ @@ -1171,18 +1165,6 @@ class array_exprt:public exprt exprt(ID_array, _type) { } - - friend inline const array_exprt &to_array_expr(const exprt &expr) - { - assert(expr.id()==ID_array); - return static_cast(expr); - } - - friend inline array_exprt &to_array_expr(exprt &expr) - { - assert(expr.id()==ID_array); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to an \ref array_exprt @@ -1195,11 +1177,20 @@ class array_exprt:public exprt * * \ingroup gr_std_expr */ -const array_exprt &to_array_expr(const exprt &expr); +inline const array_exprt &to_array_expr(const exprt &expr) +{ + assert(expr.id()==ID_array); + return static_cast(expr); +} + /*! \copydoc to_array_expr(const exprt &) * \ingroup gr_std_expr */ -array_exprt &to_array_expr(exprt &expr); +inline array_exprt &to_array_expr(exprt &expr) +{ + assert(expr.id()==ID_array); + return static_cast(expr); +} /*! \brief array constructor from list of elements */ @@ -1214,18 +1205,6 @@ class vector_exprt:public exprt exprt(ID_vector, _type) { } - - friend inline const vector_exprt &to_vector_expr(const exprt &expr) - { - assert(expr.id()==ID_vector); - return static_cast(expr); - } - - friend inline vector_exprt &to_vector_expr(exprt &expr) - { - assert(expr.id()==ID_vector); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to an \ref vector_exprt @@ -1238,11 +1217,20 @@ class vector_exprt:public exprt * * \ingroup gr_std_expr */ -const vector_exprt &to_vector_expr(const exprt &expr); +inline const vector_exprt &to_vector_expr(const exprt &expr) +{ + assert(expr.id()==ID_vector); + return static_cast(expr); +} + /*! \copydoc to_vector_expr(const exprt &) * \ingroup gr_std_expr */ -vector_exprt &to_vector_expr(exprt &expr); +inline vector_exprt &to_vector_expr(exprt &expr) +{ + assert(expr.id()==ID_vector); + return static_cast(expr); +} /*! \brief union constructor from single element */ @@ -1267,18 +1255,6 @@ class union_exprt:public unary_exprt set_component_name(_component_name); } - friend inline const union_exprt &to_union_expr(const exprt &expr) - { - assert(expr.id()==ID_union && expr.operands().size()==1); - return static_cast(expr); - } - - friend inline union_exprt &to_union_expr(exprt &expr) - { - assert(expr.id()==ID_union && expr.operands().size()==1); - return static_cast(expr); - } - inline irep_idt get_component_name() const { return get(ID_component_name); @@ -1310,11 +1286,20 @@ class union_exprt:public unary_exprt * * \ingroup gr_std_expr */ -const union_exprt &to_union_expr(const exprt &expr); +inline const union_exprt &to_union_expr(const exprt &expr) +{ + assert(expr.id()==ID_union && expr.operands().size()==1); + return static_cast(expr); +} + /*! \copydoc to_union_expr(const exprt &) * \ingroup gr_std_expr */ -union_exprt &to_union_expr(exprt &expr); +inline union_exprt &to_union_expr(exprt &expr) +{ + assert(expr.id()==ID_union && expr.operands().size()==1); + return static_cast(expr); +} /*! \brief struct constructor from list of elements */ @@ -1329,18 +1314,6 @@ class struct_exprt:public exprt exprt(ID_struct, _type) { } - - friend inline const struct_exprt &to_struct_expr(const exprt &expr) - { - assert(expr.id()==ID_struct); - return static_cast(expr); - } - - friend inline struct_exprt &to_struct_expr(exprt &expr) - { - assert(expr.id()==ID_struct); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to a \ref struct_exprt @@ -1353,11 +1326,20 @@ class struct_exprt:public exprt * * \ingroup gr_std_expr */ -const struct_exprt &to_struct_expr(const exprt &expr); +inline const struct_exprt &to_struct_expr(const exprt &expr) +{ + assert(expr.id()==ID_struct); + return static_cast(expr); +} + /*! \copydoc to_struct_expr(const exprt &) * \ingroup gr_std_expr */ -struct_exprt &to_struct_expr(exprt &expr); +inline struct_exprt &to_struct_expr(exprt &expr) +{ + assert(expr.id()==ID_struct); + return static_cast(expr); +} /*! \brief complex constructor from a pair of numbers */ @@ -1473,18 +1455,6 @@ class object_descriptor_exprt:public exprt { return op1(); } - - friend inline const object_descriptor_exprt &to_object_descriptor_expr(const exprt &expr) - { - assert(expr.id()==ID_object_descriptor && expr.operands().size()==2); - return static_cast(expr); - } - - friend inline object_descriptor_exprt &to_object_descriptor_expr(exprt &expr) - { - assert(expr.id()==ID_object_descriptor && expr.operands().size()==2); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to an \ref object_descriptor_exprt @@ -1497,11 +1467,21 @@ class object_descriptor_exprt:public exprt * * \ingroup gr_std_expr */ -const object_descriptor_exprt &to_object_descriptor_expr(const exprt &expr); +inline const object_descriptor_exprt &to_object_descriptor_expr( + const exprt &expr) +{ + assert(expr.id()==ID_object_descriptor && expr.operands().size()==2); + return static_cast(expr); +} + /*! \copydoc to_object_descriptor_expr(const exprt &) * \ingroup gr_std_expr */ -object_descriptor_exprt &to_object_descriptor_expr(exprt &expr); +inline object_descriptor_exprt &to_object_descriptor_expr(exprt &expr) +{ + assert(expr.id()==ID_object_descriptor && expr.operands().size()==2); + return static_cast(expr); +} /*! \brief TO_BE_DOCUMENTED */ @@ -1541,18 +1521,6 @@ class dynamic_object_exprt:public exprt { return op1(); } - - friend inline const dynamic_object_exprt &to_dynamic_object_expr(const exprt &expr) - { - assert(expr.id()==ID_dynamic_object && expr.operands().size()==2); - return static_cast(expr); - } - - friend inline dynamic_object_exprt &to_dynamic_object_expr(exprt &expr) - { - assert(expr.id()==ID_dynamic_object && expr.operands().size()==2); - return static_cast(expr); - } }; /*! \brief Cast a generic exprt to a \ref dynamic_object_exprt @@ -1565,11 +1533,21 @@ class dynamic_object_exprt:public exprt * * \ingroup gr_std_expr */ -const dynamic_object_exprt &to_dynamic_object_expr(const exprt &expr); +inline const dynamic_object_exprt &to_dynamic_object_expr( + const exprt &expr) +{ + assert(expr.id()==ID_dynamic_object && expr.operands().size()==2); + return static_cast(expr); +} + /*! \copydoc to_dynamic_object_expr(const exprt &) * \ingroup gr_std_expr */ -dynamic_object_exprt &to_dynamic_object_expr(exprt &expr); +inline dynamic_object_exprt &to_dynamic_object_expr(exprt &expr) +{ + assert(expr.id()==ID_dynamic_object && expr.operands().size()==2); + return static_cast(expr); +} /*! \brief semantic type conversion */ diff --git a/src/util/std_types.h b/src/util/std_types.h index 3fb2af54e17..94b7e65f6e7 100644 --- a/src/util/std_types.h +++ b/src/util/std_types.h @@ -1219,12 +1219,6 @@ class fixedbv_typet:public bitvector_typet { set(ID_integer_bits, b); } - - inline friend const fixedbv_typet &to_fixedbv_type(const typet &type) - { - assert(type.id()==ID_fixedbv); - return static_cast(type); - } }; /*! \brief Cast a generic typet to a \ref fixedbv_typet @@ -1237,7 +1231,11 @@ class fixedbv_typet:public bitvector_typet * * \ingroup gr_std_types */ -const fixedbv_typet &to_fixedbv_type(const typet &type); +inline const fixedbv_typet &to_fixedbv_type(const typet &type) +{ + assert(type.id()==ID_fixedbv); + return static_cast(type); +} /*! \brief Fixed-width bit-vector with IEEE floating-point interpretation */ @@ -1260,12 +1258,6 @@ class floatbv_typet:public bitvector_typet { set(ID_f, b); } - - inline friend const floatbv_typet &to_floatbv_type(const typet &type) - { - assert(type.id()==ID_floatbv); - return static_cast(type); - } }; /*! \brief Cast a generic typet to a \ref floatbv_typet @@ -1278,7 +1270,11 @@ class floatbv_typet:public bitvector_typet * * \ingroup gr_std_types */ -const floatbv_typet &to_floatbv_type(const typet &type); +inline const floatbv_typet &to_floatbv_type(const typet &type) +{ + assert(type.id()==ID_floatbv); + return static_cast(type); +} /*! \brief Type for c bit fields */ @@ -1294,18 +1290,6 @@ class c_bit_field_typet:public bitvector_typet { } - inline friend const c_bit_field_typet &to_c_bit_field_type(const typet &type) - { - assert(type.id()==ID_c_bit_field); - return static_cast(type); - } - - inline friend c_bit_field_typet &to_c_bit_field_type(typet &type) - { - assert(type.id()==ID_c_bit_field); - return static_cast(type); - } - // These have a sub-type }; @@ -1319,7 +1303,11 @@ class c_bit_field_typet:public bitvector_typet * * \ingroup gr_std_types */ -const c_bit_field_typet &to_c_bit_field_type(const typet &type); +inline const c_bit_field_typet &to_c_bit_field_type(const typet &type) +{ + assert(type.id()==ID_c_bit_field); + return static_cast(type); +} /*! \brief Cast a generic typet to a \ref c_bit_field_typet * @@ -1331,7 +1319,11 @@ const c_bit_field_typet &to_c_bit_field_type(const typet &type); * * \ingroup gr_std_types */ -c_bit_field_typet &to_c_bit_field_type(typet &type); +inline c_bit_field_typet &to_c_bit_field_type(typet &type) +{ + assert(type.id()==ID_c_bit_field); + return static_cast(type); +} /*! \brief The pointer type */ @@ -1463,12 +1455,6 @@ class string_typet:public typet inline string_typet():typet(ID_string) { } - - inline friend const string_typet &to_string_type(const typet &type) - { - assert(type.id()==ID_string); - return static_cast(type); - } }; /*! \brief Cast a generic typet to a \ref string_typet @@ -1481,7 +1467,11 @@ class string_typet:public typet * * \ingroup gr_std_types */ -const string_typet &to_string_type(const typet &type); +inline const string_typet &to_string_type(const typet &type) +{ + assert(type.id()==ID_string); + return static_cast(type); +} /*! \brief A type for subranges of integers */ @@ -1498,12 +1488,6 @@ class range_typet:public typet set_to(_to); } - inline friend const range_typet &to_range_type(const typet &type) - { - assert(type.id()==ID_range); - return static_cast(type); - } - mp_integer get_from() const; mp_integer get_to() const; @@ -1521,7 +1505,11 @@ class range_typet:public typet * * \ingroup gr_std_types */ -const range_typet &to_range_type(const typet &type); +inline const range_typet &to_range_type(const typet &type) +{ + assert(type.id()==ID_range); + return static_cast(type); +} /*! \brief A constant-size array type */ diff --git a/src/util/string_container.cpp b/src/util/string_container.cpp index 66cd0bfc3b3..90b8ad3c908 100644 --- a/src/util/string_container.cpp +++ b/src/util/string_container.cpp @@ -30,7 +30,7 @@ string_ptrt::string_ptrt(const char *_s):s(_s), len(strlen(_s)) /*******************************************************************\ -Function: operator== +Function: string_ptrt::operator== Inputs: @@ -40,11 +40,11 @@ Function: operator== \*******************************************************************/ -bool operator==(const string_ptrt a, const string_ptrt b) +bool string_ptrt::operator==(const string_ptrt &other) const { - if(a.len!=b.len) return false; - if(a.len==0) return true; - return memcmp(a.s, b.s, a.len)==0; + if(len!=other.len) return false; + if(len==0) return true; + return memcmp(s, other.s, len)==0; } /*******************************************************************\ diff --git a/src/util/string_container.h b/src/util/string_container.h index c2ce0b22939..a0872a92b6a 100644 --- a/src/util/string_container.h +++ b/src/util/string_container.h @@ -31,11 +31,9 @@ struct string_ptrt { } - friend bool operator==(const string_ptrt a, const string_ptrt b); + bool operator==(const string_ptrt &other) const; }; -bool operator==(const string_ptrt a, const string_ptrt b); - class string_ptr_hash { public: diff --git a/src/util/threeval.h b/src/util/threeval.h index c1202d710af..a2ab0d300b2 100644 --- a/src/util/threeval.h +++ b/src/util/threeval.h @@ -49,35 +49,35 @@ class tvt { } - inline friend bool operator ==(const tvt a, const tvt b) + inline bool operator==(const tvt other) const { - return a.value==b.value; + return value==other.value; } - inline friend bool operator !=(const tvt a, const tvt b) + inline bool operator!=(const tvt other) const { - return a.value!=b.value; + return value!=other.value; } - inline friend tvt operator &&(const tvt a, const tvt b) + inline tvt operator&&(const tvt other) const { - if(a.value==tv_enumt::TV_FALSE || b.value==tv_enumt::TV_FALSE) return tvt(tv_enumt::TV_FALSE); - if(a.value==tv_enumt::TV_TRUE && b.value==tv_enumt::TV_TRUE) return tvt(tv_enumt::TV_TRUE); - return tvt(tv_enumt::TV_UNKNOWN); + if(is_false() || other.is_false()) return tvt(false); + if(is_true() && other.is_true()) return tvt(true); + return unknown(); } - inline friend tvt operator ||(const tvt a, const tvt b) + inline tvt operator||(const tvt other) { - if(a.value==tv_enumt::TV_TRUE || b.value==tv_enumt::TV_TRUE) return tvt(tv_enumt::TV_TRUE); - if(a.value==tv_enumt::TV_FALSE && b.value==tv_enumt::TV_FALSE) return tvt(tv_enumt::TV_FALSE); - return tvt(tv_enumt::TV_UNKNOWN); + if(is_true() || other.is_true()) return tvt(true); + if(is_false() && other.is_false()) return tvt(false); + return unknown(); } - inline friend tvt operator !(const tvt a) + inline tvt operator!() const { - if(a.value==tv_enumt::TV_UNKNOWN) return tvt(tv_enumt::TV_UNKNOWN); - if(a.value==tv_enumt::TV_TRUE) return tvt(tv_enumt::TV_FALSE); - return tvt(tv_enumt::TV_TRUE); + if(is_unknown()) return unknown(); + if(is_true()) return tvt(false); + return tvt(true); } protected: diff --git a/src/util/timer.h b/src/util/timer.h index 2a99ab29970..e17ee5f1f04 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -51,13 +51,11 @@ class timert { return _latest_time.as_string(); } - - friend std::ostream& operator<< (std::ostream &out, const timert &timer) - { - return out << timer._total_time; - } }; -std::ostream& operator<< (std::ostream &out, const timert &timer); +std::ostream& operator<<(std::ostream &out, const timert &timer) +{ + return out << timer.total_time(); +} #endif // CPROVER_UTIL_TIMER_H From faba84374389ce025349e4c9fc7fd20acad4f28a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 10:22:17 +0100 Subject: [PATCH 11/47] Added "explicit" to all single-parameter constructors Some constructors without an argument had an "explicit" attribute as well - removed. --- src/analyses/flow_insensitive_analysis.h | 4 ++-- src/analyses/invariant_set.h | 2 +- src/analyses/natural_loops.h | 2 +- src/ansi-c/ansi_c_convert_type.h | 2 +- src/ansi-c/c_sizeof.h | 2 +- src/ansi-c/c_typecast.h | 2 +- src/ansi-c/expr2c_class.h | 2 +- src/cbmc/cbmc_solvers.h | 2 +- src/cbmc/xml_interface.h | 2 +- src/cegis/cegis-util/instruction_iterator.h | 2 +- src/cegis/cegis-util/irep_pipe.h | 2 +- src/cegis/cegis-util/program_helper.cpp | 2 +- src/cegis/constant/literals_collector.cpp | 2 +- .../control/simplify/remove_unused_elements.cpp | 2 +- src/cegis/control/verify/insert_solution.cpp | 3 +-- src/cegis/control/verify/zero_solutions.h | 4 ++-- .../add_ranking_and_skolem_variables.cpp | 2 +- .../danger/symex/learn/add_x0_placeholders.cpp | 2 +- src/cegis/danger/symex/verify/insert_candidate.cpp | 2 +- .../symex/verify/parallel_danger_verify_task.cpp | 10 +++++----- src/cegis/genetic/instruction_set_info_factory.h | 3 ++- src/cegis/genetic/match_select.cpp | 2 +- src/cegis/genetic/symex_test_runner.h | 2 +- src/cegis/genetic/tournament_select.cpp | 2 +- .../constant/literals_constant_strategy.cpp | 2 +- .../invariant/symex/verify/insert_program.cpp | 2 +- src/cegis/invariant/util/copy_instructions.cpp | 2 +- .../util/invariant_constraint_variables.cpp | 2 +- src/cegis/jsa/converters/replace_operators.cpp | 4 ++-- src/cegis/jsa/genetic/jsa_source_provider.h | 2 +- .../refactor/environment/instrument_state_vars.cpp | 2 +- .../instructionset/cegis_instruction_factory.cpp | 4 ++-- src/cegis/refactor/options/refactor_program.h | 2 +- .../safety/symex/verify/safety_verify_config.h | 2 +- src/cegis/seed/literals_seed.cpp | 12 ++++++------ src/cegis/wordsize/restrict_bv_size.cpp | 2 +- src/cpp/cpp_convert_type.cpp | 2 +- src/cpp/cpp_scopes.h | 2 +- src/cpp/cpp_typecast.h | 2 +- src/cpp/expr2cpp.cpp | 2 +- src/cpp/parse.cpp | 2 +- src/cpp/recursion_counter.h | 2 +- src/cpp/template_map.h | 2 +- src/goto-cc/compile.h | 2 +- .../xml_binaries/xml_goto_function_hashing.h | 2 +- .../xml_binaries/xml_goto_program_hashing.h | 2 +- src/goto-cc/xml_binaries/xml_symbol_hashing.h | 2 +- src/goto-instrument/accelerate/scratch_program.h | 2 +- src/goto-instrument/accelerate/subsumed.h | 3 ++- src/goto-instrument/accelerate/trace_automaton.h | 2 +- src/goto-instrument/race_check.cpp | 2 +- src/goto-instrument/rw_set.h | 2 +- src/goto-instrument/uninitialized.cpp | 2 +- src/goto-instrument/wmm/event_graph.h | 14 +++++++------- src/goto-programs/goto_program_template.h | 2 +- src/goto-programs/pointer_arithmetic.h | 2 +- src/goto-symex/slice_by_trace.h | 2 +- src/java_bytecode/java_bytecode_vtable.cpp | 4 ++-- src/jsil/expr2jsil.cpp | 2 +- src/memory-models/mm2cpp.cpp | 2 +- src/musketeer/cycles_visitor.h | 2 +- src/musketeer/graph_visitor.h | 2 +- .../propagate_const_function_pointers.cpp | 4 ++-- src/path-symex/locs.h | 2 +- src/pointer-analysis/value_set_analysis.h | 2 +- src/solvers/dplib/dplib_prop.h | 2 +- src/solvers/flattening/bv_utils.h | 2 +- src/solvers/floatbv/float_approximation.h | 2 +- src/solvers/floatbv/float_bv.h | 2 +- src/solvers/miniBDD/miniBDD.h | 2 +- src/solvers/prop/bdd_expr.h | 2 +- src/solvers/prop/prop_conv_store.h | 2 +- src/solvers/prop/prop_wrapper.h | 2 +- src/solvers/sat/satcheck_zchaff.h | 2 +- src/solvers/smt2/smt2_conv.h | 2 +- src/solvers/smt2/smt2_parser.h | 2 +- src/solvers/smt2/smt2irep.cpp | 2 +- src/util/arith_tools.cpp | 5 ++--- src/util/base_type.h | 2 +- src/util/bv_arithmetic.h | 6 +++--- src/util/fixedbv.h | 2 +- src/util/identifier.h | 2 +- src/util/ieee_float.h | 2 +- src/util/message_stream.h | 2 +- src/util/rational.h | 4 ++-- src/util/sorted_vector.h | 2 +- src/util/std_expr.h | 2 +- src/util/std_types.h | 2 +- src/util/symbol.h | 2 +- src/util/typecheck.h | 2 +- 90 files changed, 117 insertions(+), 117 deletions(-) diff --git a/src/analyses/flow_insensitive_analysis.h b/src/analyses/flow_insensitive_analysis.h index 3c64f5a0f63..15378cd08b5 100644 --- a/src/analyses/flow_insensitive_analysis.h +++ b/src/analyses/flow_insensitive_analysis.h @@ -86,7 +86,7 @@ class flow_insensitive_analysis_baset return (seen_locations.find(l)!=seen_locations.end()); } - flow_insensitive_analysis_baset(const namespacet &_ns): + explicit flow_insensitive_analysis_baset(const namespacet &_ns): ns(_ns), initialized(false) { @@ -225,7 +225,7 @@ class flow_insensitive_analysist:public flow_insensitive_analysis_baset { public: // constructor - flow_insensitive_analysist(const namespacet &_ns): + explicit flow_insensitive_analysist(const namespacet &_ns): flow_insensitive_analysis_baset(_ns) { } diff --git a/src/analyses/invariant_set.h b/src/analyses/invariant_set.h index fc9ad07d59f..d5f0a31003c 100644 --- a/src/analyses/invariant_set.h +++ b/src/analyses/invariant_set.h @@ -22,7 +22,7 @@ Author: Daniel Kroening, kroening@kroening.com class inv_object_storet { public: - inv_object_storet(const namespacet &_ns):ns(_ns) + explicit inv_object_storet(const namespacet &_ns):ns(_ns) { } diff --git a/src/analyses/natural_loops.h b/src/analyses/natural_loops.h index 53d96aaf54d..ffeaf2aa36d 100644 --- a/src/analyses/natural_loops.h +++ b/src/analyses/natural_loops.h @@ -45,7 +45,7 @@ class natural_loops_templatet { } - inline natural_loops_templatet(P &program) + explicit inline natural_loops_templatet(P &program) { compute(program); } diff --git a/src/ansi-c/ansi_c_convert_type.h b/src/ansi-c/ansi_c_convert_type.h index 6b46a1a4f61..0fef20b4928 100644 --- a/src/ansi-c/ansi_c_convert_type.h +++ b/src/ansi-c/ansi_c_convert_type.h @@ -49,7 +49,7 @@ class ansi_c_convert_typet:public messaget std::list other; - ansi_c_convert_typet(message_handlert &_message_handler): + explicit ansi_c_convert_typet(message_handlert &_message_handler): messaget(_message_handler) { } diff --git a/src/ansi-c/c_sizeof.h b/src/ansi-c/c_sizeof.h index 2ec8508f928..92e977ccc39 100644 --- a/src/ansi-c/c_sizeof.h +++ b/src/ansi-c/c_sizeof.h @@ -12,7 +12,7 @@ Author: Daniel Kroening, kroening@kroening.com class c_sizeoft { public: - c_sizeoft(const namespacet &_ns):ns(_ns) + explicit c_sizeoft(const namespacet &_ns):ns(_ns) { } diff --git a/src/ansi-c/c_typecast.h b/src/ansi-c/c_typecast.h index d444fb45f66..cfc3eb79aa5 100644 --- a/src/ansi-c/c_typecast.h +++ b/src/ansi-c/c_typecast.h @@ -38,7 +38,7 @@ bool c_implicit_typecast_arithmetic( class c_typecastt { public: - c_typecastt(const namespacet &_ns):ns(_ns) + explicit c_typecastt(const namespacet &_ns):ns(_ns) { } diff --git a/src/ansi-c/expr2c_class.h b/src/ansi-c/expr2c_class.h index a4b8ff2bd66..2592635fd50 100644 --- a/src/ansi-c/expr2c_class.h +++ b/src/ansi-c/expr2c_class.h @@ -22,7 +22,7 @@ class namespacet; class expr2ct { public: - expr2ct(const namespacet &_ns):ns(_ns), sizeof_nesting(0) { } + explicit expr2ct(const namespacet &_ns):ns(_ns), sizeof_nesting(0) { } virtual ~expr2ct() { } virtual std::string convert(const typet &src); diff --git a/src/cbmc/cbmc_solvers.h b/src/cbmc/cbmc_solvers.h index 35ded2a5c92..9cb52e49117 100644 --- a/src/cbmc/cbmc_solvers.h +++ b/src/cbmc/cbmc_solvers.h @@ -51,7 +51,7 @@ class cbmc_solverst:public messaget class solvert { public: - solvert(prop_convt* _prop_conv) + explicit solvert(prop_convt* _prop_conv) { assert(_prop_conv!=NULL); prop_conv_ptr = _prop_conv; diff --git a/src/cbmc/xml_interface.h b/src/cbmc/xml_interface.h index 1c2a926e33c..0cf038083db 100644 --- a/src/cbmc/xml_interface.h +++ b/src/cbmc/xml_interface.h @@ -14,7 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com class xml_interfacet { public: - xml_interfacet(cmdlinet &_cmdline) + explicit xml_interfacet(cmdlinet &_cmdline) { get_xml_options(_cmdline); } diff --git a/src/cegis/cegis-util/instruction_iterator.h b/src/cegis/cegis-util/instruction_iterator.h index 40b289f88e9..0cbb042e93d 100644 --- a/src/cegis/cegis-util/instruction_iterator.h +++ b/src/cegis/cegis-util/instruction_iterator.h @@ -31,7 +31,7 @@ class instr_iteratort: public std::iteratorfalse * otherwise. */ - irep_pipet(bool auto_close); + explicit irep_pipet(bool auto_close); /** * @brief Optionally closing destructor. diff --git a/src/cegis/cegis-util/program_helper.cpp b/src/cegis/cegis-util/program_helper.cpp index 673510d8b04..80693d852c8 100644 --- a/src/cegis/cegis-util/program_helper.cpp +++ b/src/cegis/cegis-util/program_helper.cpp @@ -65,7 +65,7 @@ class id_searcht: public const_expr_visitort const irep_idt &id; bool found; public: - id_searcht(const irep_idt &id) : + explicit id_searcht(const irep_idt &id) : id(id), found(false) { } diff --git a/src/cegis/constant/literals_collector.cpp b/src/cegis/constant/literals_collector.cpp index 7400815ef89..4f779d331c1 100644 --- a/src/cegis/constant/literals_collector.cpp +++ b/src/cegis/constant/literals_collector.cpp @@ -21,7 +21,7 @@ class compare_constantt { const namespacet ns; public: - compare_constantt(const symbol_tablet &st) : + explicit compare_constantt(const symbol_tablet &st) : ns(st) { } diff --git a/src/cegis/control/simplify/remove_unused_elements.cpp b/src/cegis/control/simplify/remove_unused_elements.cpp index 3bc35dd88cf..140eeae9222 100644 --- a/src/cegis/control/simplify/remove_unused_elements.cpp +++ b/src/cegis/control/simplify/remove_unused_elements.cpp @@ -20,7 +20,7 @@ class symbol_visitort: public const_expr_visitort { std::set &vars; public: - symbol_visitort(std::set &vars) : + explicit symbol_visitort(std::set &vars) : vars(vars) { } diff --git a/src/cegis/control/verify/insert_solution.cpp b/src/cegis/control/verify/insert_solution.cpp index ca5decd1ac7..67743961feb 100644 --- a/src/cegis/control/verify/insert_solution.cpp +++ b/src/cegis/control/verify/insert_solution.cpp @@ -80,8 +80,7 @@ class is_assignment_tot { const std::string name; public: - is_assignment_tot(const std::string &name) : - name(name) + explicit is_assignment_tot(const std::string &name):name(name) { } diff --git a/src/cegis/control/verify/zero_solutions.h b/src/cegis/control/verify/zero_solutions.h index b1e47dfa3ff..3173b8ddb85 100644 --- a/src/cegis/control/verify/zero_solutions.h +++ b/src/cegis/control/verify/zero_solutions.h @@ -37,7 +37,7 @@ class zero_rational_solutiont * * @param st */ - zero_rational_solutiont(const symbol_tablet &st); + explicit zero_rational_solutiont(const symbol_tablet &st); /** * @brief @@ -65,7 +65,7 @@ class zero_vector_solutiont * * @param st */ - zero_vector_solutiont(const symbol_tablet &st); + explicit zero_vector_solutiont(const symbol_tablet &st); /** * @brief diff --git a/src/cegis/danger/preprocess/add_ranking_and_skolem_variables.cpp b/src/cegis/danger/preprocess/add_ranking_and_skolem_variables.cpp index 899a86bcc34..6d05f817c7d 100644 --- a/src/cegis/danger/preprocess/add_ranking_and_skolem_variables.cpp +++ b/src/cegis/danger/preprocess/add_ranking_and_skolem_variables.cpp @@ -55,7 +55,7 @@ class create_danger_meta_variables_for_loopt size_t loop_id; const bool use_ranking; public: - create_danger_meta_variables_for_loopt(danger_programt &prog) : + explicit create_danger_meta_variables_for_loopt(danger_programt &prog) : st(prog.st), gf(prog.gf), loop_id(0u), use_ranking(prog.use_ranking) { } diff --git a/src/cegis/danger/symex/learn/add_x0_placeholders.cpp b/src/cegis/danger/symex/learn/add_x0_placeholders.cpp index ebe7353d53c..2d69c1ad791 100644 --- a/src/cegis/danger/symex/learn/add_x0_placeholders.cpp +++ b/src/cegis/danger/symex/learn/add_x0_placeholders.cpp @@ -37,7 +37,7 @@ class add_x0_placeholdert symbol_tablet &st; goto_functionst &gf; public: - add_x0_placeholdert(danger_programt &prog) : + explicit add_x0_placeholdert(danger_programt &prog) : prog(prog), st(prog.st), gf(prog.gf) { } diff --git a/src/cegis/danger/symex/verify/insert_candidate.cpp b/src/cegis/danger/symex/verify/insert_candidate.cpp index 83bf1bbbc35..9fae8310f28 100644 --- a/src/cegis/danger/symex/verify/insert_candidate.cpp +++ b/src/cegis/danger/symex/verify/insert_candidate.cpp @@ -28,7 +28,7 @@ class assign_x0t goto_functionst &gf; goto_programt::targetst::const_iterator current_choice; public: - assign_x0t(danger_programt &prog) : + explicit assign_x0t(danger_programt &prog) : st(prog.st), gf(prog.gf), current_choice(prog.x0_choices.begin()) { } diff --git a/src/cegis/danger/symex/verify/parallel_danger_verify_task.cpp b/src/cegis/danger/symex/verify/parallel_danger_verify_task.cpp index 187b72551cd..01d127e6559 100644 --- a/src/cegis/danger/symex/verify/parallel_danger_verify_task.cpp +++ b/src/cegis/danger/symex/verify/parallel_danger_verify_task.cpp @@ -62,7 +62,7 @@ class danger_config_fullt typedef danger_verify_configt::counterexamplest counterexamplest; typedef danger_verify_configt::candidatet candidatet; - danger_config_fullt(danger_verify_configt &config) : + explicit danger_config_fullt(danger_verify_configt &config) : config(config) { } @@ -97,7 +97,7 @@ class danger_config_rankingt typedef danger_verify_configt::counterexamplest counterexamplest; typedef danger_verify_configt::candidatet candidatet; - danger_config_rankingt(danger_verify_configt &config) : + explicit danger_config_rankingt(danger_verify_configt &config) : config(config), gf(config.get_goto_functions()) { } @@ -132,7 +132,7 @@ class danger_config_assertiont typedef danger_verify_configt::counterexamplest counterexamplest; typedef danger_verify_configt::candidatet candidatet; - danger_config_assertiont(danger_verify_configt &config) : + explicit danger_config_assertiont(danger_verify_configt &config) : config(config), gf(config.get_goto_functions()) { } @@ -175,7 +175,7 @@ class ce_to_irept { irept &result; public: - ce_to_irept(irept &result) : + explicit ce_to_irept(irept &result) : result(result) { } @@ -197,7 +197,7 @@ class ces_to_irept { irept &result; public: - ces_to_irept(irept &result) : + explicit ces_to_irept(irept &result) : result(result) { } diff --git a/src/cegis/genetic/instruction_set_info_factory.h b/src/cegis/genetic/instruction_set_info_factory.h index c9c109cb1dc..69e158789f0 100644 --- a/src/cegis/genetic/instruction_set_info_factory.h +++ b/src/cegis/genetic/instruction_set_info_factory.h @@ -46,7 +46,8 @@ class instruction_set_info_factoryt * @tparam goto_program_providert */ template - instruction_set_info_factoryt(const goto_program_providert &provider); + explicit instruction_set_info_factoryt( + const goto_program_providert &provider); /** * @brief diff --git a/src/cegis/genetic/match_select.cpp b/src/cegis/genetic/match_select.cpp index 35e0cde1382..cf3e0f59b0f 100644 --- a/src/cegis/genetic/match_select.cpp +++ b/src/cegis/genetic/match_select.cpp @@ -56,7 +56,7 @@ class is_contestant_less_thant { const contestantt no_contestant; public: - is_contestant_less_thant(const contestantt &no_contestant) : + explicit is_contestant_less_thant(const contestantt &no_contestant) : no_contestant(no_contestant) { } diff --git a/src/cegis/genetic/symex_test_runner.h b/src/cegis/genetic/symex_test_runner.h index c96dd039684..c4aede09473 100644 --- a/src/cegis/genetic/symex_test_runner.h +++ b/src/cegis/genetic/symex_test_runner.h @@ -33,7 +33,7 @@ class symex_test_runnert individualt *individual; public: pid_t child_pid; - bool_pipet(individualt *individual); + explicit bool_pipet(individualt *individual); void run_test(const class optionst &options, configt &config, const counterexamplet &ce); void join(); diff --git a/src/cegis/genetic/tournament_select.cpp b/src/cegis/genetic/tournament_select.cpp index 392c3f81f80..855a2890e68 100644 --- a/src/cegis/genetic/tournament_select.cpp +++ b/src/cegis/genetic/tournament_select.cpp @@ -72,7 +72,7 @@ class arenat return father == c || mother == c || son == c || daughter == c; } public: - arenat(tournament_selectt::populationt &pop) : + explicit arenat(tournament_selectt::populationt &pop) : no_contestant(pop.end()), father(no_contestant), mother(no_contestant), son( no_contestant), daughter(no_contestant) { diff --git a/src/cegis/invariant/constant/literals_constant_strategy.cpp b/src/cegis/invariant/constant/literals_constant_strategy.cpp index 44d80d4d6f2..d1890f4135c 100644 --- a/src/cegis/invariant/constant/literals_constant_strategy.cpp +++ b/src/cegis/invariant/constant/literals_constant_strategy.cpp @@ -24,7 +24,7 @@ class compare_constantt { const namespacet ns; public: - compare_constantt(const invariant_programt &program) : + explicit compare_constantt(const invariant_programt &program) : ns(program.st) { } diff --git a/src/cegis/invariant/symex/verify/insert_program.cpp b/src/cegis/invariant/symex/verify/insert_program.cpp index 9509141932b..abed596b164 100644 --- a/src/cegis/invariant/symex/verify/insert_program.cpp +++ b/src/cegis/invariant/symex/verify/insert_program.cpp @@ -16,7 +16,7 @@ class replace_name_visitort: public expr_visitort { const replacementst &repl; public: - replace_name_visitort(const replacementst &repl) : + explicit replace_name_visitort(const replacementst &repl) : repl(repl) { } diff --git a/src/cegis/invariant/util/copy_instructions.cpp b/src/cegis/invariant/util/copy_instructions.cpp index b108a6dc389..6f1c4f62c25 100644 --- a/src/cegis/invariant/util/copy_instructions.cpp +++ b/src/cegis/invariant/util/copy_instructions.cpp @@ -104,7 +104,7 @@ class skip_removert typedef std::map skipst; skipst skips; public: - skip_removert(goto_programt::instructionst &instrs) : + explicit skip_removert(goto_programt::instructionst &instrs) : instrs(instrs) { } diff --git a/src/cegis/invariant/util/invariant_constraint_variables.cpp b/src/cegis/invariant/util/invariant_constraint_variables.cpp index 5c9a6fd69b7..a6a5bdca28d 100644 --- a/src/cegis/invariant/util/invariant_constraint_variables.cpp +++ b/src/cegis/invariant/util/invariant_constraint_variables.cpp @@ -49,7 +49,7 @@ class counterexample_variable_collectort { invariant_symbol_set &vars; public: - counterexample_variable_collectort(invariant_symbol_set &vars) : + explicit counterexample_variable_collectort(invariant_symbol_set &vars) : vars(vars) { } diff --git a/src/cegis/jsa/converters/replace_operators.cpp b/src/cegis/jsa/converters/replace_operators.cpp index 9d6d8e99d3d..098a82373f6 100644 --- a/src/cegis/jsa/converters/replace_operators.cpp +++ b/src/cegis/jsa/converters/replace_operators.cpp @@ -34,8 +34,8 @@ class replace_pred_ops_visitort: public expr_visitort { const __CPROVER_jsa_pred_instructiont &instr; public: - replace_pred_ops_visitort(const __CPROVER_jsa_pred_instructiont &instr) : - instr(instr) + explicit replace_pred_ops_visitort( + const __CPROVER_jsa_pred_instructiont &instr):instr(instr) { } diff --git a/src/cegis/jsa/genetic/jsa_source_provider.h b/src/cegis/jsa/genetic/jsa_source_provider.h index cf7be6f543a..5f892219b6b 100644 --- a/src/cegis/jsa/genetic/jsa_source_provider.h +++ b/src/cegis/jsa/genetic/jsa_source_provider.h @@ -29,7 +29,7 @@ class jsa_source_providert * * @param lcfg */ - jsa_source_providert(jsa_symex_learnt &lcfg); + explicit jsa_source_providert(jsa_symex_learnt &lcfg); /** * @brief diff --git a/src/cegis/refactor/environment/instrument_state_vars.cpp b/src/cegis/refactor/environment/instrument_state_vars.cpp index 6dc9d60869a..89362222b23 100644 --- a/src/cegis/refactor/environment/instrument_state_vars.cpp +++ b/src/cegis/refactor/environment/instrument_state_vars.cpp @@ -15,7 +15,7 @@ class var_findert: public const_expr_visitort { std::set &vars; public: - var_findert(std::set &vars) : + explicit var_findert(std::set &vars) : vars(vars) { } diff --git a/src/cegis/refactor/instructionset/cegis_instruction_factory.cpp b/src/cegis/refactor/instructionset/cegis_instruction_factory.cpp index c9d233dad1e..e2597b2cc0e 100644 --- a/src/cegis/refactor/instructionset/cegis_instruction_factory.cpp +++ b/src/cegis/refactor/instructionset/cegis_instruction_factory.cpp @@ -46,7 +46,7 @@ class arithmetic_instructionst const typet &type; const instruction_descriptiont::typest sig; public: - arithmetic_instructionst(const typet &type) : + explicit arithmetic_instructionst(const typet &type) : type(type), sig( { type, type, type }) { } @@ -76,7 +76,7 @@ class assignt { const typet type; public: - assignt(const typet &type) : + explicit assignt(const typet &type) : type(type) { } diff --git a/src/cegis/refactor/options/refactor_program.h b/src/cegis/refactor/options/refactor_program.h index aa66f843bd3..558fb645b2e 100644 --- a/src/cegis/refactor/options/refactor_program.h +++ b/src/cegis/refactor/options/refactor_program.h @@ -102,7 +102,7 @@ class refactor_programt * * @details */ - explicit refactor_programt(); + refactor_programt(); /** * @brief diff --git a/src/cegis/safety/symex/verify/safety_verify_config.h b/src/cegis/safety/symex/verify/safety_verify_config.h index bf64a69be37..3bc7d5bab32 100644 --- a/src/cegis/safety/symex/verify/safety_verify_config.h +++ b/src/cegis/safety/symex/verify/safety_verify_config.h @@ -51,7 +51,7 @@ class safety_verify_configt * * @param program */ - safety_verify_configt(const safety_programt &program); + explicit safety_verify_configt(const safety_programt &program); /** * @brief diff --git a/src/cegis/seed/literals_seed.cpp b/src/cegis/seed/literals_seed.cpp index 6cd402d5467..1c1d4b43cda 100644 --- a/src/cegis/seed/literals_seed.cpp +++ b/src/cegis/seed/literals_seed.cpp @@ -32,7 +32,7 @@ class is_same_symbolt { const irep_idt &name; public: - is_same_symbolt(const irep_idt &name) : + explicit is_same_symbolt(const irep_idt &name) : name(name) { } @@ -51,7 +51,7 @@ class add_symbolt { keyst &keys; public: - add_symbolt(keyst &keys) : + explicit add_symbolt(keyst &keys) : keys(keys) { } @@ -67,7 +67,7 @@ class compare_literalt { const constant_exprt &literal; public: - compare_literalt(const constant_exprt &literal) : + explicit compare_literalt(const constant_exprt &literal) : literal(literal) { } @@ -82,7 +82,7 @@ class add_literalt { valuest &values; public: - add_literalt(valuest &values) : + explicit add_literalt(valuest &values) : values(values) { } @@ -178,7 +178,7 @@ class is_keyt { const exprt::operandst &ops; public: - is_keyt(const exprt::operandst &ops) : + explicit is_keyt(const exprt::operandst &ops) : ops(ops) { } @@ -212,7 +212,7 @@ class scrape_literalst: public const_expr_visitort std::deque keys; pool_storaget &pool; public: - scrape_literalst(pool_storaget &p) : + explicit scrape_literalst(pool_storaget &p) : pool(p) { std::transform(p.begin(), p.end(), std::back_inserter(keys), &get_first); diff --git a/src/cegis/wordsize/restrict_bv_size.cpp b/src/cegis/wordsize/restrict_bv_size.cpp index 8ca3a0791be..a30744f4f40 100644 --- a/src/cegis/wordsize/restrict_bv_size.cpp +++ b/src/cegis/wordsize/restrict_bv_size.cpp @@ -50,7 +50,7 @@ class restrict_bv_size_visitort: public expr_visitort { const size_t width_in_bits; public: - restrict_bv_size_visitort(const size_t width_in_bits) : + explicit restrict_bv_size_visitort(const size_t width_in_bits) : width_in_bits(width_in_bits) { } diff --git a/src/cpp/cpp_convert_type.cpp b/src/cpp/cpp_convert_type.cpp index dbc9effe910..0f106b19575 100644 --- a/src/cpp/cpp_convert_type.cpp +++ b/src/cpp/cpp_convert_type.cpp @@ -34,7 +34,7 @@ class cpp_convert_typet std::list other; cpp_convert_typet() { } - cpp_convert_typet(const typet &type) { read(type); } + explicit cpp_convert_typet(const typet &type) { read(type); } protected: void read_rec(const typet &type); diff --git a/src/cpp/cpp_scopes.h b/src/cpp/cpp_scopes.h index 0c2e0420383..5fe89464322 100644 --- a/src/cpp/cpp_scopes.h +++ b/src/cpp/cpp_scopes.h @@ -125,7 +125,7 @@ class cpp_scopest class cpp_save_scopet { public: - cpp_save_scopet(cpp_scopest &_cpp_scopes): + explicit cpp_save_scopet(cpp_scopest &_cpp_scopes): cpp_scopes(_cpp_scopes), saved_scope(_cpp_scopes.current_scope_ptr) { diff --git a/src/cpp/cpp_typecast.h b/src/cpp/cpp_typecast.h index 8f242c61e6b..0552e7b1ee6 100644 --- a/src/cpp/cpp_typecast.h +++ b/src/cpp/cpp_typecast.h @@ -16,7 +16,7 @@ class cpp_typecheckt; class cpp_typecastt:public c_typecastt { public: - cpp_typecastt(cpp_typecheckt &cpp_typecheck); + explicit cpp_typecastt(cpp_typecheckt &cpp_typecheck); virtual void implicit_typecast( exprt &expr, diff --git a/src/cpp/expr2cpp.cpp b/src/cpp/expr2cpp.cpp index d01ff791599..0678a6e9773 100644 --- a/src/cpp/expr2cpp.cpp +++ b/src/cpp/expr2cpp.cpp @@ -24,7 +24,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu class expr2cppt:public expr2ct { public: - expr2cppt(const namespacet &_ns):expr2ct(_ns) { } + explicit expr2cppt(const namespacet &_ns):expr2ct(_ns) { } std::string convert(const exprt &src) override { diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index f2f4527abbf..d3cbfc3bfb6 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -129,7 +129,7 @@ class new_scopet class save_scopet { public: - inline save_scopet(new_scopet *&_scope): + explicit inline save_scopet(new_scopet *&_scope): scope_ptr(_scope), old_scope(_scope) { } diff --git a/src/cpp/recursion_counter.h b/src/cpp/recursion_counter.h index 9be4c188ae7..fab87c254f7 100644 --- a/src/cpp/recursion_counter.h +++ b/src/cpp/recursion_counter.h @@ -12,7 +12,7 @@ Author: Daniel Kroening, kroening@cs.cmu.edu class recursion_countert { public: - recursion_countert(unsigned &_cnt):cnt(_cnt) + explicit recursion_countert(unsigned &_cnt):cnt(_cnt) { cnt++; } diff --git a/src/cpp/template_map.h b/src/cpp/template_map.h index dcdee42e849..c1347eca059 100644 --- a/src/cpp/template_map.h +++ b/src/cpp/template_map.h @@ -65,7 +65,7 @@ class template_mapt class cpp_saved_template_mapt { public: - cpp_saved_template_mapt(template_mapt &map): + explicit cpp_saved_template_mapt(template_mapt &map): old_map(map), map(map) { } diff --git a/src/goto-cc/compile.h b/src/goto-cc/compile.h index 6c752036f6e..5b7188ec417 100644 --- a/src/goto-cc/compile.h +++ b/src/goto-cc/compile.h @@ -45,7 +45,7 @@ class compilet:public language_uit std::string object_file_extension; std::string output_file_object, output_file_executable; - compilet(cmdlinet &_cmdline); + explicit compilet(cmdlinet &_cmdline); ~compilet(); diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h index f826bdeed65..8e615900fc2 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h @@ -21,7 +21,7 @@ class xml_goto_function_convertt { private: xml_irep_convertt::ireps_containert &ireps_container; public: - xml_goto_function_convertt(xml_irep_convertt::ireps_containert &ic) : + explicit xml_goto_function_convertt(xml_irep_convertt::ireps_containert &ic) : ireps_container(ic) {}; void convert( const xmlt&, goto_functionst::goto_functiont& ); diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h index 52f0e796db9..a8e4384506e 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h @@ -21,7 +21,7 @@ class xml_goto_program_convertt { private: xml_irep_convertt irepconverter; public: - xml_goto_program_convertt(xml_irep_convertt::ireps_containert &ic) : + explicit xml_goto_program_convertt(xml_irep_convertt::ireps_containert &ic) : irepconverter(ic) {}; void convert(const goto_programt&, xmlt&); diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.h b/src/goto-cc/xml_binaries/xml_symbol_hashing.h index e09b4389121..796e6392789 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.h +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.h @@ -22,7 +22,7 @@ class xml_symbol_convertt { std::list irepcache; public: - xml_symbol_convertt(xml_irep_convertt::ireps_containert &ic) : + explicit xml_symbol_convertt(xml_irep_convertt::ireps_containert &ic) : irepconverter(ic) {}; void convert(const symbolt &, xmlt &); diff --git a/src/goto-instrument/accelerate/scratch_program.h b/src/goto-instrument/accelerate/scratch_program.h index 30c009501dd..3413ae39f35 100644 --- a/src/goto-instrument/accelerate/scratch_program.h +++ b/src/goto-instrument/accelerate/scratch_program.h @@ -20,7 +20,7 @@ class scratch_programt : public goto_programt { public: - scratch_programt(symbol_tablet &_symbol_table) : + explicit scratch_programt(symbol_tablet &_symbol_table) : constant_propagation(true), symbol_table(_symbol_table), ns(symbol_table), diff --git a/src/goto-instrument/accelerate/subsumed.h b/src/goto-instrument/accelerate/subsumed.h index 5b06211b2e9..cd30443842c 100644 --- a/src/goto-instrument/accelerate/subsumed.h +++ b/src/goto-instrument/accelerate/subsumed.h @@ -8,7 +8,8 @@ class subsumed_patht { public: - subsumed_patht(patht &_subsumed) { + explicit subsumed_patht(patht &_subsumed) + { patht::iterator it = subsumed.begin(); subsumed.insert(it, _subsumed.begin(), _subsumed.end()); } diff --git a/src/goto-instrument/accelerate/trace_automaton.h b/src/goto-instrument/accelerate/trace_automaton.h index 54685f4bf68..ed8e21b69cc 100644 --- a/src/goto-instrument/accelerate/trace_automaton.h +++ b/src/goto-instrument/accelerate/trace_automaton.h @@ -68,7 +68,7 @@ class automatont { class trace_automatont { public: - trace_automatont(goto_programt &_goto_program) : + explicit trace_automatont(goto_programt &_goto_program) : goto_program(_goto_program) { build_alphabet(goto_program); diff --git a/src/goto-instrument/race_check.cpp b/src/goto-instrument/race_check.cpp index 3ca605b55c6..21780ac87bc 100644 --- a/src/goto-instrument/race_check.cpp +++ b/src/goto-instrument/race_check.cpp @@ -30,7 +30,7 @@ Date: February 2006 class w_guardst { public: - w_guardst(symbol_tablet &_symbol_table):symbol_table(_symbol_table) + explicit w_guardst(symbol_tablet &_symbol_table):symbol_table(_symbol_table) { } diff --git a/src/goto-instrument/rw_set.h b/src/goto-instrument/rw_set.h index 4719ca6ed3d..6a7acd882ec 100644 --- a/src/goto-instrument/rw_set.h +++ b/src/goto-instrument/rw_set.h @@ -32,7 +32,7 @@ Date: February 2006 class rw_set_baset { public: - rw_set_baset(const namespacet &_ns) + explicit rw_set_baset(const namespacet &_ns) :ns(_ns) { } diff --git a/src/goto-instrument/uninitialized.cpp b/src/goto-instrument/uninitialized.cpp index 75a1eb10a08..756ed35c5fe 100644 --- a/src/goto-instrument/uninitialized.cpp +++ b/src/goto-instrument/uninitialized.cpp @@ -25,7 +25,7 @@ Date: January 2010 class uninitializedt { public: - uninitializedt(symbol_tablet &_symbol_table): + explicit uninitializedt(symbol_tablet &_symbol_table): symbol_table(_symbol_table), ns(_symbol_table) { diff --git a/src/goto-instrument/wmm/event_graph.h b/src/goto-instrument/wmm/event_graph.h index 1a10ded69c3..765b3c875e0 100644 --- a/src/goto-instrument/wmm/event_graph.h +++ b/src/goto-instrument/wmm/event_graph.h @@ -133,18 +133,18 @@ class event_grapht event_idt second; bool is_po; - delayt(event_idt _first) - :first(_first),is_po(true) + explicit delayt(event_idt _first): + first(_first), is_po(true) { } - delayt(event_idt _first, event_idt _second) - :first(_first),second(_second),is_po(false) + delayt(event_idt _first, event_idt _second): + first(_first), second(_second), is_po(false) { } - delayt(event_idt _first, event_idt _second, bool _is_po) - :first(_first),second(_second),is_po(_is_po) + delayt(event_idt _first, event_idt _second, bool _is_po): + first(_first), second(_second), is_po(_is_po) { } @@ -340,7 +340,7 @@ class event_grapht }; public: - event_grapht(messaget& _message): + explicit event_grapht(messaget& _message): filter_thin_air(true), filter_uniproc(true), message(_message) diff --git a/src/goto-programs/goto_program_template.h b/src/goto-programs/goto_program_template.h index 94ef7c8a297..a0bbff9623c 100644 --- a/src/goto-programs/goto_program_template.h +++ b/src/goto-programs/goto_program_template.h @@ -195,7 +195,7 @@ class goto_program_templatet { } - inline instructiont(goto_program_instruction_typet _type): + explicit inline instructiont(goto_program_instruction_typet _type): source_location(static_cast(get_nil_irep())), type(_type), guard(true_exprt()), diff --git a/src/goto-programs/pointer_arithmetic.h b/src/goto-programs/pointer_arithmetic.h index 646223dc99c..4e59e78ff52 100644 --- a/src/goto-programs/pointer_arithmetic.h +++ b/src/goto-programs/pointer_arithmetic.h @@ -15,7 +15,7 @@ struct pointer_arithmetict { exprt pointer, offset; - pointer_arithmetict(const exprt &src); + explicit pointer_arithmetict(const exprt &src); protected: void read(const exprt &src); diff --git a/src/goto-symex/slice_by_trace.h b/src/goto-symex/slice_by_trace.h index 841f8bb1a47..4e275ff0456 100644 --- a/src/goto-symex/slice_by_trace.h +++ b/src/goto-symex/slice_by_trace.h @@ -14,7 +14,7 @@ Author: Alex Groce (agroce@gmail.com) class symex_slice_by_tracet { public: - symex_slice_by_tracet(const namespacet &_ns):ns(_ns) + explicit symex_slice_by_tracet(const namespacet &_ns):ns(_ns) { } diff --git a/src/java_bytecode/java_bytecode_vtable.cpp b/src/java_bytecode/java_bytecode_vtable.cpp index be0cf2a15b8..31f12d85f37 100644 --- a/src/java_bytecode/java_bytecode_vtable.cpp +++ b/src/java_bytecode/java_bytecode_vtable.cpp @@ -21,7 +21,7 @@ const char ID_virtual_name[] = "virtual_name"; class is_virtual_name_equalt { const irep_idt &virtual_name; public: - is_virtual_name_equalt(const class_typet::methodt &method) : + explicit is_virtual_name_equalt(const class_typet::methodt &method) : virtual_name(method.get(ID_virtual_name)) { } bool operator()(const class_typet::methodt &method) const { @@ -32,7 +32,7 @@ class is_virtual_name_equalt { class is_name_equalt { const irep_idt &name; public: - is_name_equalt(const irep_idt &name) : + explicit is_name_equalt(const irep_idt &name) : name(name) { } bool operator()(const class_typet::componentt &component) const { diff --git a/src/jsil/expr2jsil.cpp b/src/jsil/expr2jsil.cpp index b849370bb30..fde6cf87f00 100644 --- a/src/jsil/expr2jsil.cpp +++ b/src/jsil/expr2jsil.cpp @@ -13,7 +13,7 @@ Author: Michael Tautschnig, tautschn@amazon.com class expr2jsilt:public expr2ct { public: - expr2jsilt(const namespacet &_ns):expr2ct(_ns) { } + explicit expr2jsilt(const namespacet &_ns):expr2ct(_ns) { } virtual std::string convert(const exprt &src) { diff --git a/src/memory-models/mm2cpp.cpp b/src/memory-models/mm2cpp.cpp index 838ed6133d4..62cf4cea000 100644 --- a/src/memory-models/mm2cpp.cpp +++ b/src/memory-models/mm2cpp.cpp @@ -15,7 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com class mm2cppt { public: - inline mm2cppt(std::ostream &_out):out(_out) + explicit inline mm2cppt(std::ostream &_out):out(_out) { } diff --git a/src/musketeer/cycles_visitor.h b/src/musketeer/cycles_visitor.h index 33bd1e5bbb7..5c26ffb846f 100644 --- a/src/musketeer/cycles_visitor.h +++ b/src/musketeer/cycles_visitor.h @@ -23,7 +23,7 @@ class cycles_visitort fence_insertert& fence_inserter; public: - cycles_visitort(fence_insertert& _fi) + explicit cycles_visitort(fence_insertert& _fi) : fence_inserter(_fi) {} diff --git a/src/musketeer/graph_visitor.h b/src/musketeer/graph_visitor.h index c75004d01d3..76693a52ca1 100644 --- a/src/musketeer/graph_visitor.h +++ b/src/musketeer/graph_visitor.h @@ -64,7 +64,7 @@ class const_graph_visitort void const_graph_explore_AC(event_grapht& egraph, event_idt next, std::list& old_path); - const_graph_visitort(fence_insertert& _fence_inserter) + explicit const_graph_visitort(fence_insertert& _fence_inserter) : fence_inserter(_fence_inserter) {} }; diff --git a/src/musketeer/propagate_const_function_pointers.cpp b/src/musketeer/propagate_const_function_pointers.cpp index 253d601a056..08b5197858d 100644 --- a/src/musketeer/propagate_const_function_pointers.cpp +++ b/src/musketeer/propagate_const_function_pointers.cpp @@ -101,8 +101,8 @@ class const_function_pointer_propagationt { const_function_pointer_propagationt& cfpp; public: - arg_stackt (const_function_pointer_propagationt& _cfpp) - :cfpp(_cfpp) + explicit arg_stackt(const_function_pointer_propagationt& _cfpp): + cfpp(_cfpp) {} void add_args(const symbol_exprt& const_function, goto_programt::instructionst::iterator it); diff --git a/src/path-symex/locs.h b/src/path-symex/locs.h index f45349b420d..57b39865801 100644 --- a/src/path-symex/locs.h +++ b/src/path-symex/locs.h @@ -49,7 +49,7 @@ class locst typedef std::map function_mapt; function_mapt function_map; - locst(const namespacet &_ns); + explicit locst(const namespacet &_ns); void build(const goto_functionst &goto_functions); void output(std::ostream &out) const; diff --git a/src/pointer-analysis/value_set_analysis.h b/src/pointer-analysis/value_set_analysis.h index 08979034906..6af0750273c 100644 --- a/src/pointer-analysis/value_set_analysis.h +++ b/src/pointer-analysis/value_set_analysis.h @@ -22,7 +22,7 @@ class value_set_analysist: public static_analysist { public: - value_set_analysist(const namespacet &_ns): + explicit value_set_analysist(const namespacet &_ns): static_analysist(_ns) { } diff --git a/src/solvers/dplib/dplib_prop.h b/src/solvers/dplib/dplib_prop.h index 5abdc41aaba..d41bfd30457 100644 --- a/src/solvers/dplib/dplib_prop.h +++ b/src/solvers/dplib/dplib_prop.h @@ -18,7 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com class dplib_propt:virtual public propt { public: - dplib_propt(std::ostream &_out); + explicit dplib_propt(std::ostream &_out); virtual ~dplib_propt() { } virtual void land(literalt a, literalt b, literalt o); diff --git a/src/solvers/flattening/bv_utils.h b/src/solvers/flattening/bv_utils.h index f0d728e7734..992d7229b7c 100644 --- a/src/solvers/flattening/bv_utils.h +++ b/src/solvers/flattening/bv_utils.h @@ -25,7 +25,7 @@ Author: Daniel Kroening, kroening@kroening.com class bv_utilst { public: - inline bv_utilst(propt &_prop):prop(_prop) { } + explicit inline bv_utilst(propt &_prop):prop(_prop) { } typedef enum { SIGNED, UNSIGNED } representationt; diff --git a/src/solvers/floatbv/float_approximation.h b/src/solvers/floatbv/float_approximation.h index dd0a495db39..0ca3db7864a 100644 --- a/src/solvers/floatbv/float_approximation.h +++ b/src/solvers/floatbv/float_approximation.h @@ -14,7 +14,7 @@ Module: Floating Point with under/over-approximation class float_approximationt:public float_utilst { public: - float_approximationt(propt &_prop): + explicit float_approximationt(propt &_prop): float_utilst(_prop), over_approximate(false), partial_interpretation(false) diff --git a/src/solvers/floatbv/float_bv.h b/src/solvers/floatbv/float_bv.h index d71ef8be4e9..7ddf3808fcf 100644 --- a/src/solvers/floatbv/float_bv.h +++ b/src/solvers/floatbv/float_bv.h @@ -17,7 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com class float_bvt { public: - explicit float_bvt() + float_bvt() { } diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index 1e7085590e3..2f09173f7be 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -103,7 +103,7 @@ class mini_bdd_mgrt struct var_table_entryt { std::string label; - inline var_table_entryt(const std::string &_label); + explicit inline var_table_entryt(const std::string &_label); }; typedef std::vector var_tablet; diff --git a/src/solvers/prop/bdd_expr.h b/src/solvers/prop/bdd_expr.h index 6d76437dc95..3c35aa5dc21 100644 --- a/src/solvers/prop/bdd_expr.h +++ b/src/solvers/prop/bdd_expr.h @@ -27,7 +27,7 @@ class namespacet; class bdd_exprt { public: - bdd_exprt(const namespacet &_ns):ns(_ns) { } + explicit bdd_exprt(const namespacet &_ns):ns(_ns) { } void from_expr(const exprt &expr); exprt as_expr() const; diff --git a/src/solvers/prop/prop_conv_store.h b/src/solvers/prop/prop_conv_store.h index 675bda541ac..74ee286926d 100644 --- a/src/solvers/prop/prop_conv_store.h +++ b/src/solvers/prop/prop_conv_store.h @@ -14,7 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com class prop_conv_storet:public prop_convt { public: - prop_conv_storet(const namespacet &_ns):prop_convt(_ns) + explicit prop_conv_storet(const namespacet &_ns):prop_convt(_ns) { } diff --git a/src/solvers/prop/prop_wrapper.h b/src/solvers/prop/prop_wrapper.h index ac40bc81d1c..d21b2e85a4e 100644 --- a/src/solvers/prop/prop_wrapper.h +++ b/src/solvers/prop/prop_wrapper.h @@ -14,7 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com class prop_wrappert:public virtual propt { public: - prop_wrappert(propt &_prop):propt(_prop), p(_prop) { } + explicit prop_wrappert(propt &_prop):propt(_prop), p(_prop) { } virtual ~prop_wrappert() { } virtual literalt constant(bool value) diff --git a/src/solvers/sat/satcheck_zchaff.h b/src/solvers/sat/satcheck_zchaff.h index d86a426be9f..10619cf1434 100644 --- a/src/solvers/sat/satcheck_zchaff.h +++ b/src/solvers/sat/satcheck_zchaff.h @@ -18,7 +18,7 @@ Author: Daniel Kroening, kroening@kroening.com class satcheck_zchaff_baset:public cnf_clause_listt { public: - satcheck_zchaff_baset(class CSolver *_solver); + explicit satcheck_zchaff_baset(class CSolver *_solver); virtual ~satcheck_zchaff_baset(); virtual const std::string solver_text(); diff --git a/src/solvers/smt2/smt2_conv.h b/src/solvers/smt2/smt2_conv.h index 3e27a1500d0..ff3601f13f7 100644 --- a/src/solvers/smt2/smt2_conv.h +++ b/src/solvers/smt2/smt2_conv.h @@ -173,7 +173,7 @@ class smt2_convt:public prop_convt const seen_expressionst &let_map; public: - let_visitort(const seen_expressionst &map):let_map(map) { } + explicit let_visitort(const seen_expressionst &map):let_map(map) { } void operator()(exprt &expr) { diff --git a/src/solvers/smt2/smt2_parser.h b/src/solvers/smt2/smt2_parser.h index 41e95a45ffe..c01069b3cfd 100644 --- a/src/solvers/smt2/smt2_parser.h +++ b/src/solvers/smt2/smt2_parser.h @@ -15,7 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com class smt2_parsert { public: - smt2_parsert(std::istream &_in):in(_in) + explicit smt2_parsert(std::istream &_in):in(_in) { } diff --git a/src/solvers/smt2/smt2irep.cpp b/src/solvers/smt2/smt2irep.cpp index e3b27afa656..3db2dbd2200 100644 --- a/src/solvers/smt2/smt2irep.cpp +++ b/src/solvers/smt2/smt2irep.cpp @@ -15,7 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com class smt2irept:public smt2_parsert { public: - smt2irept(std::istream &_in):smt2_parsert(_in) + explicit smt2irept(std::istream &_in):smt2_parsert(_in) { } diff --git a/src/util/arith_tools.cpp b/src/util/arith_tools.cpp index 4df13e8b3a0..9a79af12821 100644 --- a/src/util/arith_tools.cpp +++ b/src/util/arith_tools.cpp @@ -226,14 +226,13 @@ constant_exprt from_integer( else if(type_id==ID_fixedbv) { fixedbvt fixedbv; - fixedbv.spec=to_fixedbv_type(type); + fixedbv.spec=fixedbv_spect(to_fixedbv_type(type)); fixedbv.from_integer(int_value); return fixedbv.to_expr(); } else if(type_id==ID_floatbv) { - ieee_floatt ieee_float; - ieee_float.spec=to_floatbv_type(type); + ieee_floatt ieee_float(to_floatbv_type(type)); ieee_float.from_integer(int_value); return ieee_float.to_expr(); } diff --git a/src/util/base_type.h b/src/util/base_type.h index b456f417de4..41e2fe6df4f 100644 --- a/src/util/base_type.h +++ b/src/util/base_type.h @@ -37,7 +37,7 @@ bool base_type_eq( class base_type_eqt { public: - base_type_eqt(const namespacet &_ns):ns(_ns) + explicit base_type_eqt(const namespacet &_ns):ns(_ns) { } diff --git a/src/util/bv_arithmetic.h b/src/util/bv_arithmetic.h index d054214e8aa..b555bfaacfd 100644 --- a/src/util/bv_arithmetic.h +++ b/src/util/bv_arithmetic.h @@ -23,7 +23,7 @@ class bv_spect std::size_t width; bool is_signed; - bv_spect(const typet &type) + explicit bv_spect(const typet &type) { from_type(type); } @@ -50,7 +50,7 @@ class bv_arithmetict public: bv_spect spec; - bv_arithmetict(const bv_spect &_spec): + explicit bv_arithmetict(const bv_spect &_spec): spec(_spec), value(0) { } @@ -59,7 +59,7 @@ class bv_arithmetict { } - bv_arithmetict(const exprt &expr) + explicit bv_arithmetict(const exprt &expr) { from_expr(expr); } diff --git a/src/util/fixedbv.h b/src/util/fixedbv.h index ce617c71ec5..ec2d36679f8 100644 --- a/src/util/fixedbv.h +++ b/src/util/fixedbv.h @@ -29,7 +29,7 @@ class fixedbv_spect { } - fixedbv_spect(const fixedbv_typet &type); + explicit fixedbv_spect(const fixedbv_typet &type); inline std::size_t get_fraction_bits() const { diff --git a/src/util/identifier.h b/src/util/identifier.h index 94dad2ecf13..5bcd8e9b6eb 100644 --- a/src/util/identifier.h +++ b/src/util/identifier.h @@ -17,7 +17,7 @@ Author: Daniel Kroening, kroening@kroening.com class identifiert { public: - identifiert(const std::string &s) + explicit identifiert(const std::string &s) { parse(s); } identifiert() diff --git a/src/util/ieee_float.h b/src/util/ieee_float.h index 03f63771772..9bddcef0526 100644 --- a/src/util/ieee_float.h +++ b/src/util/ieee_float.h @@ -30,7 +30,7 @@ class ieee_float_spect mp_integer bias() const; - ieee_float_spect(const floatbv_typet &type) + explicit ieee_float_spect(const floatbv_typet &type) { from_type(type); } diff --git a/src/util/message_stream.h b/src/util/message_stream.h index 89db8200107..084e4307e3d 100644 --- a/src/util/message_stream.h +++ b/src/util/message_stream.h @@ -19,7 +19,7 @@ Author: Daniel Kroening, kroening@kroening.com class legacy_message_streamt:public message_clientt { public: - legacy_message_streamt(message_handlert &_message_handler): + explicit legacy_message_streamt(message_handlert &_message_handler): message_clientt(_message_handler), error_found(false), saved_error_location(static_cast(get_nil_irep())), diff --git a/src/util/rational.h b/src/util/rational.h index c88c9d9f324..b697cb5d350 100644 --- a/src/util/rational.h +++ b/src/util/rational.h @@ -28,8 +28,8 @@ class rationalt public: // constructors rationalt():numerator(0), denominator(1) { } - rationalt(const mp_integer &i):numerator(i), denominator(1) { } - rationalt(int i):numerator(i), denominator(1) { } + explicit rationalt(const mp_integer &i):numerator(i), denominator(1) { } + explicit rationalt(int i):numerator(i), denominator(1) { } rationalt &operator+=(const rationalt &n); rationalt &operator-=(const rationalt &n); diff --git a/src/util/sorted_vector.h b/src/util/sorted_vector.h index fe5fae10775..ab19bc6c2cc 100644 --- a/src/util/sorted_vector.h +++ b/src/util/sorted_vector.h @@ -76,7 +76,7 @@ class sorted_vector :key_compare_(pred),vec_(first,beyond,al) {stable_sort();} #endif - sorted_vector(const Myt_& x) + explicit sorted_vector(const Myt_& x) : key_compare_(x.key_compare_),vec_(x.vec_) {} ~sorted_vector() {} diff --git a/src/util/std_expr.h b/src/util/std_expr.h index 72b837f44cf..f2f38584ea8 100644 --- a/src/util/std_expr.h +++ b/src/util/std_expr.h @@ -2310,7 +2310,7 @@ class address_of_exprt:public exprt copy_to_operands(op); } - explicit address_of_exprt(): + address_of_exprt(): exprt(ID_address_of, pointer_typet()) { operands().resize(1); diff --git a/src/util/std_types.h b/src/util/std_types.h index 94b7e65f6e7..0661e3a5e12 100644 --- a/src/util/std_types.h +++ b/src/util/std_types.h @@ -959,7 +959,7 @@ class incomplete_array_typet:public type_with_subtypet { } - inline incomplete_array_typet(const typet &_subtype): + explicit inline incomplete_array_typet(const typet &_subtype): type_with_subtypet(ID_array, _subtype) { } diff --git a/src/util/symbol.h b/src/util/symbol.h index 3f821421719..abe6998ec93 100644 --- a/src/util/symbol.h +++ b/src/util/symbol.h @@ -121,7 +121,7 @@ std::ostream &operator<<(std::ostream &out, class type_symbolt:public symbolt { public: - type_symbolt(const typet &_type) + explicit type_symbolt(const typet &_type) { type=_type; is_type=true; diff --git a/src/util/typecheck.h b/src/util/typecheck.h index 2da39da5695..09171e64c2c 100644 --- a/src/util/typecheck.h +++ b/src/util/typecheck.h @@ -14,7 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com class legacy_typecheckt:public legacy_message_streamt { public: - legacy_typecheckt(message_handlert &_message_handler): + explicit legacy_typecheckt(message_handlert &_message_handler): legacy_message_streamt(_message_handler) { } virtual ~legacy_typecheckt() { } From eed3e2d9e198b1717e2ce60ff98449689c77524c Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 14:10:09 +0100 Subject: [PATCH 12/47] bformulat is never used and is missing an implementation --- src/solvers/prop/bformula.h | 128 ------------------------------------ 1 file changed, 128 deletions(-) delete mode 100644 src/solvers/prop/bformula.h diff --git a/src/solvers/prop/bformula.h b/src/solvers/prop/bformula.h deleted file mode 100644 index a0ae99220bf..00000000000 --- a/src/solvers/prop/bformula.h +++ /dev/null @@ -1,128 +0,0 @@ -/*******************************************************************\ - -Module: - -Author: Daniel Kroening, kroening@kroening.com - -\*******************************************************************/ - -#ifndef CPROVER_SOLVERS_PROP_BFORMULA_H -#define CPROVER_SOLVERS_PROP_BFORMULA_H - -#include "prop.h" - -class bformulat -{ -protected: - literalt l; - propt *prop; - -public: - // constructors - bformulat():prop(NULL) - { - } - - friend bformulat operator! (bformulat f) - { - f.l.invert(); - return f; - } - - friend bformulat operator? ( - bformulat c, bformulat a, bformulat b); - - friend bformulat operator | (bformulat a, bformulat b); - friend bformulat operator & (bformulat a, bformulat b); - friend bformulat operator ^ (bformulat a, bformulat b); - friend bformulat operator ==(bformulat a, bformulat b); - friend bformulat operator !=(bformulat a, bformulat b); - - // for sets - friend inline bool operator <(const bformulat a, const bformulat b) - { - return a.ll_get(l); - } - - friend inline bformulat const_bformula(bool value) - { - bformulat f; - f.l=const_literal(value); - return f; - } - - inline bool is_constant() const - { - return l.is_constant(); - } -}; - -// constants -bformulat const_bformula(bool value); - -//typedef std::vector bvt; - -#endif // CPROVER_SOLVERS_PROP_BFORMULA_H From df1954cd3d05b7d4abd7d37ec43d1c563aa0d158 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 23:08:10 +0100 Subject: [PATCH 13/47] Do not use static/extern qualifiers with "inline" "static inline" would cause duplicate code, and "extern inline" is just unnecessary. --- src/analyses/dirty.h | 5 +- src/analyses/locals.h | 2 +- src/ansi-c/ansi_c_declaration.h | 8 +- src/cpp/cpp_declaration.h | 4 +- src/cpp/cpp_enum_type.h | 4 +- src/cpp/cpp_template_args.h | 8 +- src/cpp/cpp_util.h | 2 +- src/goto-instrument/rw_set.h | 2 +- src/goto-programs/goto_program.h | 5 +- src/goto-symex/symex_target_equation.h | 2 +- src/jsil/jsil_types.h | 13 +- src/path-symex/loc_ref.h | 28 ++-- src/path-symex/path_symex_history.h | 2 +- src/pointer-analysis/dereference.h | 2 +- src/solvers/floatbv/float_bv.h | 2 +- src/solvers/prop/literal_expr.h | 4 +- src/util/byte_operators.h | 32 +++-- src/util/decision_procedure.h | 2 +- src/util/endianness_map.h | 2 +- src/util/irep.h | 4 +- src/util/irep_hash.h | 2 +- src/util/json.h | 2 +- src/util/ssa_expr.h | 6 +- src/util/std_code.h | 80 +++++------ src/util/std_expr.h | 180 ++++++++++++------------- src/util/std_types.h | 72 +++++----- src/util/xml.h | 2 +- 27 files changed, 243 insertions(+), 234 deletions(-) diff --git a/src/analyses/dirty.h b/src/analyses/dirty.h index 61ab0b0cb40..d1edec8fee4 100644 --- a/src/analyses/dirty.h +++ b/src/analyses/dirty.h @@ -60,8 +60,9 @@ class dirtyt void find_dirty_address_of(const exprt &expr); }; -static inline std::ostream &operator << ( - std::ostream &out, const dirtyt &dirty) +inline std::ostream &operator<<( + std::ostream &out, + const dirtyt &dirty) { dirty.output(out); return out; diff --git a/src/analyses/locals.h b/src/analyses/locals.h index 8690d48d817..09da8b08892 100644 --- a/src/analyses/locals.h +++ b/src/analyses/locals.h @@ -40,7 +40,7 @@ class localst void build(const goto_functiont &goto_function); }; -static inline std::ostream &operator << ( +inline std::ostream &operator<<( std::ostream &out, const localst &locals) { locals.output(out); diff --git a/src/ansi-c/ansi_c_declaration.h b/src/ansi-c/ansi_c_declaration.h index 5a2b5649387..1adc6d72c89 100644 --- a/src/ansi-c/ansi_c_declaration.h +++ b/src/ansi-c/ansi_c_declaration.h @@ -53,13 +53,13 @@ class ansi_c_declaratort:public exprt void build(irept &src); }; -extern inline ansi_c_declaratort &to_ansi_c_declarator(exprt &expr) +inline ansi_c_declaratort &to_ansi_c_declarator(exprt &expr) { assert(expr.id()==ID_declarator); return static_cast(expr); } -extern inline const ansi_c_declaratort &to_ansi_c_declarator(const exprt &expr) +inline const ansi_c_declaratort &to_ansi_c_declarator(const exprt &expr) { assert(expr.id()==ID_declarator); return static_cast(expr); @@ -232,13 +232,13 @@ class ansi_c_declarationt:public exprt } }; -extern inline ansi_c_declarationt &to_ansi_c_declaration(exprt &expr) +inline ansi_c_declarationt &to_ansi_c_declaration(exprt &expr) { assert(expr.id()==ID_declaration); return static_cast(expr); } -extern inline const ansi_c_declarationt &to_ansi_c_declaration(const exprt &expr) +inline const ansi_c_declarationt &to_ansi_c_declaration(const exprt &expr) { assert(expr.id()==ID_declaration); return static_cast(expr); diff --git a/src/cpp/cpp_declaration.h b/src/cpp/cpp_declaration.h index 34ae1e796bc..323535df5dc 100644 --- a/src/cpp/cpp_declaration.h +++ b/src/cpp/cpp_declaration.h @@ -140,13 +140,13 @@ class cpp_declarationt:public exprt void name_anon_struct_union(typet &dest); }; -extern inline cpp_declarationt &to_cpp_declaration(irept &irep) +inline cpp_declarationt &to_cpp_declaration(irept &irep) { assert(irep.id()==ID_cpp_declaration); return static_cast(irep); } -extern inline const cpp_declarationt &to_cpp_declaration(const irept &irep) +inline const cpp_declarationt &to_cpp_declaration(const irept &irep) { assert(irep.id()==ID_cpp_declaration); return static_cast(irep); diff --git a/src/cpp/cpp_enum_type.h b/src/cpp/cpp_enum_type.h index cb30d910e7b..c58a1901431 100644 --- a/src/cpp/cpp_enum_type.h +++ b/src/cpp/cpp_enum_type.h @@ -58,13 +58,13 @@ class cpp_enum_typet:public typet irep_idt generate_anon_tag() const; }; -extern inline const cpp_enum_typet &to_cpp_enum_type(const irept &irep) +inline const cpp_enum_typet &to_cpp_enum_type(const irept &irep) { assert(irep.id()==ID_c_enum); return static_cast(irep); } -extern inline cpp_enum_typet &to_cpp_enum_type(irept &irep) +inline cpp_enum_typet &to_cpp_enum_type(irept &irep) { assert(irep.id()==ID_c_enum); return static_cast(irep); diff --git a/src/cpp/cpp_template_args.h b/src/cpp/cpp_template_args.h index b30e17b7f4e..837e3769d11 100644 --- a/src/cpp/cpp_template_args.h +++ b/src/cpp/cpp_template_args.h @@ -41,13 +41,13 @@ class cpp_template_args_non_tct:public cpp_template_args_baset { }; -extern inline cpp_template_args_non_tct &to_cpp_template_args_non_tc(irept &irep) +inline cpp_template_args_non_tct &to_cpp_template_args_non_tc(irept &irep) { assert(irep.id()==ID_template_args); return static_cast(irep); } -extern inline const cpp_template_args_non_tct &to_cpp_template_args_non_tc(const irept &irep) +inline const cpp_template_args_non_tct &to_cpp_template_args_non_tc(const irept &irep) { assert(irep.id()==ID_template_args); return static_cast(irep); @@ -73,13 +73,13 @@ class cpp_template_args_tct:public cpp_template_args_baset } }; -extern inline cpp_template_args_tct &to_cpp_template_args_tc(irept &irep) +inline cpp_template_args_tct &to_cpp_template_args_tc(irept &irep) { assert(irep.id()==ID_template_args); return static_cast(irep); } -extern inline const cpp_template_args_tct &to_cpp_template_args_tc(const irept &irep) +inline const cpp_template_args_tct &to_cpp_template_args_tc(const irept &irep) { assert(irep.id()==ID_template_args); return static_cast(irep); diff --git a/src/cpp/cpp_util.h b/src/cpp/cpp_util.h index 8bb50c9dc83..17351354c1d 100644 --- a/src/cpp/cpp_util.h +++ b/src/cpp/cpp_util.h @@ -38,7 +38,7 @@ Function: already_typechecked \*******************************************************************/ -extern inline void already_typechecked(irept &irep) +inline void already_typechecked(irept &irep) { exprt tmp("already_typechecked"); tmp.copy_to_operands(static_cast(irep)); diff --git a/src/goto-instrument/rw_set.h b/src/goto-instrument/rw_set.h index 6a7acd882ec..cad31be7431 100644 --- a/src/goto-instrument/rw_set.h +++ b/src/goto-instrument/rw_set.h @@ -91,7 +91,7 @@ class rw_set_baset const namespacet &ns; }; -extern inline std::ostream & operator << ( +inline std::ostream &operator<<( std::ostream &out, const rw_set_baset &rw_set) { rw_set.output(out); diff --git a/src/goto-programs/goto_program.h b/src/goto-programs/goto_program.h index e3c7c5528c6..d30434c33e4 100644 --- a/src/goto-programs/goto_program.h +++ b/src/goto-programs/goto_program.h @@ -51,8 +51,9 @@ class goto_programt:public goto_program_templatet it=(program).instructions.begin(); \ it!=(program).instructions.end(); it++) -extern inline bool operator<(const goto_programt::const_targett i1, - const goto_programt::const_targett i2) +inline bool operator<( + const goto_programt::const_targett i1, + const goto_programt::const_targett i2) { return order_const_target(i1, i2); } diff --git a/src/goto-symex/symex_target_equation.h b/src/goto-symex/symex_target_equation.h index 6fe33428f82..5801045a0a6 100644 --- a/src/goto-symex/symex_target_equation.h +++ b/src/goto-symex/symex_target_equation.h @@ -301,7 +301,7 @@ class symex_target_equationt:public symex_targett void merge_ireps(SSA_stept &SSA_step); }; -extern inline bool operator<( +inline bool operator<( const symex_target_equationt::SSA_stepst::const_iterator a, const symex_target_equationt::SSA_stepst::const_iterator b) { diff --git a/src/jsil/jsil_types.h b/src/jsil/jsil_types.h index d76f73873d4..4d5438a5b7d 100644 --- a/src/jsil/jsil_types.h +++ b/src/jsil/jsil_types.h @@ -42,14 +42,14 @@ class jsil_builtin_code_typet:public code_typet } }; -extern inline jsil_builtin_code_typet &to_jsil_builtin_code_type( +inline jsil_builtin_code_typet &to_jsil_builtin_code_type( code_typet &code) { assert(code.get_bool("jsil_builtin_proceduret")); return static_cast(code); } -extern inline bool is_jsil_builtin_code_type(const typet &type) +inline bool is_jsil_builtin_code_type(const typet &type) { return type.id()==ID_code && type.get_bool("jsil_builtin_proceduret"); @@ -65,14 +65,14 @@ class jsil_spec_code_typet:public code_typet } }; -extern inline jsil_spec_code_typet &to_jsil_spec_code_type( +inline jsil_spec_code_typet &to_jsil_spec_code_type( code_typet &code) { assert(code.get_bool("jsil_spec_proceduret")); return static_cast(code); } -extern inline bool is_jsil_spec_code_type(const typet &type) +inline bool is_jsil_spec_code_type(const typet &type) { return type.id()==ID_code && type.get_bool("jsil_spec_proceduret"); @@ -97,14 +97,13 @@ class jsil_union_typet:public union_typet const typet& to_type() const; }; -extern inline jsil_union_typet &to_jsil_union_type(typet &type) +inline jsil_union_typet &to_jsil_union_type(typet &type) { assert(type.id()==ID_union); return static_cast(type); } -extern inline const jsil_union_typet &to_jsil_union_type( - const typet &type) +inline const jsil_union_typet &to_jsil_union_type(const typet &type) { assert(type.id()==ID_union); return static_cast(type); diff --git a/src/path-symex/loc_ref.h b/src/path-symex/loc_ref.h index d11877683c2..2684b777bd9 100644 --- a/src/path-symex/loc_ref.h +++ b/src/path-symex/loc_ref.h @@ -58,24 +58,24 @@ class loc_reft decrease(); return *this; } -}; -static inline bool operator < (const loc_reft l1, const loc_reft l2) -{ - return l1.loc_number < l2.loc_number; -} + bool operator<(const loc_reft other) const + { + return loc_number(expr); @@ -54,7 +54,7 @@ extern inline const literal_exprt &to_literal_expr(const exprt &expr) /*! \copydoc to_literal_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline literal_exprt &to_literal_expr(exprt &expr) +inline literal_exprt &to_literal_expr(exprt &expr) { assert(expr.id()==ID_literal && !expr.has_operands()); return static_cast(expr); diff --git a/src/util/byte_operators.h b/src/util/byte_operators.h index 6b1878b9a0e..728a821a28b 100644 --- a/src/util/byte_operators.h +++ b/src/util/byte_operators.h @@ -49,13 +49,13 @@ class byte_extract_exprt:public exprt inline const exprt &offset() const { return op1(); } }; -extern inline const byte_extract_exprt &to_byte_extract_expr(const exprt &expr) +inline const byte_extract_exprt &to_byte_extract_expr(const exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); } -extern inline byte_extract_exprt &to_byte_extract_expr(exprt &expr) +inline byte_extract_exprt &to_byte_extract_expr(exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -76,13 +76,15 @@ class byte_extract_little_endian_exprt:public byte_extract_exprt }; -extern inline const byte_extract_little_endian_exprt &to_byte_extract_little_endian_expr(const exprt &expr) +inline const byte_extract_little_endian_exprt + &to_byte_extract_little_endian_expr(const exprt &expr) { assert(expr.id()==ID_byte_extract_little_endian && expr.operands().size()==2); return static_cast(expr); } -extern inline byte_extract_little_endian_exprt &to_byte_extract_little_endian_expr(exprt &expr) +inline byte_extract_little_endian_exprt + &to_byte_extract_little_endian_expr(exprt &expr) { assert(expr.id()==ID_byte_extract_little_endian && expr.operands().size()==2); return static_cast(expr); @@ -105,13 +107,15 @@ class byte_extract_big_endian_exprt:public byte_extract_exprt } }; -extern inline const byte_extract_big_endian_exprt &to_byte_extract_big_endian_expr(const exprt &expr) +inline const byte_extract_big_endian_exprt + &to_byte_extract_big_endian_expr(const exprt &expr) { assert(expr.id()==ID_byte_extract_big_endian && expr.operands().size()==2); return static_cast(expr); } -extern inline byte_extract_big_endian_exprt &to_byte_extract_big_endian_expr(exprt &expr) +inline byte_extract_big_endian_exprt + &to_byte_extract_big_endian_expr(exprt &expr) { assert(expr.id()==ID_byte_extract_big_endian && expr.operands().size()==2); return static_cast(expr); @@ -150,13 +154,13 @@ class byte_update_exprt:public exprt inline const exprt &value() const { return op2(); } }; -extern inline const byte_update_exprt &to_byte_update_expr(const exprt &expr) +inline const byte_update_exprt &to_byte_update_expr(const exprt &expr) { assert(expr.operands().size()==3); return static_cast(expr); } -extern inline byte_update_exprt &to_byte_update_expr(exprt &expr) +inline byte_update_exprt &to_byte_update_expr(exprt &expr) { assert(expr.operands().size()==3); return static_cast(expr); @@ -180,13 +184,15 @@ class byte_update_little_endian_exprt:public byte_update_exprt }; -extern inline const byte_update_little_endian_exprt &to_byte_update_little_endian_expr(const exprt &expr) +inline const byte_update_little_endian_exprt + &to_byte_update_little_endian_expr(const exprt &expr) { assert(expr.id()==ID_byte_update_little_endian && expr.operands().size()==3); return static_cast(expr); } -extern inline byte_update_little_endian_exprt &to_byte_update_little_endian_expr(exprt &expr) +inline byte_update_little_endian_exprt + &to_byte_update_little_endian_expr(exprt &expr) { assert(expr.id()==ID_byte_update_little_endian && expr.operands().size()==3); return static_cast(expr); @@ -210,13 +216,15 @@ class byte_update_big_endian_exprt:public byte_update_exprt }; -extern inline const byte_update_big_endian_exprt &to_byte_update_big_endian_expr(const exprt &expr) +inline const byte_update_big_endian_exprt + &to_byte_update_big_endian_expr(const exprt &expr) { assert(expr.id()==ID_byte_update_big_endian && expr.operands().size()==3); return static_cast(expr); } -extern inline byte_update_big_endian_exprt &to_byte_update_big_endian_expr(exprt &expr) +inline byte_update_big_endian_exprt + &to_byte_update_big_endian_expr(exprt &expr) { assert(expr.id()==ID_byte_update_big_endian && expr.operands().size()==3); return static_cast(expr); diff --git a/src/util/decision_procedure.h b/src/util/decision_procedure.h index c2e07d0081a..8711809a8fd 100644 --- a/src/util/decision_procedure.h +++ b/src/util/decision_procedure.h @@ -59,7 +59,7 @@ class decision_proceduret:public messaget const namespacet &ns; }; -static inline decision_proceduret & operator << ( +inline decision_proceduret & operator<<( decision_proceduret &dest, const exprt &src) { diff --git a/src/util/endianness_map.h b/src/util/endianness_map.h index efb09f195c0..c73da7b03e1 100644 --- a/src/util/endianness_map.h +++ b/src/util/endianness_map.h @@ -61,7 +61,7 @@ class endianness_mapt void build_big_endian(const typet &type); }; -extern inline std::ostream &operator << ( +inline std::ostream &operator<<( std::ostream &out, const endianness_mapt &m) { diff --git a/src/util/irep.h b/src/util/irep.h index 858b276ee35..6776c55b305 100644 --- a/src/util/irep.h +++ b/src/util/irep.h @@ -43,7 +43,7 @@ typedef std::string irep_namet; typedef string_hash irep_id_hash; #endif -extern inline const std::string &id2string(const irep_idt &d) +inline const std::string &id2string(const irep_idt &d) { #ifdef USE_DSTRING return as_string(d); @@ -52,7 +52,7 @@ extern inline const std::string &id2string(const irep_idt &d) #endif } -extern inline const std::string &name2string(const irep_namet &n) +inline const std::string &name2string(const irep_namet &n) { #ifdef USE_DSTRING return as_string(n); diff --git a/src/util/irep_hash.h b/src/util/irep_hash.h index 8af53d7d7a4..a6cf1283b7c 100644 --- a/src/util/irep_hash.h +++ b/src/util/irep_hash.h @@ -139,7 +139,7 @@ Function: basic_hash_finalize \*******************************************************************/ -static inline std::size_t basic_hash_finalize( +inline std::size_t basic_hash_finalize( std::size_t h1, std::size_t len) { diff --git a/src/util/json.h b/src/util/json.h index 18182b97c96..53cbb1890d9 100644 --- a/src/util/json.h +++ b/src/util/json.h @@ -121,7 +121,7 @@ class jsont std::string value; }; -static inline std::ostream & operator << (std::ostream &out, const jsont &src) +inline std::ostream & operator<<(std::ostream &out, const jsont &src) { src.output(out); return out; diff --git a/src/util/ssa_expr.h b/src/util/ssa_expr.h index 31064c1ec60..d9eb292b4aa 100644 --- a/src/util/ssa_expr.h +++ b/src/util/ssa_expr.h @@ -146,7 +146,7 @@ class ssa_exprt:public symbol_exprt * * \ingroup gr_std_expr */ -extern inline const ssa_exprt &to_ssa_expr(const exprt &expr) +inline const ssa_exprt &to_ssa_expr(const exprt &expr) { assert(expr.id()==ID_symbol && expr.get_bool(ID_C_SSA_symbol) && @@ -157,7 +157,7 @@ extern inline const ssa_exprt &to_ssa_expr(const exprt &expr) /*! \copydoc to_ssa_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline ssa_exprt &to_ssa_expr(exprt &expr) +inline ssa_exprt &to_ssa_expr(exprt &expr) { assert(expr.id()==ID_symbol && expr.get_bool(ID_C_SSA_symbol) && @@ -165,7 +165,7 @@ extern inline ssa_exprt &to_ssa_expr(exprt &expr) return static_cast(expr); } -extern inline bool is_ssa_expr(const exprt &expr) +inline bool is_ssa_expr(const exprt &expr) { return expr.id()==ID_symbol && expr.get_bool(ID_C_SSA_symbol); diff --git a/src/util/std_code.h b/src/util/std_code.h index cf658154483..86eca52127b 100644 --- a/src/util/std_code.h +++ b/src/util/std_code.h @@ -45,13 +45,13 @@ class codet:public exprt class code_blockt &make_block(); }; -static inline const codet &to_code(const exprt &expr) +inline const codet &to_code(const exprt &expr) { assert(expr.id()==ID_code); return static_cast(expr); } -static inline codet &to_code(exprt &expr) +inline codet &to_code(exprt &expr) { assert(expr.id()==ID_code); return static_cast(expr); @@ -114,13 +114,13 @@ class code_blockt:public codet } }; -static inline const code_blockt &to_code_block(const codet &code) +inline const code_blockt &to_code_block(const codet &code) { assert(code.get_statement()==ID_block); return static_cast(code); } -static inline code_blockt &to_code_block(codet &code) +inline code_blockt &to_code_block(codet &code) { assert(code.get_statement()==ID_block); return static_cast(code); @@ -172,13 +172,13 @@ class code_assignt:public codet } }; -static inline const code_assignt &to_code_assign(const codet &code) +inline const code_assignt &to_code_assign(const codet &code) { assert(code.get_statement()==ID_assign && code.operands().size()==2); return static_cast(code); } -static inline code_assignt &to_code_assign(codet &code) +inline code_assignt &to_code_assign(codet &code) { assert(code.get_statement()==ID_assign && code.operands().size()==2); return static_cast(code); @@ -292,13 +292,13 @@ class code_assumet:public codet } }; -static inline const code_assumet &to_code_assume(const codet &code) +inline const code_assumet &to_code_assume(const codet &code) { assert(code.get_statement()==ID_assume); return static_cast(code); } -static inline code_assumet &to_code_assume(codet &code) +inline code_assumet &to_code_assume(codet &code) { assert(code.get_statement()==ID_assume); return static_cast(code); @@ -330,13 +330,13 @@ class code_assertt:public codet } }; -static inline const code_assertt &to_code_assert(const codet &code) +inline const code_assertt &to_code_assert(const codet &code) { assert(code.get_statement()==ID_assert); return static_cast(code); } -static inline code_assertt &to_code_assert(codet &code) +inline code_assertt &to_code_assert(codet &code) { assert(code.get_statement()==ID_assert); return static_cast(code); @@ -390,14 +390,14 @@ class code_ifthenelset:public codet } }; -static inline const code_ifthenelset &to_code_ifthenelse(const codet &code) +inline const code_ifthenelset &to_code_ifthenelse(const codet &code) { assert(code.get_statement()==ID_ifthenelse && code.operands().size()==3); return static_cast(code); } -static inline code_ifthenelset &to_code_ifthenelse(codet &code) +inline code_ifthenelset &to_code_ifthenelse(codet &code) { assert(code.get_statement()==ID_ifthenelse && code.operands().size()==3); @@ -435,14 +435,14 @@ class code_switcht:public codet } }; -static inline const code_switcht &to_code_switch(const codet &code) +inline const code_switcht &to_code_switch(const codet &code) { assert(code.get_statement()==ID_switch && code.operands().size()==2); return static_cast(code); } -static inline code_switcht &to_code_switch(codet &code) +inline code_switcht &to_code_switch(codet &code) { assert(code.get_statement()==ID_switch && code.operands().size()==2); @@ -480,14 +480,14 @@ class code_whilet:public codet } }; -static inline const code_whilet &to_code_while(const codet &code) +inline const code_whilet &to_code_while(const codet &code) { assert(code.get_statement()==ID_while && code.operands().size()==2); return static_cast(code); } -static inline code_whilet &to_code_while(codet &code) +inline code_whilet &to_code_while(codet &code) { assert(code.get_statement()==ID_while && code.operands().size()==2); @@ -525,14 +525,14 @@ class code_dowhilet:public codet } }; -static inline const code_dowhilet &to_code_dowhile(const codet &code) +inline const code_dowhilet &to_code_dowhile(const codet &code) { assert(code.get_statement()==ID_dowhile && code.operands().size()==2); return static_cast(code); } -static inline code_dowhilet &to_code_dowhile(codet &code) +inline code_dowhilet &to_code_dowhile(codet &code) { assert(code.get_statement()==ID_dowhile && code.operands().size()==2); @@ -591,14 +591,14 @@ class code_fort:public codet } }; -static inline const code_fort &to_code_for(const codet &code) +inline const code_fort &to_code_for(const codet &code) { assert(code.get_statement()==ID_for && code.operands().size()==4); return static_cast(code); } -static inline code_fort &to_code_for(codet &code) +inline code_fort &to_code_for(codet &code) { assert(code.get_statement()==ID_for && code.operands().size()==4); @@ -630,14 +630,14 @@ class code_gotot:public codet } }; -static inline const code_gotot &to_code_goto(const codet &code) +inline const code_gotot &to_code_goto(const codet &code) { assert(code.get_statement()==ID_goto && code.operands().empty()); return static_cast(code); } -static inline code_gotot &to_code_goto(codet &code) +inline code_gotot &to_code_goto(codet &code) { assert(code.get_statement()==ID_goto && code.operands().empty()); @@ -694,13 +694,13 @@ class code_function_callt:public codet } }; -static inline const code_function_callt &to_code_function_call(const codet &code) +inline const code_function_callt &to_code_function_call(const codet &code) { assert(code.get_statement()==ID_function_call); return static_cast(code); } -static inline code_function_callt &to_code_function_call(codet &code) +inline code_function_callt &to_code_function_call(codet &code) { assert(code.get_statement()==ID_function_call); return static_cast(code); @@ -740,13 +740,13 @@ class code_returnt:public codet } }; -static inline const code_returnt &to_code_return(const codet &code) +inline const code_returnt &to_code_return(const codet &code) { assert(code.get_statement()==ID_return); return static_cast(code); } -static inline code_returnt &to_code_return(codet &code) +inline code_returnt &to_code_return(codet &code) { assert(code.get_statement()==ID_return); return static_cast(code); @@ -797,13 +797,13 @@ class code_labelt:public codet } }; -static inline const code_labelt &to_code_label(const codet &code) +inline const code_labelt &to_code_label(const codet &code) { assert(code.get_statement()==ID_label && code.operands().size()==1); return static_cast(code); } -static inline code_labelt &to_code_label(codet &code) +inline code_labelt &to_code_label(codet &code) { assert(code.get_statement()==ID_label && code.operands().size()==1); return static_cast(code); @@ -856,13 +856,13 @@ class code_switch_caset:public codet } }; -static inline const code_switch_caset &to_code_switch_case(const codet &code) +inline const code_switch_caset &to_code_switch_case(const codet &code) { assert(code.get_statement()==ID_switch_case && code.operands().size()==2); return static_cast(code); } -static inline code_switch_caset &to_code_switch_case(codet &code) +inline code_switch_caset &to_code_switch_case(codet &code) { assert(code.get_statement()==ID_switch_case && code.operands().size()==2); return static_cast(code); @@ -878,13 +878,13 @@ class code_breakt:public codet } }; -static inline const code_breakt &to_code_break(const codet &code) +inline const code_breakt &to_code_break(const codet &code) { assert(code.get_statement()==ID_break); return static_cast(code); } -static inline code_breakt &to_code_break(codet &code) +inline code_breakt &to_code_break(codet &code) { assert(code.get_statement()==ID_break); return static_cast(code); @@ -900,13 +900,13 @@ class code_continuet:public codet } }; -static inline const code_continuet &to_code_continue(const codet &code) +inline const code_continuet &to_code_continue(const codet &code) { assert(code.get_statement()==ID_continue); return static_cast(code); } -static inline code_continuet &to_code_continue(codet &code) +inline code_continuet &to_code_continue(codet &code) { assert(code.get_statement()==ID_continue); return static_cast(code); @@ -937,13 +937,13 @@ class code_asmt:public codet } }; -static inline code_asmt &to_code_asm(codet &code) +inline code_asmt &to_code_asm(codet &code) { assert(code.get_statement()==ID_asm); return static_cast(code); } -static inline const code_asmt &to_code_asm(const codet &code) +inline const code_asmt &to_code_asm(const codet &code) { assert(code.get_statement()==ID_asm); return static_cast(code); @@ -1108,14 +1108,14 @@ class side_effect_expr_throwt:public side_effect_exprt } }; -static inline side_effect_expr_throwt &to_side_effect_expr_throw(exprt &expr) +inline side_effect_expr_throwt &to_side_effect_expr_throw(exprt &expr) { assert(expr.id()==ID_side_effect); assert(expr.get(ID_statement)==ID_throw); return static_cast(expr); } -static inline const side_effect_expr_throwt &to_side_effect_expr_throw(const exprt &expr) +inline const side_effect_expr_throwt &to_side_effect_expr_throw(const exprt &expr) { assert(expr.id()==ID_side_effect); assert(expr.get(ID_statement)==ID_throw); @@ -1174,13 +1174,13 @@ class code_try_catcht:public codet } }; -static inline const code_try_catcht &to_code_try_catch(const codet &code) +inline const code_try_catcht &to_code_try_catch(const codet &code) { assert(code.get_statement()==ID_try_catch && code.operands().size()>=3); return static_cast(code); } -static inline code_try_catcht &to_code_try_catch(codet &code) +inline code_try_catcht &to_code_try_catch(codet &code) { assert(code.get_statement()==ID_try_catch && code.operands().size()>=3); return static_cast(code); diff --git a/src/util/std_expr.h b/src/util/std_expr.h index f2f38584ea8..f245d59ee0d 100644 --- a/src/util/std_expr.h +++ b/src/util/std_expr.h @@ -56,7 +56,7 @@ class transt:public exprt * * \ingroup gr_std_expr */ -extern inline const transt &to_trans_expr(const exprt &expr) +inline const transt &to_trans_expr(const exprt &expr) { assert(expr.id()==ID_trans && expr.operands().size()==3); return static_cast(expr); @@ -65,7 +65,7 @@ extern inline const transt &to_trans_expr(const exprt &expr) /*! \copydoc to_trans(const exprt &) * \ingroup gr_std_expr */ -extern inline transt &to_trans_expr(exprt &expr) +inline transt &to_trans_expr(exprt &expr) { assert(expr.id()==ID_trans && expr.operands().size()==3); return static_cast(expr); @@ -192,7 +192,7 @@ class decorated_symbol_exprt:public symbol_exprt * * \ingroup gr_std_expr */ -extern inline const symbol_exprt &to_symbol_expr(const exprt &expr) +inline const symbol_exprt &to_symbol_expr(const exprt &expr) { assert(expr.id()==ID_symbol && !expr.has_operands()); return static_cast(expr); @@ -201,7 +201,7 @@ extern inline const symbol_exprt &to_symbol_expr(const exprt &expr) /*! \copydoc to_symbol_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline symbol_exprt &to_symbol_expr(exprt &expr) +inline symbol_exprt &to_symbol_expr(exprt &expr) { assert(expr.id()==ID_symbol && !expr.has_operands()); return static_cast(expr); @@ -267,7 +267,7 @@ class unary_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const unary_exprt &to_unary_expr(const exprt &expr) +inline const unary_exprt &to_unary_expr(const exprt &expr) { assert(expr.operands().size()==1); return static_cast(expr); @@ -276,7 +276,7 @@ extern inline const unary_exprt &to_unary_expr(const exprt &expr) /*! \copydoc to_unary_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline unary_exprt &to_unary_expr(exprt &expr) +inline unary_exprt &to_unary_expr(exprt &expr) { assert(expr.operands().size()==1); return static_cast(expr); @@ -307,7 +307,7 @@ class abs_exprt:public unary_exprt * * \ingroup gr_std_expr */ -extern inline const abs_exprt &to_abs_expr(const exprt &expr) +inline const abs_exprt &to_abs_expr(const exprt &expr) { assert(expr.id()==ID_abs && expr.operands().size()==1); return static_cast(expr); @@ -316,7 +316,7 @@ extern inline const abs_exprt &to_abs_expr(const exprt &expr) /*! \copydoc to_abs_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline abs_exprt &to_abs_expr(exprt &expr) +inline abs_exprt &to_abs_expr(exprt &expr) { assert(expr.id()==ID_abs && expr.operands().size()==1); return static_cast(expr); @@ -354,7 +354,7 @@ class unary_minus_exprt:public unary_exprt * * \ingroup gr_std_expr */ -extern inline const unary_minus_exprt &to_unary_minus_expr(const exprt &expr) +inline const unary_minus_exprt &to_unary_minus_expr(const exprt &expr) { assert(expr.id()==ID_unary_minus && expr.operands().size()==1); return static_cast(expr); @@ -363,7 +363,7 @@ extern inline const unary_minus_exprt &to_unary_minus_expr(const exprt &expr) /*! \copydoc to_unary_minus_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline unary_minus_exprt &to_unary_minus_expr(exprt &expr) +inline unary_minus_exprt &to_unary_minus_expr(exprt &expr) { assert(expr.id()==ID_unary_minus && expr.operands().size()==1); return static_cast(expr); @@ -496,7 +496,7 @@ class binary_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const binary_exprt &to_binary_expr(const exprt &expr) +inline const binary_exprt &to_binary_expr(const exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -505,7 +505,7 @@ extern inline const binary_exprt &to_binary_expr(const exprt &expr) /*! \copydoc to_binary_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline binary_exprt &to_binary_expr(exprt &expr) +inline binary_exprt &to_binary_expr(exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -586,7 +586,7 @@ class binary_relation_exprt:public binary_predicate_exprt * * \ingroup gr_std_expr */ -extern inline const binary_relation_exprt &to_binary_relation_expr(const exprt &expr) +inline const binary_relation_exprt &to_binary_relation_expr(const exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -595,7 +595,7 @@ extern inline const binary_relation_exprt &to_binary_relation_expr(const exprt & /*! \copydoc to_binary_relation_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline binary_relation_exprt &to_binary_relation_expr(exprt &expr) +inline binary_relation_exprt &to_binary_relation_expr(exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -636,7 +636,7 @@ class plus_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const plus_exprt &to_plus_expr(const exprt &expr) +inline const plus_exprt &to_plus_expr(const exprt &expr) { assert(expr.id()==ID_plus && expr.operands().size()>=2); return static_cast(expr); @@ -645,7 +645,7 @@ extern inline const plus_exprt &to_plus_expr(const exprt &expr) /*! \copydoc to_plus_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline plus_exprt &to_plus_expr(exprt &expr) +inline plus_exprt &to_plus_expr(exprt &expr) { assert(expr.id()==ID_plus && expr.operands().size()>=2); return static_cast(expr); @@ -678,7 +678,7 @@ class minus_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const minus_exprt &to_minus_expr(const exprt &expr) +inline const minus_exprt &to_minus_expr(const exprt &expr) { assert(expr.id()==ID_minus && expr.operands().size()>=2); return static_cast(expr); @@ -687,7 +687,7 @@ extern inline const minus_exprt &to_minus_expr(const exprt &expr) /*! \copydoc to_minus_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline minus_exprt &to_minus_expr(exprt &expr) +inline minus_exprt &to_minus_expr(exprt &expr) { assert(expr.id()==ID_minus && expr.operands().size()>=2); return static_cast(expr); @@ -720,7 +720,7 @@ class mult_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const mult_exprt &to_mult_expr(const exprt &expr) +inline const mult_exprt &to_mult_expr(const exprt &expr) { assert(expr.id()==ID_mult && expr.operands().size()>=2); return static_cast(expr); @@ -729,7 +729,7 @@ extern inline const mult_exprt &to_mult_expr(const exprt &expr) /*! \copydoc to_mult_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline mult_exprt &to_mult_expr(exprt &expr) +inline mult_exprt &to_mult_expr(exprt &expr) { assert(expr.id()==ID_mult && expr.operands().size()>=2); return static_cast(expr); @@ -762,7 +762,7 @@ class div_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const div_exprt &to_div_expr(const exprt &expr) +inline const div_exprt &to_div_expr(const exprt &expr) { assert(expr.id()==ID_div && expr.operands().size()==2); return static_cast(expr); @@ -771,7 +771,7 @@ extern inline const div_exprt &to_div_expr(const exprt &expr) /*! \copydoc to_div_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline div_exprt &to_div_expr(exprt &expr) +inline div_exprt &to_div_expr(exprt &expr) { assert(expr.id()==ID_div && expr.operands().size()==2); return static_cast(expr); @@ -804,7 +804,7 @@ class mod_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const mod_exprt &to_mod_expr(const exprt &expr) +inline const mod_exprt &to_mod_expr(const exprt &expr) { assert(expr.id()==ID_mod && expr.operands().size()==2); return static_cast(expr); @@ -813,7 +813,7 @@ extern inline const mod_exprt &to_mod_expr(const exprt &expr) /*! \copydoc to_mod_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline mod_exprt &to_mod_expr(exprt &expr) +inline mod_exprt &to_mod_expr(exprt &expr) { assert(expr.id()==ID_mod && expr.operands().size()==2); return static_cast(expr); @@ -846,7 +846,7 @@ class rem_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const rem_exprt &to_rem_expr(const exprt &expr) +inline const rem_exprt &to_rem_expr(const exprt &expr) { assert(expr.id()==ID_rem && expr.operands().size()==2); return static_cast(expr); @@ -855,7 +855,7 @@ extern inline const rem_exprt &to_rem_expr(const exprt &expr) /*! \copydoc to_rem_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline rem_exprt &to_rem_expr(exprt &expr) +inline rem_exprt &to_rem_expr(exprt &expr) { assert(expr.id()==ID_rem && expr.operands().size()==2); return static_cast(expr); @@ -888,7 +888,7 @@ class power_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const power_exprt &to_power_expr(const exprt &expr) +inline const power_exprt &to_power_expr(const exprt &expr) { assert(expr.id()==ID_power && expr.operands().size()==2); return static_cast(expr); @@ -897,7 +897,7 @@ extern inline const power_exprt &to_power_expr(const exprt &expr) /*! \copydoc to_power_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline power_exprt &to_power_expr(exprt &expr) +inline power_exprt &to_power_expr(exprt &expr) { assert(expr.id()==ID_power && expr.operands().size()==2); return static_cast(expr); @@ -930,7 +930,7 @@ class factorial_power_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const factorial_power_exprt &to_factorial_power_expr(const exprt &expr) +inline const factorial_power_exprt &to_factorial_power_expr(const exprt &expr) { assert(expr.id()==ID_factorial_power && expr.operands().size()==2); return static_cast(expr); @@ -939,7 +939,7 @@ extern inline const factorial_power_exprt &to_factorial_power_expr(const exprt & /*! \copydoc to_factorial_power_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline factorial_power_exprt &to_factorial_expr(exprt &expr) +inline factorial_power_exprt &to_factorial_expr(exprt &expr) { assert(expr.id()==ID_factorial_power && expr.operands().size()==2); return static_cast(expr); @@ -970,7 +970,7 @@ class equal_exprt:public binary_relation_exprt * * \ingroup gr_std_expr */ -extern inline const equal_exprt &to_equal_expr(const exprt &expr) +inline const equal_exprt &to_equal_expr(const exprt &expr) { assert(expr.id()==ID_equal && expr.operands().size()==2); return static_cast(expr); @@ -979,7 +979,7 @@ extern inline const equal_exprt &to_equal_expr(const exprt &expr) /*! \copydoc to_equal_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline equal_exprt &to_equal_expr(exprt &expr) +inline equal_exprt &to_equal_expr(exprt &expr) { assert(expr.id()==ID_equal && expr.operands().size()==2); return static_cast(expr); @@ -1010,7 +1010,7 @@ class notequal_exprt:public binary_relation_exprt * * \ingroup gr_std_expr */ -extern inline const notequal_exprt &to_notequal_expr(const exprt &expr) +inline const notequal_exprt &to_notequal_expr(const exprt &expr) { assert(expr.id()==ID_notequal && expr.operands().size()==2); return static_cast(expr); @@ -1019,7 +1019,7 @@ extern inline const notequal_exprt &to_notequal_expr(const exprt &expr) /*! \copydoc to_notequal_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline notequal_exprt &to_notequal_expr(exprt &expr) +inline notequal_exprt &to_notequal_expr(exprt &expr) { assert(expr.id()==ID_notequal && expr.operands().size()==2); return static_cast(expr); @@ -1392,7 +1392,7 @@ class complex_exprt:public binary_exprt * * \ingroup gr_std_expr */ -static inline const complex_exprt &to_complex_expr(const exprt &expr) +inline const complex_exprt &to_complex_expr(const exprt &expr) { assert(expr.id()==ID_complex && expr.operands().size()==2); return static_cast(expr); @@ -1401,7 +1401,7 @@ static inline const complex_exprt &to_complex_expr(const exprt &expr) /*! \copydoc to_complex_expr(const exprt &) * \ingroup gr_std_expr */ -static inline complex_exprt &to_complex_expr(exprt &expr) +inline complex_exprt &to_complex_expr(exprt &expr) { assert(expr.id()==ID_complex && expr.operands().size()==2); return static_cast(expr); @@ -1585,7 +1585,7 @@ class typecast_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const typecast_exprt &to_typecast_expr(const exprt &expr) +inline const typecast_exprt &to_typecast_expr(const exprt &expr) { assert(expr.id()==ID_typecast && expr.operands().size()==1); return static_cast(expr); @@ -1594,7 +1594,7 @@ extern inline const typecast_exprt &to_typecast_expr(const exprt &expr) /*! \copydoc to_typecast_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline typecast_exprt &to_typecast_expr(exprt &expr) +inline typecast_exprt &to_typecast_expr(exprt &expr) { assert(expr.id()==ID_typecast && expr.operands().size()==1); return static_cast(expr); @@ -1648,7 +1648,7 @@ class floatbv_typecast_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const floatbv_typecast_exprt &to_floatbv_typecast_expr(const exprt &expr) +inline const floatbv_typecast_exprt &to_floatbv_typecast_expr(const exprt &expr) { assert(expr.id()==ID_floatbv_typecast && expr.operands().size()==2); return static_cast(expr); @@ -1657,7 +1657,7 @@ extern inline const floatbv_typecast_exprt &to_floatbv_typecast_expr(const exprt /*! \copydoc to_floatbv_typecast_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline floatbv_typecast_exprt &to_floatbv_typecast_expr(exprt &expr) +inline floatbv_typecast_exprt &to_floatbv_typecast_expr(exprt &expr) { assert(expr.id()==ID_floatbv_typecast && expr.operands().size()==2); return static_cast(expr); @@ -1710,7 +1710,7 @@ exprt conjunction(const exprt::operandst &); * * \ingroup gr_std_expr */ -extern inline const and_exprt &to_and_expr(const exprt &expr) +inline const and_exprt &to_and_expr(const exprt &expr) { assert(expr.id()==ID_and); return static_cast(expr); @@ -1719,7 +1719,7 @@ extern inline const and_exprt &to_and_expr(const exprt &expr) /*! \copydoc to_and_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline and_exprt &to_and_expr(exprt &expr) +inline and_exprt &to_and_expr(exprt &expr) { assert(expr.id()==ID_and); return static_cast(expr); @@ -1750,7 +1750,7 @@ class implies_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const implies_exprt &to_implies_expr(const exprt &expr) +inline const implies_exprt &to_implies_expr(const exprt &expr) { assert(expr.id()==ID_implies && expr.operands().size()==2); return static_cast(expr); @@ -1759,7 +1759,7 @@ extern inline const implies_exprt &to_implies_expr(const exprt &expr) /*! \copydoc to_implies_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline implies_exprt &to_implies_expr(exprt &expr) +inline implies_exprt &to_implies_expr(exprt &expr) { assert(expr.id()==ID_implies && expr.operands().size()==2); return static_cast(expr); @@ -1812,7 +1812,7 @@ exprt disjunction(const exprt::operandst &); * * \ingroup gr_std_expr */ -extern inline const or_exprt &to_or_expr(const exprt &expr) +inline const or_exprt &to_or_expr(const exprt &expr) { assert(expr.id()==ID_or); return static_cast(expr); @@ -1821,7 +1821,7 @@ extern inline const or_exprt &to_or_expr(const exprt &expr) /*! \copydoc to_or_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline or_exprt &to_or_expr(exprt &expr) +inline or_exprt &to_or_expr(exprt &expr) { assert(expr.id()==ID_or); return static_cast(expr); @@ -1868,7 +1868,7 @@ class bitor_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const bitor_exprt &to_bitor_expr(const exprt &expr) +inline const bitor_exprt &to_bitor_expr(const exprt &expr) { assert(expr.id()==ID_bitor); return static_cast(expr); @@ -1877,7 +1877,7 @@ extern inline const bitor_exprt &to_bitor_expr(const exprt &expr) /*! \copydoc to_bitor_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline bitor_exprt &to_bitor_expr(exprt &expr) +inline bitor_exprt &to_bitor_expr(exprt &expr) { assert(expr.id()==ID_bitor); return static_cast(expr); @@ -1909,7 +1909,7 @@ class bitxor_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const bitxor_exprt &to_bitxor_expr(const exprt &expr) +inline const bitxor_exprt &to_bitxor_expr(const exprt &expr) { assert(expr.id()==ID_bitxor); return static_cast(expr); @@ -1918,7 +1918,7 @@ extern inline const bitxor_exprt &to_bitxor_expr(const exprt &expr) /*! \copydoc to_bitxor_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline bitxor_exprt &to_bitxor_expr(exprt &expr) +inline bitxor_exprt &to_bitxor_expr(exprt &expr) { assert(expr.id()==ID_bitxor); return static_cast(expr); @@ -1950,7 +1950,7 @@ class bitand_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const bitand_exprt &to_bitand_expr(const exprt &expr) +inline const bitand_exprt &to_bitand_expr(const exprt &expr) { assert(expr.id()==ID_bitand); return static_cast(expr); @@ -1959,7 +1959,7 @@ extern inline const bitand_exprt &to_bitand_expr(const exprt &expr) /*! \copydoc to_bitand_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline bitand_exprt &to_bitand_expr(exprt &expr) +inline bitand_exprt &to_bitand_expr(exprt &expr) { assert(expr.id()==ID_bitand); return static_cast(expr); @@ -2016,7 +2016,7 @@ class shift_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const shift_exprt &to_shift_expr(const exprt &expr) +inline const shift_exprt &to_shift_expr(const exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -2025,7 +2025,7 @@ extern inline const shift_exprt &to_shift_expr(const exprt &expr) /*! \copydoc to_shift_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline shift_exprt &to_shift_expr(exprt &expr) +inline shift_exprt &to_shift_expr(exprt &expr) { assert(expr.operands().size()==2); return static_cast(expr); @@ -2136,7 +2136,7 @@ class replication_exprt:public binary_exprt * * \ingroup gr_std_expr */ -extern inline const replication_exprt &to_replication_expr(const exprt &expr) +inline const replication_exprt &to_replication_expr(const exprt &expr) { assert(expr.id()==ID_replication && expr.operands().size()==2); return static_cast(expr); @@ -2145,7 +2145,7 @@ extern inline const replication_exprt &to_replication_expr(const exprt &expr) /*! \copydoc to_replication_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline replication_exprt &to_replication_expr(exprt &expr) +inline replication_exprt &to_replication_expr(exprt &expr) { assert(expr.id()==ID_replication && expr.operands().size()==2); return static_cast(expr); @@ -2201,7 +2201,7 @@ class extractbit_exprt:public binary_predicate_exprt * * \ingroup gr_std_expr */ -extern inline const extractbit_exprt &to_extractbit_expr(const exprt &expr) +inline const extractbit_exprt &to_extractbit_expr(const exprt &expr) { assert(expr.id()==ID_extractbit && expr.operands().size()==2); return static_cast(expr); @@ -2210,7 +2210,7 @@ extern inline const extractbit_exprt &to_extractbit_expr(const exprt &expr) /*! \copydoc to_extractbit_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline extractbit_exprt &to_extractbit_expr(exprt &expr) +inline extractbit_exprt &to_extractbit_expr(exprt &expr) { assert(expr.id()==ID_extractbit && expr.operands().size()==2); return static_cast(expr); @@ -2284,7 +2284,7 @@ class extractbits_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const extractbits_exprt &to_extractbits_expr(const exprt &expr) +inline const extractbits_exprt &to_extractbits_expr(const exprt &expr) { assert(expr.id()==ID_extractbits && expr.operands().size()==3); return static_cast(expr); @@ -2293,7 +2293,7 @@ extern inline const extractbits_exprt &to_extractbits_expr(const exprt &expr) /*! \copydoc to_extractbits_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline extractbits_exprt &to_extractbits_expr(exprt &expr) +inline extractbits_exprt &to_extractbits_expr(exprt &expr) { assert(expr.id()==ID_extractbits && expr.operands().size()==3); return static_cast(expr); @@ -2337,7 +2337,7 @@ class address_of_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const address_of_exprt &to_address_of_expr(const exprt &expr) +inline const address_of_exprt &to_address_of_expr(const exprt &expr) { assert(expr.id()==ID_address_of && expr.operands().size()==1); return static_cast(expr); @@ -2346,7 +2346,7 @@ extern inline const address_of_exprt &to_address_of_expr(const exprt &expr) /*! \copydoc to_address_of_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline address_of_exprt &to_address_of_expr(exprt &expr) +inline address_of_exprt &to_address_of_expr(exprt &expr) { assert(expr.id()==ID_address_of && expr.operands().size()==1); return static_cast(expr); @@ -2388,7 +2388,7 @@ class not_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const not_exprt &to_not_expr(const exprt &expr) +inline const not_exprt &to_not_expr(const exprt &expr) { assert(expr.id()==ID_not && expr.operands().size()==1); return static_cast(expr); @@ -2397,7 +2397,7 @@ extern inline const not_exprt &to_not_expr(const exprt &expr) /*! \copydoc to_not_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline not_exprt &to_not_expr(exprt &expr) +inline not_exprt &to_not_expr(exprt &expr) { assert(expr.id()==ID_not && expr.operands().size()==1); return static_cast(expr); @@ -2449,7 +2449,7 @@ class dereference_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const dereference_exprt &to_dereference_expr(const exprt &expr) +inline const dereference_exprt &to_dereference_expr(const exprt &expr) { assert(expr.id()==ID_dereference && expr.operands().size()==1); return static_cast(expr); @@ -2458,7 +2458,7 @@ extern inline const dereference_exprt &to_dereference_expr(const exprt &expr) /*! \copydoc to_dereference_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline dereference_exprt &to_dereference_expr(exprt &expr) +inline dereference_exprt &to_dereference_expr(exprt &expr) { assert(expr.id()==ID_dereference && expr.operands().size()==1); return static_cast(expr); @@ -2527,7 +2527,7 @@ class if_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const if_exprt &to_if_expr(const exprt &expr) +inline const if_exprt &to_if_expr(const exprt &expr) { assert(expr.id()==ID_if && expr.operands().size()==3); return static_cast(expr); @@ -2536,7 +2536,7 @@ extern inline const if_exprt &to_if_expr(const exprt &expr) /*! \copydoc to_if_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline if_exprt &to_if_expr(exprt &expr) +inline if_exprt &to_if_expr(exprt &expr) { assert(expr.id()==ID_if && expr.operands().size()==3); return static_cast(expr); @@ -2604,7 +2604,7 @@ class with_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const with_exprt &to_with_expr(const exprt &expr) +inline const with_exprt &to_with_expr(const exprt &expr) { assert(expr.id()==ID_with && expr.operands().size()==3); return static_cast(expr); @@ -2613,7 +2613,7 @@ extern inline const with_exprt &to_with_expr(const exprt &expr) /*! \copydoc to_with_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline with_exprt &to_with_expr(exprt &expr) +inline with_exprt &to_with_expr(exprt &expr) { assert(expr.id()==ID_with && expr.operands().size()==3); return static_cast(expr); @@ -2649,7 +2649,7 @@ class index_designatort:public exprt * * \ingroup gr_std_expr */ -extern inline const index_designatort &to_index_designator(const exprt &expr) +inline const index_designatort &to_index_designator(const exprt &expr) { assert(expr.id()==ID_index_designator && expr.operands().size()==1); return static_cast(expr); @@ -2658,7 +2658,7 @@ extern inline const index_designatort &to_index_designator(const exprt &expr) /*! \copydoc to_index_designator(const exprt &) * \ingroup gr_std_expr */ -extern inline index_designatort &to_index_designator(exprt &expr) +inline index_designatort &to_index_designator(exprt &expr) { assert(expr.id()==ID_index_designator && expr.operands().size()==1); return static_cast(expr); @@ -2689,7 +2689,7 @@ class member_designatort:public exprt * * \ingroup gr_std_expr */ -extern inline const member_designatort &to_member_designator(const exprt &expr) +inline const member_designatort &to_member_designator(const exprt &expr) { assert(expr.id()==ID_member_designator && expr.operands().size()==0); return static_cast(expr); @@ -2698,7 +2698,7 @@ extern inline const member_designatort &to_member_designator(const exprt &expr) /*! \copydoc to_member_designator(const exprt &) * \ingroup gr_std_expr */ -extern inline member_designatort &to_member_designator(exprt &expr) +inline member_designatort &to_member_designator(exprt &expr) { assert(expr.id()==ID_member_designator && expr.operands().size()==0); return static_cast(expr); @@ -2775,7 +2775,7 @@ class update_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const update_exprt &to_update_expr(const exprt &expr) +inline const update_exprt &to_update_expr(const exprt &expr) { assert(expr.id()==ID_update && expr.operands().size()==3); return static_cast(expr); @@ -2784,7 +2784,7 @@ extern inline const update_exprt &to_update_expr(const exprt &expr) /*! \copydoc to_update_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline update_exprt &to_update_expr(exprt &expr) +inline update_exprt &to_update_expr(exprt &expr) { assert(expr.id()==ID_update && expr.operands().size()==3); return static_cast(expr); @@ -2851,7 +2851,7 @@ class array_update_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const array_update_exprt &to_array_update_expr(const exprt &expr) +inline const array_update_exprt &to_array_update_expr(const exprt &expr) { assert(expr.id()==ID_array_update && expr.operands().size()==3); return static_cast(expr); @@ -2860,7 +2860,7 @@ extern inline const array_update_exprt &to_array_update_expr(const exprt &expr) /*! \copydoc to_array_update_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline array_update_exprt &to_array_update_expr(exprt &expr) +inline array_update_exprt &to_array_update_expr(exprt &expr) { assert(expr.id()==ID_array_update && expr.operands().size()==3); return static_cast(expr); @@ -3152,7 +3152,7 @@ class ieee_float_equal_exprt:public binary_relation_exprt * * \ingroup gr_std_expr */ -extern inline const ieee_float_equal_exprt &to_ieee_float_equal_expr(const exprt &expr) +inline const ieee_float_equal_exprt &to_ieee_float_equal_expr(const exprt &expr) { assert(expr.id()==ID_ieee_float_equal && expr.operands().size()==2); return static_cast(expr); @@ -3161,7 +3161,7 @@ extern inline const ieee_float_equal_exprt &to_ieee_float_equal_expr(const exprt /*! \copydoc to_ieee_float_equal_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline ieee_float_equal_exprt &to_ieee_float_equal_expr(exprt &expr) +inline ieee_float_equal_exprt &to_ieee_float_equal_expr(exprt &expr) { assert(expr.id()==ID_ieee_float_equal && expr.operands().size()==2); return static_cast(expr); @@ -3192,7 +3192,7 @@ class ieee_float_notequal_exprt:public binary_relation_exprt * * \ingroup gr_std_expr */ -extern inline const ieee_float_notequal_exprt &to_ieee_float_notequal_expr(const exprt &expr) +inline const ieee_float_notequal_exprt &to_ieee_float_notequal_expr(const exprt &expr) { assert(expr.id()==ID_ieee_float_notequal && expr.operands().size()==2); return static_cast(expr); @@ -3201,7 +3201,7 @@ extern inline const ieee_float_notequal_exprt &to_ieee_float_notequal_expr(const /*! \copydoc to_ieee_float_notequal_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline ieee_float_notequal_exprt &to_ieee_float_notequal_expr(exprt &expr) +inline ieee_float_notequal_exprt &to_ieee_float_notequal_expr(exprt &expr) { assert(expr.id()==ID_ieee_float_notequal && expr.operands().size()==2); return static_cast(expr); @@ -3264,7 +3264,7 @@ class ieee_float_op_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const ieee_float_op_exprt &to_ieee_float_op_expr(const exprt &expr) +inline const ieee_float_op_exprt &to_ieee_float_op_expr(const exprt &expr) { assert(expr.operands().size()==3); return static_cast(expr); @@ -3273,7 +3273,7 @@ extern inline const ieee_float_op_exprt &to_ieee_float_op_expr(const exprt &expr /*! \copydoc to_ieee_float_op_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline ieee_float_op_exprt &to_ieee_float_op_expr(exprt &expr) +inline ieee_float_op_exprt &to_ieee_float_op_expr(exprt &expr) { assert(expr.operands().size()==3); return static_cast(expr); @@ -3438,7 +3438,7 @@ class function_application_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const function_application_exprt &to_function_application_expr(const exprt &expr) +inline const function_application_exprt &to_function_application_expr(const exprt &expr) { assert(expr.id()==ID_function_application && expr.operands().size()==2); return static_cast(expr); @@ -3447,7 +3447,7 @@ extern inline const function_application_exprt &to_function_application_expr(con /*! \copydoc to_function_application_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline function_application_exprt &to_function_application_expr(exprt &expr) +inline function_application_exprt &to_function_application_expr(exprt &expr) { assert(expr.id()==ID_function_application && expr.operands().size()==2); return static_cast(expr); @@ -3490,7 +3490,7 @@ class concatenation_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const concatenation_exprt &to_concatenation_expr(const exprt &expr) +inline const concatenation_exprt &to_concatenation_expr(const exprt &expr) { assert(expr.id()==ID_concatenation); return static_cast(expr); @@ -3499,7 +3499,7 @@ extern inline const concatenation_exprt &to_concatenation_expr(const exprt &expr /*! \copydoc to_concatenation_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline concatenation_exprt &to_concatenation_expr(exprt &expr) +inline concatenation_exprt &to_concatenation_expr(exprt &expr) { assert(expr.id()==ID_concatenation); return static_cast(expr); @@ -3568,7 +3568,7 @@ class let_exprt:public exprt * * \ingroup gr_std_expr */ -extern inline const let_exprt &to_let_expr(const exprt &expr) +inline const let_exprt &to_let_expr(const exprt &expr) { assert(expr.id()==ID_let && expr.operands().size()==3); return static_cast(expr); @@ -3577,7 +3577,7 @@ extern inline const let_exprt &to_let_expr(const exprt &expr) /*! \copydoc to_let_expr(const exprt &) * \ingroup gr_std_expr */ -extern inline let_exprt &to_let_expr(exprt &expr) +inline let_exprt &to_let_expr(exprt &expr) { assert(expr.id()==ID_let && expr.operands().size()==3); return static_cast(expr); diff --git a/src/util/std_types.h b/src/util/std_types.h index 0661e3a5e12..a6e56a4e4fa 100644 --- a/src/util/std_types.h +++ b/src/util/std_types.h @@ -138,7 +138,7 @@ class symbol_typet:public typet * * \ingroup gr_std_types */ -extern inline const symbol_typet &to_symbol_type(const typet &type) +inline const symbol_typet &to_symbol_type(const typet &type) { assert(type.id()==ID_symbol); return static_cast(type); @@ -147,7 +147,7 @@ extern inline const symbol_typet &to_symbol_type(const typet &type) /*! \copydoc to_symbol_type(const typet &) * \ingroup gr_std_types */ -extern inline symbol_typet &to_symbol_type(typet &type) +inline symbol_typet &to_symbol_type(typet &type) { assert(type.id()==ID_symbol); return static_cast(type); @@ -273,7 +273,7 @@ class struct_union_typet:public typet * * \ingroup gr_std_types */ -extern inline const struct_union_typet &to_struct_union_type(const typet &type) +inline const struct_union_typet &to_struct_union_type(const typet &type) { assert(type.id()==ID_struct || type.id()==ID_union); @@ -283,7 +283,7 @@ extern inline const struct_union_typet &to_struct_union_type(const typet &type) /*! \copydoc to_struct_union_type(const typet &) * \ingroup gr_std_types */ -extern inline struct_union_typet &to_struct_union_type(typet &type) +inline struct_union_typet &to_struct_union_type(typet &type) { assert(type.id()==ID_struct || type.id()==ID_union); @@ -313,7 +313,7 @@ class struct_typet:public struct_union_typet * * \ingroup gr_std_types */ -extern inline const struct_typet &to_struct_type(const typet &type) +inline const struct_typet &to_struct_type(const typet &type) { assert(type.id()==ID_struct); return static_cast(type); @@ -322,7 +322,7 @@ extern inline const struct_typet &to_struct_type(const typet &type) /*! \copydoc to_struct_type(const typet &) * \ingroup gr_std_types */ -extern inline struct_typet &to_struct_type(typet &type) +inline struct_typet &to_struct_type(typet &type) { assert(type.id()==ID_struct); return static_cast(type); @@ -403,7 +403,7 @@ class class_typet:public struct_typet * * \ingroup gr_std_types */ -extern inline const class_typet &to_class_type(const typet &type) +inline const class_typet &to_class_type(const typet &type) { assert(type.id()==ID_struct); return static_cast(type); @@ -412,7 +412,7 @@ extern inline const class_typet &to_class_type(const typet &type) /*! \copydoc to_class_type(const typet &) * \ingroup gr_std_types */ -extern inline class_typet &to_class_type(typet &type) +inline class_typet &to_class_type(typet &type) { assert(type.id()==ID_struct); return static_cast(type); @@ -438,7 +438,7 @@ class union_typet:public struct_union_typet * * \ingroup gr_std_types */ -extern inline const union_typet &to_union_type(const typet &type) +inline const union_typet &to_union_type(const typet &type) { assert(type.id()==ID_union); return static_cast(type); @@ -447,7 +447,7 @@ extern inline const union_typet &to_union_type(const typet &type) /*! \copydoc to_union_type(const typet &) * \ingroup gr_std_types */ -extern inline union_typet &to_union_type(typet &type) +inline union_typet &to_union_type(typet &type) { assert(type.id()==ID_union); return static_cast(type); @@ -491,7 +491,7 @@ class tag_typet:public typet * * \ingroup gr_std_types */ -extern inline const tag_typet &to_tag_type(const typet &type) +inline const tag_typet &to_tag_type(const typet &type) { assert(type.id()==ID_c_enum_tag || type.id()==ID_struct_tag || @@ -502,7 +502,7 @@ extern inline const tag_typet &to_tag_type(const typet &type) /*! \copydoc to_tag_type(const typet &) * \ingroup gr_std_types */ -extern inline tag_typet &to_tag_type(typet &type) +inline tag_typet &to_tag_type(typet &type) { assert(type.id()==ID_c_enum_tag || type.id()==ID_struct_tag || @@ -532,7 +532,7 @@ class struct_tag_typet:public tag_typet * * \ingroup gr_std_types */ -extern inline const struct_tag_typet &to_struct_tag_type(const typet &type) +inline const struct_tag_typet &to_struct_tag_type(const typet &type) { assert(type.id()==ID_struct_tag); return static_cast(type); @@ -541,7 +541,7 @@ extern inline const struct_tag_typet &to_struct_tag_type(const typet &type) /*! \copydoc to_struct_tag_type(const typet &) * \ingroup gr_std_types */ -extern inline struct_tag_typet &to_struct_tag_type(typet &type) +inline struct_tag_typet &to_struct_tag_type(typet &type) { assert(type.id()==ID_struct_tag); return static_cast(type); @@ -569,7 +569,7 @@ class union_tag_typet:public tag_typet * * \ingroup gr_std_types */ -extern inline const union_tag_typet &to_union_tag_type(const typet &type) +inline const union_tag_typet &to_union_tag_type(const typet &type) { assert(type.id()==ID_union_tag); return static_cast(type); @@ -578,7 +578,7 @@ extern inline const union_tag_typet &to_union_tag_type(const typet &type) /*! \copydoc to_union_tag_type(const typet &) * \ingroup gr_std_types */ -extern inline union_tag_typet &to_union_tag_type(typet &type) +inline union_tag_typet &to_union_tag_type(typet &type) { assert(type.id()==ID_union_tag); return static_cast(type); @@ -615,7 +615,7 @@ class enumeration_typet:public typet * * \ingroup gr_std_types */ -extern inline const enumeration_typet &to_enumeration_type(const typet &type) +inline const enumeration_typet &to_enumeration_type(const typet &type) { assert(type.id()==ID_enumeration); return static_cast(type); @@ -624,7 +624,7 @@ extern inline const enumeration_typet &to_enumeration_type(const typet &type) /*! \copydoc to_enumeration_type(const typet &) * \ingroup gr_std_types */ -extern inline enumeration_typet &to_enumeration_type(typet &type) +inline enumeration_typet &to_enumeration_type(typet &type) { assert(type.id()==ID_enumeration); return static_cast(type); @@ -669,7 +669,7 @@ class c_enum_typet:public type_with_subtypet * * \ingroup gr_std_types */ -extern inline const c_enum_typet &to_c_enum_type(const typet &type) +inline const c_enum_typet &to_c_enum_type(const typet &type) { assert(type.id()==ID_c_enum); return static_cast(type); @@ -678,7 +678,7 @@ extern inline const c_enum_typet &to_c_enum_type(const typet &type) /*! \copydoc to_c_enum_type(const typet &) * \ingroup gr_std_types */ -extern inline c_enum_typet &to_c_enum_type(typet &type) +inline c_enum_typet &to_c_enum_type(typet &type) { assert(type.id()==ID_c_enum); return static_cast(type); @@ -706,7 +706,7 @@ class c_enum_tag_typet:public tag_typet * * \ingroup gr_std_types */ -extern inline const c_enum_tag_typet &to_c_enum_tag_type(const typet &type) +inline const c_enum_tag_typet &to_c_enum_tag_type(const typet &type) { assert(type.id()==ID_c_enum_tag); return static_cast(type); @@ -715,7 +715,7 @@ extern inline const c_enum_tag_typet &to_c_enum_tag_type(const typet &type) /*! \copydoc to_enum_tag_type(const typet &) * \ingroup gr_std_types */ -extern inline c_enum_tag_typet &to_c_enum_tag_type(typet &type) +inline c_enum_tag_typet &to_c_enum_tag_type(typet &type) { assert(type.id()==ID_c_enum_tag); return static_cast(type); @@ -873,7 +873,7 @@ class code_typet:public typet * * \ingroup gr_std_types */ -extern inline const code_typet &to_code_type(const typet &type) +inline const code_typet &to_code_type(const typet &type) { assert(type.id()==ID_code); return static_cast(type); @@ -882,7 +882,7 @@ extern inline const code_typet &to_code_type(const typet &type) /*! \copydoc to_code_type(const typet &) * \ingroup gr_std_types */ -extern inline code_typet &to_code_type(typet &type) +inline code_typet &to_code_type(typet &type) { assert(type.id()==ID_code); return static_cast(type); @@ -935,7 +935,7 @@ class array_typet:public type_with_subtypet * * \ingroup gr_std_types */ -extern inline const array_typet &to_array_type(const typet &type) +inline const array_typet &to_array_type(const typet &type) { assert(type.id()==ID_array); return static_cast(type); @@ -944,7 +944,7 @@ extern inline const array_typet &to_array_type(const typet &type) /*! \copydoc to_array_type(const typet &) * \ingroup gr_std_types */ -extern inline array_typet &to_array_type(typet &type) +inline array_typet &to_array_type(typet &type) { assert(type.id()==ID_array); return static_cast(type); @@ -975,7 +975,7 @@ class incomplete_array_typet:public type_with_subtypet * * \ingroup gr_std_types */ -extern inline const incomplete_array_typet &to_incomplete_array_type(const typet &type) +inline const incomplete_array_typet &to_incomplete_array_type(const typet &type) { assert(type.id()==ID_array); return static_cast(type); @@ -984,7 +984,7 @@ extern inline const incomplete_array_typet &to_incomplete_array_type(const typet /*! \copydoc to_incomplete_array_type(const typet &) * \ingroup gr_std_types */ -extern inline incomplete_array_typet &to_incomplete_array_type(typet &type) +inline incomplete_array_typet &to_incomplete_array_type(typet &type) { assert(type.id()==ID_array); return static_cast(type); @@ -1361,7 +1361,7 @@ class pointer_typet:public bitvector_typet * * \ingroup gr_std_types */ -extern inline const pointer_typet &to_pointer_type(const typet &type) +inline const pointer_typet &to_pointer_type(const typet &type) { assert(type.id()==ID_pointer); return static_cast(type); @@ -1370,7 +1370,7 @@ extern inline const pointer_typet &to_pointer_type(const typet &type) /*! \copydoc to_pointer_type(const typet &) * \ingroup gr_std_types */ -extern inline pointer_typet &to_pointer_type(typet &type) +inline pointer_typet &to_pointer_type(typet &type) { assert(type.id()==ID_pointer); return static_cast(type); @@ -1432,7 +1432,7 @@ class c_bool_typet:public bitvector_typet * * \ingroup gr_std_types */ -extern inline const c_bool_typet &to_c_bool_type(const typet &type) +inline const c_bool_typet &to_c_bool_type(const typet &type) { assert(type.id()==ID_c_bool); return static_cast(type); @@ -1441,7 +1441,7 @@ extern inline const c_bool_typet &to_c_bool_type(const typet &type) /*! \copydoc to_c_bool_type(const typet &) * \ingroup gr_std_types */ -extern inline c_bool_typet &to_c_bool_type(typet &type) +inline c_bool_typet &to_c_bool_type(typet &type) { assert(type.id()==ID_c_bool); return static_cast(type); @@ -1548,7 +1548,7 @@ class vector_typet:public type_with_subtypet * * \ingroup gr_std_types */ -extern inline const vector_typet &to_vector_type(const typet &type) +inline const vector_typet &to_vector_type(const typet &type) { assert(type.id()==ID_vector); return static_cast(type); @@ -1557,7 +1557,7 @@ extern inline const vector_typet &to_vector_type(const typet &type) /*! \copydoc to_vector_type(const typet &) * \ingroup gr_std_types */ -extern inline vector_typet &to_vector_type(typet &type) +inline vector_typet &to_vector_type(typet &type) { assert(type.id()==ID_vector); return static_cast(type); @@ -1588,7 +1588,7 @@ class complex_typet:public type_with_subtypet * * \ingroup gr_std_types */ -extern inline const complex_typet &to_complex_type(const typet &type) +inline const complex_typet &to_complex_type(const typet &type) { assert(type.id()==ID_complex); return static_cast(type); @@ -1597,7 +1597,7 @@ extern inline const complex_typet &to_complex_type(const typet &type) /*! \copydoc to_complex_type(const typet &) * \ingroup gr_std_types */ -extern inline complex_typet &to_complex_type(typet &type) +inline complex_typet &to_complex_type(typet &type) { assert(type.id()==ID_complex); return static_cast(type); diff --git a/src/util/xml.h b/src/util/xml.h index f2f19b69670..bfd6bff9ab0 100644 --- a/src/util/xml.h +++ b/src/util/xml.h @@ -122,7 +122,7 @@ class xmlt unsigned indent); }; -extern inline std::ostream& operator <<( +inline std::ostream& operator<<( std::ostream &out, const xmlt &xml) { From 8ca2e12a88e453705a856feb70c2fd04fc18cc7e Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 23:09:51 +0100 Subject: [PATCH 14/47] Remove unnecessary friend declarations This may cause protection problems. --- src/analyses/constant_propagator.h | 2 -- src/analyses/escape_analysis.h | 2 -- src/analyses/flow_insensitive_analysis.h | 1 - src/cbmc/bmc.h | 4 ---- src/cpp/cpp_id.h | 2 -- src/goto-programs/interpreter_class.h | 2 -- src/solvers/miniBDD/miniBDD.h | 1 - src/util/merge_irep.h | 1 - src/util/simplify_expr.cpp | 2 -- 9 files changed, 17 deletions(-) diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index 026bc96f970..50963650695 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -107,8 +107,6 @@ class constant_propagator_ait:public ait } protected: - friend class constant_propagator_domaint; - void replace( goto_functionst::goto_functiont &, const namespacet &); diff --git a/src/analyses/escape_analysis.h b/src/analyses/escape_analysis.h index 3cccec91a30..f1d17bcb3df 100644 --- a/src/analyses/escape_analysis.h +++ b/src/analyses/escape_analysis.h @@ -110,8 +110,6 @@ class escape_analysist:public ait { } - friend class escape_domaint; - numbering bits; void insert_cleanup( diff --git a/src/analyses/flow_insensitive_analysis.h b/src/analyses/flow_insensitive_analysis.h index 15378cd08b5..8d1292ca61c 100644 --- a/src/analyses/flow_insensitive_analysis.h +++ b/src/analyses/flow_insensitive_analysis.h @@ -59,7 +59,6 @@ class flow_insensitive_abstract_domain_baset virtual void clear(void)=0; protected: - friend class flow_insensitive_analysis_baset; bool changed; // utilities diff --git a/src/cbmc/bmc.h b/src/cbmc/bmc.h index 5b8a64e9adb..10ae1b6dcbd 100644 --- a/src/cbmc/bmc.h +++ b/src/cbmc/bmc.h @@ -53,10 +53,6 @@ class bmct:public safety_checkert // additional stuff expr_listt bmc_constraints; - friend class cbmc_satt; - friend class hw_cbmc_satt; - friend class counterexample_beautification_greedyt; - void set_ui(language_uit::uit _ui) { ui=_ui; } // the safety_checkert interface diff --git a/src/cpp/cpp_id.h b/src/cpp/cpp_id.h index 1994c52bc68..8b9c96027c9 100644 --- a/src/cpp/cpp_id.h +++ b/src/cpp/cpp_id.h @@ -90,8 +90,6 @@ class cpp_idt void print(std::ostream &out, unsigned indent=0) const; void print_fields(std::ostream &out, unsigned indent=0) const; - friend class cpp_scopet; - protected: cpp_id_mapt sub; diff --git a/src/goto-programs/interpreter_class.h b/src/goto-programs/interpreter_class.h index 9a3133e9f1c..cc442507b65 100644 --- a/src/goto-programs/interpreter_class.h +++ b/src/goto-programs/interpreter_class.h @@ -29,8 +29,6 @@ class interpretert void operator()(); - friend class simplify_evaluatet; - protected: const symbol_tablet &symbol_table; const namespacet ns; diff --git a/src/solvers/miniBDD/miniBDD.h b/src/solvers/miniBDD/miniBDD.h index 2f09173f7be..6db6c6b3bf3 100644 --- a/src/solvers/miniBDD/miniBDD.h +++ b/src/solvers/miniBDD/miniBDD.h @@ -92,7 +92,6 @@ class mini_bdd_mgrt inline const mini_bddt &True() const; inline const mini_bddt &False() const; - friend class mini_bddt; friend class mini_bdd_nodet; // create a node (consulting the reverse-map) diff --git a/src/util/merge_irep.h b/src/util/merge_irep.h index a7f182e9b6b..6b1b8f18355 100644 --- a/src/util/merge_irep.h +++ b/src/util/merge_irep.h @@ -43,7 +43,6 @@ class merged_irept:public irept } friend class merged_irepst; - friend class to_be_merged_irept; }; struct merged_irep_hash diff --git a/src/util/simplify_expr.cpp b/src/util/simplify_expr.cpp index a5f9b69c943..250672f72e5 100644 --- a/src/util/simplify_expr.cpp +++ b/src/util/simplify_expr.cpp @@ -47,8 +47,6 @@ Author: Daniel Kroening, kroening@kroening.com struct simplify_expr_cachet { public: - friend class simplify_exprt; - #if 1 typedef std::unordered_map< exprt, exprt, irep_full_hash, irep_full_eq> containert; From f191d170b748f7e156fff348c7eb9acd880ee01e Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 22 Dec 2016 10:51:36 +0100 Subject: [PATCH 15/47] Whitespace and line breaks to match coding guidelines --- src/aa-path-symex/path_symex.cpp | 21 +- src/aa-path-symex/path_symex_state.cpp | 6 +- src/aa-symex/path_search.cpp | 6 +- src/aa-symex/path_search.h | 1 - src/analyses/ai.h | 22 +- src/analyses/cfg_dominators.h | 22 +- src/analyses/constant_propagator.h | 24 +- src/analyses/custom_bitvector_analysis.cpp | 39 +- src/analyses/dependence_graph.cpp | 6 +- src/analyses/dependence_graph.h | 3 +- src/analyses/escape_analysis.cpp | 21 +- src/analyses/escape_analysis.h | 2 +- src/analyses/flow_insensitive_analysis.h | 4 +- src/analyses/global_may_alias.cpp | 12 +- src/analyses/goto_check.cpp | 12 +- src/analyses/goto_rw.cpp | 6 +- src/analyses/interval_domain.cpp | 71 ++- src/analyses/interval_domain.h | 2 +- src/analyses/interval_template.h | 39 +- src/analyses/invariant_propagation.cpp | 7 +- src/analyses/invariant_propagation.h | 4 +- src/analyses/invariant_set.cpp | 52 +- src/analyses/invariant_set_domain.cpp | 3 +- src/analyses/is_threaded.cpp | 3 +- src/analyses/local_bitvector_analysis.cpp | 35 +- src/analyses/local_may_alias.cpp | 3 +- src/analyses/local_may_alias.h | 4 +- src/analyses/natural_loops.h | 16 +- src/analyses/reaching_definitions.cpp | 9 +- src/analyses/reaching_definitions.h | 24 +- src/analyses/static_analysis.h | 16 +- src/analyses/uninitialized_domain.cpp | 3 +- src/ansi-c/anonymous_member.cpp | 3 +- src/ansi-c/c_preprocess.cpp | 2 +- src/ansi-c/c_qualifiers.h | 3 +- src/ansi-c/c_typecast.cpp | 8 +- src/ansi-c/c_typecheck_base.cpp | 6 +- src/ansi-c/expr2c_class.h | 6 +- src/ansi-c/literals/convert_float_literal.cpp | 17 +- src/cbmc/bmc.h | 2 +- src/cbmc/cbmc_solvers.h | 9 +- src/cpp/cpp_declaration.h | 6 +- src/cpp/cpp_template_args.h | 6 +- src/cpp/cpp_typecast.h | 14 +- src/cpp/cpp_typecheck_resolve.h | 13 +- src/cpp/expr2cpp.cpp | 29 +- src/goto-cc/compile.h | 12 +- .../xml_binaries/xml_goto_function_hashing.h | 22 +- .../xml_binaries/xml_goto_program_hashing.h | 27 +- src/goto-cc/xml_binaries/xml_irep_hashing.h | 153 +++--- src/goto-cc/xml_binaries/xml_symbol_hashing.h | 19 +- src/goto-diff/change_impact.cpp | 76 ++- src/goto-diff/goto_diff.h | 7 +- src/goto-diff/goto_diff_languages.h | 4 +- src/goto-diff/goto_diff_parse_options.cpp | 60 ++- src/goto-diff/syntactic_diff.cpp | 1 - src/goto-diff/syntactic_diff.h | 10 +- src/goto-diff/unified_diff.cpp | 3 +- src/goto-instrument/object_id.h | 2 +- src/goto-instrument/rw_set.h | 15 +- src/goto-instrument/uninitialized.cpp | 6 +- src/goto-instrument/unwind.cpp | 4 +- src/goto-programs/goto_program_template.h | 65 +-- .../remove_function_pointers.cpp | 14 +- src/goto-symex/slice_by_trace.h | 9 +- src/goto-symex/symex_target_equation.h | 8 +- src/path-symex/locs.h | 13 +- src/path-symex/path_symex_history.h | 3 +- src/pointer-analysis/value_set_analysis.h | 8 +- .../value_set_dereference.cpp | 17 +- src/solvers/dplib/dplib_prop.h | 2 +- src/solvers/flattening/boolbv.cpp | 11 +- src/solvers/flattening/boolbv_typecast.cpp | 45 +- src/solvers/flattening/bv_utils.h | 74 ++- src/solvers/floatbv/float_bv.h | 80 ++- src/solvers/floatbv/float_utils.h | 12 +- src/solvers/refinement/refine_arithmetic.cpp | 13 +- src/solvers/smt2/smt2_conv.cpp | 504 ++++++++++-------- src/solvers/smt2/smt2_conv.h | 27 +- src/solvers/smt2/smt2irep.cpp | 6 +- src/util/bv_arithmetic.cpp | 8 +- src/util/bv_arithmetic.h | 10 +- src/util/byte_operators.h | 3 - src/util/expr.cpp | 6 +- src/util/expr.h | 24 +- src/util/expr_util.cpp | 4 +- src/util/file_util.cpp | 7 +- src/util/fixedbv.cpp | 5 +- src/util/fixedbv.h | 11 +- src/util/guard.h | 2 +- src/util/ieee_float.cpp | 204 +++---- src/util/ieee_float.h | 23 +- src/util/irep.cpp | 16 +- src/util/irep.h | 14 +- src/util/irep_hash.h | 44 +- src/util/merge_irep.h | 11 +- src/util/rational_tools.cpp | 8 +- src/util/simplify_expr.cpp | 111 ++-- src/util/simplify_expr_floatbv.cpp | 30 +- src/util/simplify_expr_int.cpp | 24 +- src/util/std_code.h | 3 +- src/util/std_expr.h | 115 ++-- src/util/std_types.h | 36 +- src/util/string_container.cpp | 7 +- src/util/symbol.h | 3 +- src/util/tempfile.cpp | 14 +- src/util/threeval.h | 26 +- src/util/timer.h | 8 +- 108 files changed, 1650 insertions(+), 1081 deletions(-) diff --git a/src/aa-path-symex/path_symex.cpp b/src/aa-path-symex/path_symex.cpp index 0c18e34bb8e..5a9e059058a 100644 --- a/src/aa-path-symex/path_symex.cpp +++ b/src/aa-path-symex/path_symex.cpp @@ -133,26 +133,31 @@ bool path_symext::propagate(const exprt &src) else if(src.id()==ID_plus) { forall_operands(it, src) - if(!propagate(*it)) return false; + if(!propagate(*it)) + return false; return true; } else if(src.id()==ID_array) { forall_operands(it, src) - if(!propagate(*it)) return false; + if(!propagate(*it)) + return false; return true; } else if(src.id()==ID_vector) { forall_operands(it, src) - if(!propagate(*it)) return false; + if(!propagate(*it)) + return false; return true; } else if(src.id()==ID_if) { const if_exprt &if_expr=to_if_expr(src); - if(!propagate(if_expr.true_case())) return false; - if(!propagate(if_expr.false_case())) return false; + if(!propagate(if_expr.true_case()) || + !propagate(if_expr.false_case())) + return false; + return true; } else if(src.id()==ID_array_of) @@ -244,7 +249,8 @@ inline static typet c_sizeof_type_rec(const exprt &expr) forall_operands(it, expr) { typet t=c_sizeof_type_rec(*it); - if(t.is_not_nil()) return t; + if(t.is_not_nil()) + return t; } } @@ -446,7 +452,8 @@ void path_symext::assign_rec( state.record_step(); path_symex_stept &step=*state.history; - if(!guard.empty()) step.guard=conjunction(guard); + if(!guard.empty()) + step.guard=conjunction(guard); step.full_lhs=ssa_lhs; step.ssa_lhs=new_lhs; step.ssa_rhs=ssa_rhs; diff --git a/src/aa-path-symex/path_symex_state.cpp b/src/aa-path-symex/path_symex_state.cpp index f0f21b1b8b5..2c47ebed82f 100644 --- a/src/aa-path-symex/path_symex_state.cpp +++ b/src/aa-path-symex/path_symex_state.cpp @@ -131,7 +131,8 @@ path_symex_statet::var_statet &path_symex_statet::get_var_state( var_valt &var_val= var_info.is_shared()?shared_vars:threads[current_thread].local_vars; - if(var_val.size()<=var_info.number) var_val.resize(var_info.number+1); + if(var_val.size()<=var_info.number) + var_val.resize(var_info.number+1); return var_val[var_info.number]; } @@ -771,7 +772,8 @@ bool path_symex_statet::check_assertion( exprt assertion=read(instruction.guard); // trivial? - if(assertion.is_true()) return true; // no error + if(assertion.is_true()) + return true; // no error // the path constraint decision_procedure << history; diff --git a/src/aa-symex/path_search.cpp b/src/aa-symex/path_search.cpp index b6fdfdd70dd..71576b9a944 100644 --- a/src/aa-symex/path_search.cpp +++ b/src/aa-symex/path_search.cpp @@ -218,7 +218,8 @@ int path_searcht::await() pid_t pid=wait(&status); if(pid==-1) { - if(errno==ECHILD) break; // no more child processes + if(errno==ECHILD) + break; // no more child processes } else { @@ -451,7 +452,8 @@ void path_searcht::check_assertion(statet &state) exprt assertion= state.read(instruction.guard); - if(assertion.is_true()) return; // no error, trivially + if(assertion.is_true()) + return; // no error, trivially // keep statistics number_of_VCCs_after_simplification++; diff --git a/src/aa-symex/path_search.h b/src/aa-symex/path_search.h index 7a6b270c040..3a8adfe0256 100644 --- a/src/aa-symex/path_search.h +++ b/src/aa-symex/path_search.h @@ -80,7 +80,6 @@ class path_searcht:public safety_checkert property_mapt property_map; protected: - #ifdef PATH_SYMEX_FORK // blocks until child processes have terminated int await(); diff --git a/src/analyses/ai.h b/src/analyses/ai.h index 10a9831d1c5..5d42098f6e6 100644 --- a/src/analyses/ai.h +++ b/src/analyses/ai.h @@ -36,8 +36,8 @@ class ai_domain_baset // how function calls are treated: // a) there is an edge from each call site to the function head - // b) there is an edge from the last instruction (END_FUNCTION) of the function - // to the instruction _following_ the call site + // b) there is an edge from the last instruction (END_FUNCTION) + // of the function to the instruction _following_ the call site // (this also needs to set the LHS, if applicable) virtual void transform( @@ -257,14 +257,18 @@ class ait:public ai_baset inline domainT &operator[](locationt l) { typename state_mapt::iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } inline const domainT &operator[](locationt l) const { typename state_mapt::const_iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } @@ -288,14 +292,17 @@ class ait:public ai_baset virtual const statet &find_state(locationt l) const override { typename state_mapt::const_iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } virtual bool merge(const statet &src, locationt from, locationt to) override { statet &dest=get_state(to); - return static_cast(dest).merge(static_cast(src), from, to); + return static_cast(dest).merge( + static_cast(src), from, to); } virtual statet *make_temporary_state(const statet &s) override @@ -343,7 +350,8 @@ class concurrency_aware_ait:public ait const namespacet &ns) override { statet &dest=this->get_state(to); - return static_cast(dest).merge_shared(static_cast(src), from, to, ns); + return static_cast(dest).merge_shared( + static_cast(src), from, to, ns); } protected: diff --git a/src/analyses/cfg_dominators.h b/src/analyses/cfg_dominators.h index 209a76852e6..da7cb42cfbc 100644 --- a/src/analyses/cfg_dominators.h +++ b/src/analyses/cfg_dominators.h @@ -149,7 +149,7 @@ void cfg_dominators_templatet::fixedpoint(P &program) bool changed=false; typename cfgt::nodet &node=cfg[cfg.entry_map[current]]; if(node.dominators.empty()) - for(const auto & edge : (post_dom?node.out:node.in)) + for(const auto &edge : (post_dom ? node.out : node.in)) if(!cfg[edge.first].dominators.empty()) { node.dominators=cfg[edge.first].dominators; @@ -158,7 +158,7 @@ void cfg_dominators_templatet::fixedpoint(P &program) } // compute intersection of predecessors - for(const auto & edge : (post_dom?node.out:node.in)) + for(const auto &edge : (post_dom ? node.out : node.in)) { const target_sett &other=cfg[edge.first].dominators; if(other.empty()) @@ -170,10 +170,20 @@ void cfg_dominators_templatet::fixedpoint(P &program) // in-place intersection. not safe to use set_intersect while(n_it!=node.dominators.end() && o_it!=other.end()) { - if(*n_it==current) ++n_it; - else if(*n_it<*o_it) { changed=true; node.dominators.erase(n_it++); } - else if(*o_it<*n_it) ++o_it; - else { ++n_it; ++o_it; } + if(*n_it==current) + ++n_it; + else if(*n_it<*o_it) + { + changed=true; + node.dominators.erase(n_it++); + } + else if(*o_it<*n_it) + ++o_it; + else + { + ++n_it; + ++o_it; + } } while(n_it!=node.dominators.end()) diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index 50963650695..d3cb9ee6f4a 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -16,8 +16,15 @@ Author: Peter Schrammel class constant_propagator_domaint:public ai_domain_baset { public: - void transform(locationt, locationt, ai_baset &, const namespacet &) override final; - void output(std::ostream &, const ai_baset &, const namespacet &) const override final; + void transform( + locationt, + locationt, + ai_baset &, + const namespacet &) override final; + void output( + std::ostream &, + const ai_baset &, + const namespacet &) const override final; void make_top() override final { values.set_to_top(); } void make_bottom() override final { values.set_to_bottom(); } void make_entry() override final { values.set_to_top(); } @@ -79,12 +86,15 @@ class constant_propagator_domaint:public ai_domain_baset exprt rhs, const namespacet &ns) const; - void assign_rec(valuest &values, - const exprt &lhs, const exprt &rhs, - const namespacet &ns); + void assign_rec( + valuest &values, + const exprt &lhs, + const exprt &rhs, + const namespacet &ns); - bool two_way_propagate_rec(const exprt &expr, - const namespacet &ns); + bool two_way_propagate_rec( + const exprt &expr, + const namespacet &ns); }; class constant_propagator_ait:public ait diff --git a/src/analyses/custom_bitvector_analysis.cpp b/src/analyses/custom_bitvector_analysis.cpp index 5155d13b7e5..41516606490 100644 --- a/src/analyses/custom_bitvector_analysis.cpp +++ b/src/analyses/custom_bitvector_analysis.cpp @@ -68,7 +68,8 @@ void custom_bitvector_domaint::set_bit( modet mode) { irep_idt id=object2id(lhs); - if(!id.empty()) set_bit(id, bit_nr, mode); + if(!id.empty()) + set_bit(id, bit_nr, mode); } /*******************************************************************\ @@ -133,7 +134,8 @@ void custom_bitvector_domaint::assign_lhs( const vectorst &vectors) { irep_idt id=object2id(lhs); - if(!id.empty()) assign_lhs(id, vectors); + if(!id.empty()) + assign_lhs(id, vectors); } /*******************************************************************\ @@ -183,10 +185,12 @@ custom_bitvector_domaint::vectorst vectorst vectors; bitst::const_iterator may_it=may_bits.find(identifier); - if(may_it!=may_bits.end()) vectors.may_bits=may_it->second; + if(may_it!=may_bits.end()) + vectors.may_bits=may_it->second; bitst::const_iterator must_it=must_bits.find(identifier); - if(must_it!=must_bits.end()) vectors.must_bits=must_it->second; + if(must_it!=must_bits.end()) + vectors.must_bits=must_it->second; return vectors; } @@ -323,7 +327,8 @@ void custom_bitvector_domaint::transform( ai_baset &ai, const namespacet &ns) { - if(has_values.is_false()) return; + if(has_values.is_false()) + return; // upcast of ai custom_bitvector_analysist &cba= @@ -526,7 +531,8 @@ void custom_bitvector_domaint::transform( { exprt guard=instruction.guard; - if(to!=from->get_target()) guard.make_not(); + if(to!=from->get_target()) + guard.make_not(); exprt result=eval(guard, cba); exprt result2=simplify_expr(result, ns); @@ -633,7 +639,8 @@ bool custom_bitvector_domaint::merge( bit_vectort &a_bits=may_bits[bit.first]; bit_vectort old=a_bits; a_bits|=bit.second; - if(old!=a_bits) changed=true; + if(old!=a_bits) + changed=true; } // now do MUST @@ -651,7 +658,8 @@ bool custom_bitvector_domaint::merge( { bit_vectort old=bit.second; bit.second&=bit.second; - if(old!=bit.second) changed=true; + if(old!=bit.second) + changed=true; } } @@ -706,7 +714,8 @@ bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src) return true; forall_operands(it, src) - if(has_get_must_or_may(*it)) return true; + if(has_get_must_or_may(*it)) + return true; return false; } @@ -742,9 +751,8 @@ exprt custom_bitvector_domaint::eval( if(src.id()=="get_may") { for(const auto &bit : may_bits) - { - if(get_bit(bit.second, bit_nr)) return true_exprt(); - } + if(get_bit(bit.second, bit_nr)) + return true_exprt(); return false_exprt(); } @@ -824,8 +832,10 @@ void custom_bitvector_analysist::check( forall_goto_functions(f_it, goto_functions) { - if(!f_it->second.body.has_assertion()) continue; + if(!f_it->second.body.has_assertion()) + continue; + // TODO this is a hard-coded hack if(f_it->first=="__actual_thread_spawn") continue; @@ -842,7 +852,8 @@ void custom_bitvector_analysist::check( if(!custom_bitvector_domaint::has_get_must_or_may(i_it->guard)) continue; - if(operator[](i_it).has_values.is_false()) continue; + if(operator[](i_it).has_values.is_false()) + continue; exprt tmp=eval(i_it->guard, i_it); result=simplify_expr(tmp, ns); diff --git a/src/analyses/dependence_graph.cpp b/src/analyses/dependence_graph.cpp index ddabac0c522..6f544609288 100644 --- a/src/analyses/dependence_graph.cpp +++ b/src/analyses/dependence_graph.cpp @@ -308,7 +308,8 @@ void dep_graph_domaint::output( it!=control_deps.end(); ++it) { - if(it!=control_deps.begin()) out << ","; + if(it!=control_deps.begin()) + out << ","; out << (*it)->location_number; } out << std::endl; @@ -322,7 +323,8 @@ void dep_graph_domaint::output( it!=data_deps.end(); ++it) { - if(it!=data_deps.begin()) out << ","; + if(it!=data_deps.begin()) + out << ","; out << (*it)->location_number; } out << std::endl; diff --git a/src/analyses/dependence_graph.h b/src/analyses/dependence_graph.h index 07bf28baa1b..ab86892a93c 100644 --- a/src/analyses/dependence_graph.h +++ b/src/analyses/dependence_graph.h @@ -41,7 +41,8 @@ class dep_edget break; case DATA: case CTRL: - if(kind!=_kind) kind=BOTH; + if(kind!=_kind) + kind=BOTH; break; case BOTH: break; diff --git a/src/analyses/escape_analysis.cpp b/src/analyses/escape_analysis.cpp index 15c25eefea7..17757bab1f5 100644 --- a/src/analyses/escape_analysis.cpp +++ b/src/analyses/escape_analysis.cpp @@ -260,7 +260,8 @@ void escape_domaint::transform( ai_baset &ai, const namespacet &ns) { - if(has_values.is_false()) return; + if(has_values.is_false()) + return; // upcast of ai //escape_analysist &ea= @@ -386,12 +387,17 @@ void escape_domaint::output( if(aliases.is_root(a_it1) && a_it1!=a_it2 && aliases.same_set(a_it1, a_it2)) { - if(first) { out << "Aliases: " << *a_it1; first=false; } + if(first) + { + out << "Aliases: " << *a_it1; + first=false; + } out << ' ' << *a_it2; } } - if(!first) out << '\n'; + if(!first) + out << '\n'; } } @@ -429,7 +435,8 @@ bool escape_domaint::merge( std::set &a_cleanup=cleanup_map[cleanup.first].cleanup_functions; unsigned old_size=a_cleanup.size(); a_cleanup.insert(b_cleanup.begin(), b_cleanup.end()); - if(a_cleanup.size()!=old_size) changed=true; + if(a_cleanup.size()!=old_size) + changed=true; } // kill empty ones @@ -554,8 +561,10 @@ void escape_analysist::insert_cleanup( { typet param_type=function_type.parameters().front().type(); exprt arg=lhs; - if(is_object) arg=address_of_exprt(arg); - if(arg.type()!=param_type) arg.make_typecast(param_type); + if(is_object) + arg=address_of_exprt(arg); + if(arg.type()!=param_type) + arg.make_typecast(param_type); code.arguments().push_back(arg); } diff --git a/src/analyses/escape_analysis.h b/src/analyses/escape_analysis.h index f1d17bcb3df..6ebfafb7415 100644 --- a/src/analyses/escape_analysis.h +++ b/src/analyses/escape_analysis.h @@ -79,7 +79,7 @@ class escape_domaint:public ai_domain_baset // We track a set of 'cleanup functions' for specific // identifiers. The cleanup functions are executed // once the last pointer to an object is lost. - typedef std::map cleanup_mapt; + typedef std::map cleanup_mapt; cleanup_mapt cleanup_map; protected: diff --git a/src/analyses/flow_insensitive_analysis.h b/src/analyses/flow_insensitive_analysis.h index 8d1292ca61c..fbdfeb10768 100644 --- a/src/analyses/flow_insensitive_analysis.h +++ b/src/analyses/flow_insensitive_analysis.h @@ -28,7 +28,7 @@ class flow_insensitive_abstract_domain_baset typedef goto_programt::const_targett locationt; - virtual void initialize( const namespacet &ns )=0; + virtual void initialize(const namespacet &ns)=0; virtual bool transform( const namespacet &ns, @@ -80,7 +80,7 @@ class flow_insensitive_analysis_baset std::map statistics; - bool seen( const locationt& l ) + bool seen(const locationt& l) { return (seen_locations.find(l)!=seen_locations.end()); } diff --git a/src/analyses/global_may_alias.cpp b/src/analyses/global_may_alias.cpp index a3c5d4629e6..5bdca2e1313 100644 --- a/src/analyses/global_may_alias.cpp +++ b/src/analyses/global_may_alias.cpp @@ -126,7 +126,8 @@ void global_may_alias_domaint::transform( ai_baset &ai, const namespacet &ns) { - if(has_values.is_false()) return; + if(has_values.is_false()) + return; const goto_programt::instructiont &instruction=*from; @@ -196,12 +197,17 @@ void global_may_alias_domaint::output( if(aliases.is_root(a_it1) && a_it1!=a_it2 && aliases.same_set(a_it1, a_it2)) { - if(first) { out << "Aliases: " << *a_it1; first=false; } + if(first) + { + out << "Aliases: " << *a_it1; + first=false; + } out << ' ' << *a_it2; } } - if(!first) out << '\n'; + if(!first) + out << '\n'; } } diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index 038e7152230..c008d4f6e77 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -353,7 +353,8 @@ void goto_checkt::conversion_check( if(old_type.id()==ID_signedbv) // signed -> signed { std::size_t old_width=to_signedbv_type(old_type).get_width(); - if(new_width>=old_width) return; // always ok + if(new_width>=old_width) + return; // always ok binary_relation_exprt no_overflow_upper(ID_le); no_overflow_upper.lhs()=expr.op0(); @@ -374,7 +375,8 @@ void goto_checkt::conversion_check( else if(old_type.id()==ID_unsignedbv) // unsigned -> signed { std::size_t old_width=to_unsignedbv_type(old_type).get_width(); - if(new_width>=old_width+1) return; // always ok + if(new_width>=old_width+1) + return; // always ok binary_relation_exprt no_overflow_upper(ID_le); no_overflow_upper.lhs()=expr.op0(); @@ -458,7 +460,8 @@ void goto_checkt::conversion_check( else if(old_type.id()==ID_unsignedbv) // unsigned -> unsigned { std::size_t old_width=to_unsignedbv_type(old_type).get_width(); - if(new_width>=old_width) return; // always ok + if(new_width>=old_width) + return; // always ok binary_relation_exprt no_overflow_upper(ID_le); no_overflow_upper.lhs()=expr.op0(); @@ -1793,7 +1796,8 @@ void goto_checkt::goto_check(goto_functiont &goto_function) i_it->source_location.set_column(it->source_location.get_column()); } - if(i_it->function==irep_idt()) i_it->function=it->function; + if(i_it->function==irep_idt()) + i_it->function=it->function; } // insert new instructions -- make sure targets are not moved diff --git a/src/analyses/goto_rw.cpp b/src/analyses/goto_rw.cpp index 2d84edc27ea..2aba56eeea6 100644 --- a/src/analyses/goto_rw.cpp +++ b/src/analyses/goto_rw.cpp @@ -61,7 +61,8 @@ void range_domaint::output( itr!=end(); ++itr) { - if(itr!=begin()) out << ";"; + if(itr!=begin()) + out << ";"; out << itr->first << ":" << itr->second; } out << "]"; @@ -870,7 +871,8 @@ void guarded_range_domaint::output( itr!=end(); ++itr) { - if(itr!=begin()) out << ";"; + if(itr!=begin()) + out << ";"; out << itr->first << ":" << itr->second.first; out << " if " << from_expr(ns, "", itr->second.second); } diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index 0d5ca3d80aa..ed97d93ac57 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -43,7 +43,8 @@ void interval_domaint::output( for(const auto &interval : int_map) { - if(interval.second.is_top()) continue; + if(interval.second.is_top()) + continue; if(interval.second.lower_set) out << interval.second.lower << " <= "; out << interval.first; @@ -54,7 +55,8 @@ void interval_domaint::output( for(const auto &interval : float_map) { - if(interval.second.is_top()) continue; + if(interval.second.is_top()) + continue; if(interval.second.lower_set) out << interval.second.lower << " <= "; out << interval.first; @@ -142,8 +144,13 @@ bool interval_domaint::merge( locationt from, locationt to) { - if(b.bottom) return false; - if(bottom) { *this=b; return true; } + if(b.bottom) + return false; + if(bottom) + { + *this=b; + return true; + } bool result=false; @@ -160,7 +167,8 @@ bool interval_domaint::merge( { integer_intervalt previous=it->second; it->second.join(b_it->second); - if(it->second!=previous) result=true; + if(it->second!=previous) + result=true; it++; } @@ -179,7 +187,8 @@ bool interval_domaint::merge( { ieee_float_intervalt previous=it->second; it->second.join(b_it->second); - if(it->second!=previous) result=true; + if(it->second!=previous) + result=true; it++; } @@ -296,18 +305,22 @@ void interval_domaint::assume_rec( { mp_integer tmp; to_integer(rhs, tmp); - if(id==ID_lt) --tmp; + if(id==ID_lt) + --tmp; integer_intervalt &ii=int_map[lhs_identifier]; ii.make_le_than(tmp); - if(ii.is_bottom()) make_bottom(); + if(ii.is_bottom()) + make_bottom(); } else if(is_float(lhs.type()) && is_float(rhs.type())) { ieee_floatt tmp(to_constant_expr(rhs)); - if(id==ID_lt) tmp.decrement(); + if(id==ID_lt) + tmp.decrement(); ieee_float_intervalt &fi=float_map[lhs_identifier]; fi.make_le_than(tmp); - if(fi.is_bottom()) make_bottom(); + if(fi.is_bottom()) + make_bottom(); } } else if(lhs.id()==ID_constant && rhs.id()==ID_symbol) @@ -318,18 +331,22 @@ void interval_domaint::assume_rec( { mp_integer tmp; to_integer(lhs, tmp); - if(id==ID_lt) ++tmp; + if(id==ID_lt) + ++tmp; integer_intervalt &ii=int_map[rhs_identifier]; ii.make_ge_than(tmp); - if(ii.is_bottom()) make_bottom(); + if(ii.is_bottom()) + make_bottom(); } else if(is_float(lhs.type()) && is_float(rhs.type())) { ieee_floatt tmp(to_constant_expr(lhs)); - if(id==ID_lt) tmp.increment(); + if(id==ID_lt) + tmp.increment(); ieee_float_intervalt &fi=float_map[rhs_identifier]; fi.make_ge_than(tmp); - if(fi.is_bottom()) make_bottom(); + if(fi.is_bottom()) + make_bottom(); } } else if(lhs.id()==ID_symbol && rhs.id()==ID_symbol) @@ -343,7 +360,8 @@ void interval_domaint::assume_rec( integer_intervalt &rhs_i=int_map[rhs_identifier]; lhs_i.meet(rhs_i); rhs_i=lhs_i; - if(rhs_i.is_bottom()) make_bottom(); + if(rhs_i.is_bottom()) + make_bottom(); } else if(is_float(lhs.type()) && is_float(rhs.type())) { @@ -351,7 +369,8 @@ void interval_domaint::assume_rec( ieee_float_intervalt &rhs_i=float_map[rhs_identifier]; lhs_i.meet(rhs_i); rhs_i=lhs_i; - if(rhs_i.is_bottom()) make_bottom(); + if(rhs_i.is_bottom()) + make_bottom(); } } } @@ -450,10 +469,14 @@ exprt interval_domaint::make_expression(const symbol_exprt &src) const if(is_int(src.type())) { int_mapt::const_iterator i_it=int_map.find(src.get_identifier()); - if(i_it==int_map.end()) return true_exprt(); + if(i_it==int_map.end()) + return true_exprt(); + const integer_intervalt &interval=i_it->second; - if(interval.is_top()) return true_exprt(); - if(interval.is_bottom()) return false_exprt(); + if(interval.is_top()) + return true_exprt(); + if(interval.is_bottom()) + return false_exprt(); exprt::operandst conjuncts; @@ -474,10 +497,14 @@ exprt interval_domaint::make_expression(const symbol_exprt &src) const else if(is_float(src.type())) { float_mapt::const_iterator i_it=float_map.find(src.get_identifier()); - if(i_it==float_map.end()) return true_exprt(); + if(i_it==float_map.end()) + return true_exprt(); + const ieee_float_intervalt &interval=i_it->second; - if(interval.is_top()) return true_exprt(); - if(interval.is_bottom()) return false_exprt(); + if(interval.is_top()) + return true_exprt(); + if(interval.is_bottom()) + return false_exprt(); exprt::operandst conjuncts; diff --git a/src/analyses/interval_domain.h b/src/analyses/interval_domain.h index f9ffd291b12..dc50002d5af 100644 --- a/src/analyses/interval_domain.h +++ b/src/analyses/interval_domain.h @@ -24,7 +24,7 @@ class interval_domaint:public ai_domain_baset // Trivial, conjunctive interval domain for both float // and integers. The categorization 'float' and 'integers' // is done by is_int and is_float. - + interval_domaint():bottom(true) { } diff --git a/src/analyses/interval_template.h b/src/analyses/interval_template.h index 97ccf7a10d7..1ea84414089 100644 --- a/src/analyses/interval_template.h +++ b/src/analyses/interval_template.h @@ -76,7 +76,8 @@ template class interval_template { if(upper_set) { - if(upper>v) upper=v; + if(upper>v) + upper=v; } else { @@ -89,7 +90,8 @@ template class interval_template { if(lower_set) { - if(lower class interval_template }; template -tvt operator <= (const interval_template &a, const interval_template &b) +tvt operator<=(const interval_template &a, const interval_template &b) { - if(a.upper_set && b.lower_set && a.upper<=b.lower) return tvt(true); - if(a.lower_set && b.upper_set && a.lower>b.upper) return tvt(false); + if(a.upper_set && b.lower_set && a.upper<=b.lower) + return tvt(true); + if(a.lower_set && b.upper_set && a.lower>b.upper) + return tvt(false); + return tvt::unknown(); } template -tvt operator >= (const interval_template &a, const interval_template &b) +tvt operator>=(const interval_template &a, const interval_template &b) { return b<=a; } template -tvt operator < (const interval_template &a, const interval_template &b) +tvt operator<(const interval_template &a, const interval_template &b) { return !(a>=b); } template -tvt operator > (const interval_template &a, const interval_template &b) +tvt operator>(const interval_template &a, const interval_template &b) { return !(a<=b); } template -bool operator == (const interval_template &a, const interval_template &b) +bool operator==(const interval_template &a, const interval_template &b) { - if(a.lower_set!=b.lower_set) return false; - if(a.upper_set!=b.upper_set) return false; - if(a.lower_set && a.lower!=b.lower) return false; - if(a.upper_set && a.upper!=b.upper) return false; + if(a.lower_set!=b.lower_set) + return false; + if(a.upper_set!=b.upper_set) + return false; + + if(a.lower_set && a.lower!=b.lower) + return false; + if(a.upper_set && a.upper!=b.upper) + return false; + return true; } template -bool operator != (const interval_template &a, const interval_template &b) +bool operator!=(const interval_template &a, const interval_template &b) { return !(a==b); } diff --git a/src/analyses/invariant_propagation.cpp b/src/analyses/invariant_propagation.cpp index 8e73d7e151b..2605c6eab9c 100644 --- a/src/analyses/invariant_propagation.cpp +++ b/src/analyses/invariant_propagation.cpp @@ -382,12 +382,13 @@ void invariant_propagationt::simplify(goto_programt &goto_program) { Forall_goto_program_instructions(i_it, goto_program) { - if(!i_it->is_assert()) continue; + if(!i_it->is_assert()) + continue; // find invariant set state_mapt::const_iterator s_it=state_map.find(i_it); - - if(s_it==state_map.end()) continue; + if(s_it==state_map.end()) + continue; const invariant_sett &invariant_set=s_it->second.invariant_set; diff --git a/src/analyses/invariant_propagation.h b/src/analyses/invariant_propagation.h index 2cb25851500..0884ba85d07 100644 --- a/src/analyses/invariant_propagation.h +++ b/src/analyses/invariant_propagation.h @@ -35,7 +35,7 @@ class invariant_propagationt:public virtual void initialize(const goto_programt &goto_program); virtual void initialize(const goto_functionst &goto_functions); - + void make_all_true(); void make_all_false(); @@ -43,7 +43,7 @@ class invariant_propagationt:public void simplify(goto_functionst &goto_functions); typedef ait baset; - + protected: const namespacet &ns; value_setst &value_sets; diff --git a/src/analyses/invariant_set.cpp b/src/analyses/invariant_set.cpp index 725a0fbc648..c5c52469654 100644 --- a/src/analyses/invariant_set.cpp +++ b/src/analyses/invariant_set.cpp @@ -54,7 +54,8 @@ Function: inv_object_storet::get bool inv_object_storet::get(const exprt &expr, unsigned &n) { std::string s=build_string(expr); - if(s=="") return true; + if(s.empty()) + return true; // if it's a constant, we add it in any case if(is_constant(expr)) @@ -540,7 +541,8 @@ Function: invariant_sett::strengthen void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) { - if(expr.type()==type) return; + if(expr.type()==type) + return; if(type.id()==ID_unsignedbv) { @@ -549,7 +551,8 @@ void invariant_sett::add_type_bounds(const exprt &expr, const typet &type) if(op_width<=8) { unsigned a; - if(get_object(expr, a)) return; + if(get_object(expr, a)) + return; add_bounds(a, boundst(0, power(2, op_width)-1)); } @@ -863,14 +866,16 @@ tvt invariant_sett::implies_rec(const exprt &expr) const bool ob0=get_object(expr.op0(), p.first); bool ob1=get_object(expr.op1(), p.second); - if(ob0 || ob1) return tvt::unknown(); + if(ob0 || ob1) + return tvt::unknown(); tvt r; if(expr.id()==ID_le) { r=is_le(p); - if(!r.is_unknown()) return r; + if(!r.is_unknown()) + return r; boundst b0, b1; get_bounds(p.first, b0); @@ -881,7 +886,8 @@ tvt invariant_sett::implies_rec(const exprt &expr) const else if(expr.id()==ID_lt) { r=is_lt(p); - if(!r.is_unknown()) return r; + if(!r.is_unknown()) + return r; boundst b0, b1; get_bounds(p.first, b0); @@ -932,7 +938,8 @@ void invariant_sett::get_bounds(unsigned a, boundst &bounds) const bounds_mapt::const_iterator it=bounds_map.find(a); - if(it!=bounds_map.end()) bounds=it->second; + if(it!=bounds_map.end()) + bounds=it->second; } /*******************************************************************\ @@ -954,11 +961,13 @@ void invariant_sett::nnf(exprt &expr, bool negate) if(expr.is_true()) { - if(negate) expr=false_exprt(); + if(negate) + expr=false_exprt(); } else if(expr.is_false()) { - if(negate) expr=true_exprt(); + if(negate) + expr=true_exprt(); } else if(expr.id()==ID_not) { @@ -977,7 +986,8 @@ void invariant_sett::nnf(exprt &expr, bool negate) } else if(expr.id()==ID_or) { - if(negate) expr.id(ID_and); + if(negate) + expr.id(ID_and); Forall_operands(it, expr) nnf(*it, negate); @@ -997,7 +1007,8 @@ void invariant_sett::nnf(exprt &expr, bool negate) } else { - if(negate) expr.make_not(); + if(negate) + expr.make_not(); } } else if(expr.id()==ID_le) @@ -1040,11 +1051,13 @@ void invariant_sett::nnf(exprt &expr, bool negate) } else if(expr.id()==ID_equal) { - if(negate) expr.id(ID_notequal); + if(negate) + expr.id(ID_notequal); } else if(expr.id()==ID_notequal) { - if(negate) expr.id(ID_equal); + if(negate) + expr.id(ID_equal); } else { @@ -1245,9 +1258,10 @@ bool invariant_sett::make_union(const invariant_sett &other) if(make_union_bounds_map(other.bounds_map)) return true; - if(old_eq_roots!=eq_set.count_roots()) return true; - if(old_ne_set!=ne_set.size()) return true; - if(old_le_set!=le_set.size()) return true; + if(old_eq_roots!=eq_set.count_roots() || + old_ne_set!=ne_set.size() || + old_le_set!=le_set.size()) + return true; return false; // no change } @@ -1287,7 +1301,8 @@ bool invariant_sett::make_union_bounds_map(const bounds_mapt &other) { boundst old(it->second); it->second.approx_union_with(o_it->second); - if(it->second!=old) changed=true; + if(it->second!=old) + changed=true; it++; } } @@ -1333,7 +1348,8 @@ void invariant_sett::modifies(const exprt &lhs) lhs.id()==ID_member) { unsigned a; - if(!get_object(lhs, a)) modifies(a); + if(!get_object(lhs, a)) + modifies(a); } else if(lhs.id()==ID_index) { diff --git a/src/analyses/invariant_set_domain.cpp b/src/analyses/invariant_set_domain.cpp index 6ee0be8e6e0..03f1663acc5 100644 --- a/src/analyses/invariant_set_domain.cpp +++ b/src/analyses/invariant_set_domain.cpp @@ -36,7 +36,8 @@ void invariant_set_domaint::transform( goto_programt::const_targett next=from_l; next++; - if(next==to_l) tmp.make_not(); + if(next==to_l) + tmp.make_not(); simplify(tmp, ns); invariant_set.strengthen(tmp); diff --git a/src/analyses/is_threaded.cpp b/src/analyses/is_threaded.cpp index a808609497e..507e67046d1 100644 --- a/src/analyses/is_threaded.cpp +++ b/src/analyses/is_threaded.cpp @@ -58,7 +58,8 @@ class is_threaded_domaint:public ai_domain_baset ai_baset &ai, const namespacet &ns) override final { - if(!reachable) return; + if(!reachable) + return; if(from->is_start_thread() || to->is_end_thread()) { diff --git a/src/analyses/local_bitvector_analysis.cpp b/src/analyses/local_bitvector_analysis.cpp index d6d15a19abd..61cfc179058 100644 --- a/src/analyses/local_bitvector_analysis.cpp +++ b/src/analyses/local_bitvector_analysis.cpp @@ -32,14 +32,22 @@ Function: local_bitvector_analysist::flagst::print void local_bitvector_analysist::flagst::print(std::ostream &out) const { - if(is_unknown()) out << "+unknown"; - if(is_uninitialized()) out << "+uninitialized"; - if(is_uses_offset()) out << "+uses_offset"; - if(is_dynamic_local()) out << "+dynamic_local"; - if(is_dynamic_heap()) out << "+dynamic_heap"; - if(is_null()) out << "+null"; - if(is_static_lifetime()) out << "+static_lifetime"; - if(is_integer_address()) out << "+integer_address"; + if(is_unknown()) + out << "+unknown"; + if(is_uninitialized()) + out << "+uninitialized"; + if(is_uses_offset()) + out << "+uses_offset"; + if(is_dynamic_local()) + out << "+dynamic_local"; + if(is_dynamic_heap()) + out << "+dynamic_heap"; + if(is_null()) + out << "+null"; + if(is_static_lifetime()) + out << "+static_lifetime"; + if(is_integer_address()) + out << "+integer_address"; } /*******************************************************************\ @@ -86,9 +94,11 @@ Function: local_bitvector_analysist::is_tracked bool local_bitvector_analysist::is_tracked(const irep_idt &identifier) { localst::locals_mapt::const_iterator it=locals.locals_map.find(identifier); - if(it==locals.locals_map.end()) return false; - if(it->second.id()!=ID_pointer) return false; - if(dirty(identifier)) return false; + if(it==locals.locals_map.end() || + it->second.id()!=ID_pointer || + dirty(identifier)) + return false; + return true; } @@ -313,7 +323,8 @@ Function: local_bitvector_analysist::build void local_bitvector_analysist::build(const goto_functiont &goto_function) { - if(cfg.nodes.empty()) return; + if(cfg.nodes.empty()) + return; work_queuet work_queue; work_queue.push(0); diff --git a/src/analyses/local_may_alias.cpp b/src/analyses/local_may_alias.cpp index 25e3c4d5211..0bf605ae8a1 100644 --- a/src/analyses/local_may_alias.cpp +++ b/src/analyses/local_may_alias.cpp @@ -382,7 +382,8 @@ Function: local_may_aliast::build void local_may_aliast::build(const goto_functiont &goto_function) { - if(cfg.nodes.empty()) return; + if(cfg.nodes.empty()) + return; work_queuet work_queue; diff --git a/src/analyses/local_may_alias.h b/src/analyses/local_may_alias.h index 33ddf22bee9..cd43021de79 100644 --- a/src/analyses/local_may_alias.h +++ b/src/analyses/local_may_alias.h @@ -116,7 +116,9 @@ class local_may_alias_factoryt { assert(goto_functions!=NULL); fkt_mapt::iterator f_it=fkt_map.find(fkt); - if(f_it!=fkt_map.end()) return *f_it->second; + if(f_it!=fkt_map.end()) + return *f_it->second; + goto_functionst::function_mapt::const_iterator f_it2= goto_functions->function_map.find(fkt); assert(f_it2!=goto_functions->function_map.end()); diff --git a/src/analyses/natural_loops.h b/src/analyses/natural_loops.h index ffeaf2aa36d..502fbe26ecd 100644 --- a/src/analyses/natural_loops.h +++ b/src/analyses/natural_loops.h @@ -59,7 +59,8 @@ class natural_loops_templatet }; class natural_loopst: - public natural_loops_templatet + public natural_loops_templatet { }; @@ -80,7 +81,7 @@ Function: natural_loops_templatet::compute \*******************************************************************/ -//#define DEBUG +// #define DEBUG #ifdef DEBUG #include @@ -96,9 +97,9 @@ void natural_loops_templatet::compute(P &program) #endif // find back-edges m->n - for (T m_it = program.instructions.begin(); - m_it != program.instructions.end(); - ++m_it) + for(T m_it=program.instructions.begin(); + m_it!=program.instructions.end(); + ++m_it) { if(m_it->is_backwards_goto()) { @@ -149,7 +150,7 @@ void natural_loops_templatet::compute_natural_loop(T m, T n) loop.insert(n); loop.insert(m); - if (n!=m) + if(n!=m) stack.push(m); while(!stack.empty()) @@ -194,7 +195,8 @@ void natural_loops_templatet::output(std::ostream &out) const for(typename natural_loopt::const_iterator l_it=loop.second.begin(); l_it!=loop.second.end(); ++l_it) { - if(l_it!=loop.second.begin()) out << ", "; + if(l_it!=loop.second.begin()) + out << ", "; out << (*l_it)->location_number; } out << " }\n"; diff --git a/src/analyses/reaching_definitions.cpp b/src/analyses/reaching_definitions.cpp index 10c303bcb7d..86363beb5c5 100644 --- a/src/analyses/reaching_definitions.cpp +++ b/src/analyses/reaching_definitions.cpp @@ -896,9 +896,12 @@ Function: reaching_definitions_analysist::~reaching_definitions_analysist reaching_definitions_analysist::~reaching_definitions_analysist() { - if(is_dirty) delete is_dirty; - if(is_threaded) delete is_threaded; - if(value_sets) delete value_sets; + if(is_dirty) + delete is_dirty; + if(is_threaded) + delete is_threaded; + if(value_sets) + delete value_sets; } /*******************************************************************\ diff --git a/src/analyses/reaching_definitions.h b/src/analyses/reaching_definitions.h index c804a5dec0b..2835caa5eae 100644 --- a/src/analyses/reaching_definitions.h +++ b/src/analyses/reaching_definitions.h @@ -70,14 +70,20 @@ inline bool operator<( const reaching_definitiont &a, const reaching_definitiont &b) { - if(a.definition_atclear(); + if(bv_container) + bv_container->clear(); has_values=tvt(true); } void make_bottom() override final { values.clear(); - if(bv_container) bv_container->clear(); + if(bv_container) + bv_container->clear(); has_values=tvt(false); } diff --git a/src/analyses/static_analysis.h b/src/analyses/static_analysis.h index 3e49425bbeb..f83ec7776b7 100644 --- a/src/analyses/static_analysis.h +++ b/src/analyses/static_analysis.h @@ -275,14 +275,18 @@ class static_analysist:public static_analysis_baset inline T &operator[](locationt l) { typename state_mapt::iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } inline const T &operator[](locationt l) const { typename state_mapt::const_iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } @@ -304,14 +308,18 @@ class static_analysist:public static_analysis_baset virtual statet &get_state(locationt l) { typename state_mapt::iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } virtual const statet &get_state(locationt l) const { typename state_mapt::const_iterator it=state_map.find(l); - if(it==state_map.end()) throw "failed to find state"; + if(it==state_map.end()) + throw "failed to find state"; + return it->second; } diff --git a/src/analyses/uninitialized_domain.cpp b/src/analyses/uninitialized_domain.cpp index c671722843f..8a6e8dd52a5 100644 --- a/src/analyses/uninitialized_domain.cpp +++ b/src/analyses/uninitialized_domain.cpp @@ -31,7 +31,8 @@ void uninitialized_domaint::transform( ai_baset &ai, const namespacet &ns) { - if(has_values.is_false()) return; + if(has_values.is_false()) + return; switch(from->type) { diff --git a/src/ansi-c/anonymous_member.cpp b/src/ansi-c/anonymous_member.cpp index 22f6d18b6e9..adaff8d4680 100644 --- a/src/ansi-c/anonymous_member.cpp +++ b/src/ansi-c/anonymous_member.cpp @@ -82,7 +82,8 @@ exprt get_component_rec( { exprt tmp=make_member_expr(struct_union, comp, ns); exprt result=get_component_rec(tmp, component_name, ns); - if(result.is_not_nil()) return result; + if(result.is_not_nil()) + return result; } } diff --git a/src/ansi-c/c_preprocess.cpp b/src/ansi-c/c_preprocess.cpp index 50b412ea5b5..972d70857ec 100644 --- a/src/ansi-c/c_preprocess.cpp +++ b/src/ansi-c/c_preprocess.cpp @@ -378,7 +378,7 @@ bool c_preprocess( temporary_filet tmp_file("tmp.stdin", ".c"); std::ofstream tmp(tmp_file()); - + if(!tmp) { messaget message(message_handler); diff --git a/src/ansi-c/c_qualifiers.h b/src/ansi-c/c_qualifiers.h index a499255cc55..45e5d01d782 100644 --- a/src/ansi-c/c_qualifiers.h +++ b/src/ansi-c/c_qualifiers.h @@ -85,8 +85,7 @@ class c_qualifierst return !(*this==other); } - c_qualifierst &operator += ( - const c_qualifierst &b) + c_qualifierst &operator+=(const c_qualifierst &b) { is_constant|=b.is_constant; is_volatile|=b.is_volatile; diff --git a/src/ansi-c/c_typecast.cpp b/src/ansi-c/c_typecast.cpp index d8ac037de77..be5a7ea71f1 100644 --- a/src/ansi-c/c_typecast.cpp +++ b/src/ansi-c/c_typecast.cpp @@ -667,8 +667,12 @@ void c_typecastt::implicit_typecast_followed( { // ok } - else if((is_number(src_sub) || src_sub.id()==ID_c_enum || src_sub.id()==ID_c_enum_tag) && - (is_number(dest_sub) || dest_sub.id()==ID_c_enum || src_sub.id()==ID_c_enum_tag)) + else if((is_number(src_sub) || + src_sub.id()==ID_c_enum || + src_sub.id()==ID_c_enum_tag) && + (is_number(dest_sub) || + dest_sub.id()==ID_c_enum || + src_sub.id()==ID_c_enum_tag)) { // Also generous: between any to scalar types it's ok. // We should probably check the size. diff --git a/src/ansi-c/c_typecheck_base.cpp b/src/ansi-c/c_typecheck_base.cpp index f519c0915f3..8597eef3852 100644 --- a/src/ansi-c/c_typecheck_base.cpp +++ b/src/ansi-c/c_typecheck_base.cpp @@ -145,7 +145,8 @@ void c_typecheck_baset::typecheck_symbol(symbolt &symbol) } // see if we have it already - symbol_tablet::symbolst::iterator old_it=symbol_table.symbols.find(symbol.name); + symbol_tablet::symbolst::iterator old_it= + symbol_table.symbols.find(symbol.name); if(old_it==symbol_table.symbols.end()) { @@ -500,7 +501,8 @@ void c_typecheck_baset::typecheck_redefinition_non_type( const irep_idt identifier= to_symbol_type(old_symbol.type).get_identifier(); - symbol_tablet::symbolst::iterator s_it=symbol_table.symbols.find(identifier); + symbol_tablet::symbolst::iterator s_it= + symbol_table.symbols.find(identifier); if(s_it==symbol_table.symbols.end()) { diff --git a/src/ansi-c/expr2c_class.h b/src/ansi-c/expr2c_class.h index 2592635fd50..f4a1bf6b3dc 100644 --- a/src/ansi-c/expr2c_class.h +++ b/src/ansi-c/expr2c_class.h @@ -75,10 +75,12 @@ class expr2ct std::string convert_typecast( const typecast_exprt &src, unsigned &precedence); - std::string convert_pointer_arithmetic(const exprt &src, + std::string convert_pointer_arithmetic( + const exprt &src, unsigned &precedence); - std::string convert_pointer_difference(const exprt &src, + std::string convert_pointer_difference( + const exprt &src, unsigned &precedence); std::string convert_binary( diff --git a/src/ansi-c/literals/convert_float_literal.cpp b/src/ansi-c/literals/convert_float_literal.cpp index d411eaad964..7e72f6e6f53 100644 --- a/src/ansi-c/literals/convert_float_literal.cpp +++ b/src/ansi-c/literals/convert_float_literal.cpp @@ -39,9 +39,17 @@ exprt convert_float_literal(const std::string &src) bool is_decimal, is_float80, is_float128; // GCC extensions unsigned base; - parse_float(src, significand, exponent, base, - is_float, is_long, is_imaginary, - is_decimal, is_float80, is_float128); + parse_float( + src, + significand, + exponent, + base, + is_float, + is_long, + is_imaginary, + is_decimal, + is_float80, + is_float128); exprt result=exprt(ID_constant); @@ -130,7 +138,8 @@ exprt convert_float_literal(const std::string &src) else assert(false); - result.set(ID_value, + result.set( + ID_value, integer2binary(a.pack(), a.spec.width())); } diff --git a/src/cbmc/bmc.h b/src/cbmc/bmc.h index 10ae1b6dcbd..3fe53f1d6ed 100644 --- a/src/cbmc/bmc.h +++ b/src/cbmc/bmc.h @@ -103,7 +103,7 @@ class bmct:public safety_checkert void output_graphml( resultt result, const goto_functionst &goto_functions); - + bool cover( const goto_functionst &goto_functions, const optionst::value_listt &criteria); diff --git a/src/cbmc/cbmc_solvers.h b/src/cbmc/cbmc_solvers.h index 9cb52e49117..5a2d085cf8e 100644 --- a/src/cbmc/cbmc_solvers.h +++ b/src/cbmc/cbmc_solvers.h @@ -47,7 +47,7 @@ class cbmc_solverst:public messaget { } - //The solver class (that takes care of allocated objects) + // The solver class (that takes care of allocated objects) class solvert { public: @@ -63,7 +63,7 @@ class cbmc_solverst:public messaget delete prop_conv_ptr; } - //use this to get the prop_conv + // use this to get the prop_conv prop_convt& prop_conv() const { assert(prop_conv_ptr!=NULL); @@ -74,7 +74,7 @@ class cbmc_solverst:public messaget prop_convt* prop_conv_ptr; }; - //returns a solvert object + // returns a solvert object virtual std::unique_ptr get_solver() { solvert *solver; @@ -116,10 +116,9 @@ class cbmc_solverst:public messaget smt1_dect::solvert get_smt1_solver_type() const; smt2_dect::solvert get_smt2_solver_type() const; - //consistency checks during solver creation + // consistency checks during solver creation void no_beautification(); void no_incremental_check(); - }; #endif // CPROVER_CBMC_CBMC_SOLVERS_H diff --git a/src/cpp/cpp_declaration.h b/src/cpp/cpp_declaration.h index 323535df5dc..ba61d97ccd3 100644 --- a/src/cpp/cpp_declaration.h +++ b/src/cpp/cpp_declaration.h @@ -104,12 +104,14 @@ class cpp_declarationt:public exprt inline cpp_template_args_non_tct &partial_specialization_args() { - return static_cast(add("partial_specialization_args")); + return static_cast( + add("partial_specialization_args")); } inline const cpp_template_args_non_tct &partial_specialization_args() const { - return static_cast(find("partial_specialization_args")); + return static_cast( + find("partial_specialization_args")); } inline void set_specialization_of(const irep_idt &id) diff --git a/src/cpp/cpp_template_args.h b/src/cpp/cpp_template_args.h index 837e3769d11..5fa708879a8 100644 --- a/src/cpp/cpp_template_args.h +++ b/src/cpp/cpp_template_args.h @@ -41,13 +41,15 @@ class cpp_template_args_non_tct:public cpp_template_args_baset { }; -inline cpp_template_args_non_tct &to_cpp_template_args_non_tc(irept &irep) +inline cpp_template_args_non_tct &to_cpp_template_args_non_tc( + irept &irep) { assert(irep.id()==ID_template_args); return static_cast(irep); } -inline const cpp_template_args_non_tct &to_cpp_template_args_non_tc(const irept &irep) +inline const cpp_template_args_non_tct &to_cpp_template_args_non_tc( + const irept &irep) { assert(irep.id()==ID_template_args); return static_cast(irep); diff --git a/src/cpp/cpp_typecast.h b/src/cpp/cpp_typecast.h index 0552e7b1ee6..7689edf5d73 100644 --- a/src/cpp/cpp_typecast.h +++ b/src/cpp/cpp_typecast.h @@ -50,17 +50,17 @@ class cpp_typecastt:public c_typecastt std::string& err); bool integral_conversion( - const typet &src_type, - const typet &dest_type); + const typet &src_type, + const typet &dest_type); exprt subtype_offset( - const struct_typet &from, - const struct_typet &to); + const struct_typet &from, + const struct_typet &to); void make_ptr_typecast( - exprt &expr, - const typet & src_type, - const typet & dest_type); + exprt &expr, + const typet & src_type, + const typet & dest_type); cpp_typecheckt &cpp_typecheck; }; diff --git a/src/cpp/cpp_typecheck_resolve.h b/src/cpp/cpp_typecheck_resolve.h index fb587c93b80..b37af175762 100644 --- a/src/cpp/cpp_typecheck_resolve.h +++ b/src/cpp/cpp_typecheck_resolve.h @@ -137,13 +137,14 @@ class cpp_typecheck_resolvet cpp_template_args_tct specialization_args; cpp_template_args_tct full_args; irep_idt id; - matcht(cpp_template_args_tct _s_args, - cpp_template_args_tct _f_args, - irep_idt _id): + matcht( + cpp_template_args_tct _s_args, + cpp_template_args_tct _f_args, + irep_idt _id): cost((unsigned)_s_args.arguments().size()), - specialization_args(_s_args), - full_args(_f_args), - id(_id) + specialization_args(_s_args), + full_args(_f_args), + id(_id) { } diff --git a/src/cpp/expr2cpp.cpp b/src/cpp/expr2cpp.cpp index 0678a6e9773..2ac195577ba 100644 --- a/src/cpp/expr2cpp.cpp +++ b/src/cpp/expr2cpp.cpp @@ -343,16 +343,16 @@ std::string expr2cppt::convert_rec( typet member; member.swap(tmp.add("to-member")); - std::string dest = "(" + convert_rec(member, c_qualifierst(), "") + ":: *)"; + std::string dest="("+convert_rec(member, c_qualifierst(), "")+":: *)"; if(src.subtype().id()==ID_code) { const code_typet& code_type = to_code_type(src.subtype()); const typet& return_type = code_type.return_type(); - dest = convert_rec(return_type, c_qualifierst(), "") +" " + dest; + dest=convert_rec(return_type, c_qualifierst(), "")+" "+dest; const code_typet::parameterst &args = code_type.parameters(); - dest += "("; + dest+="("; for(code_typet::parameterst::const_iterator it=args.begin(); it!=args.end(); @@ -362,7 +362,7 @@ std::string expr2cppt::convert_rec( dest+=convert_rec(it->type(), c_qualifierst(), ""); } - dest += ")"; + dest+=")"; dest+=d; } else @@ -542,10 +542,10 @@ std::string expr2cppt::convert( else if(src.id()==ID_side_effect && src.get(ID_statement)==ID_throw) return convert_function(src, "throw", precedence=16); - else if(src.is_constant() && src.type().id() == ID_verilog_signedbv) - return "'" + id2string(src.get(ID_value)) + "'"; - else if(src.is_constant() && src.type().id() == ID_verilog_unsignedbv) - return "'" + id2string(src.get(ID_value)) + "'"; + else if(src.is_constant() && src.type().id()==ID_verilog_signedbv) + return "'"+id2string(src.get(ID_value))+"'"; + else if(src.is_constant() && src.type().id()==ID_verilog_unsignedbv) + return "'"+id2string(src.get(ID_value))+"'"; else if(src.is_constant() && to_constant_expr(src).get_value()==ID_nullptr) return "nullptr"; else if(src.id()==ID_unassigned) @@ -580,7 +580,7 @@ std::string expr2cppt::convert_code( if(statement==ID_cpp_new || statement==ID_cpp_new_array) - return convert_cpp_new(src,indent); + return convert_cpp_new(src, indent); return expr2ct::convert_code(src, indent); } @@ -601,8 +601,8 @@ std::string expr2cppt::convert_extractbit( const exprt &src, unsigned precedence) { - assert(src.operands().size() == 2); - return convert(src.op0()) + "[" + convert(src.op1()) + "]"; + assert(src.operands().size()==2); + return convert(src.op0())+"["+convert(src.op1())+"]"; } /*******************************************************************\ @@ -621,9 +621,10 @@ std::string expr2cppt::convert_extractbits( const exprt &src, unsigned precedence) { - assert(src.operands().size() == 3); - return convert(src.op0()) + ".range(" + convert(src.op1()) + "," - + convert(src.op2()) + ")"; + assert(src.operands().size()==3); + return + convert(src.op0())+".range("+convert(src.op1())+ ","+ + convert(src.op2())+")"; } /*******************************************************************\ diff --git a/src/goto-cc/compile.h b/src/goto-cc/compile.h index 5b7188ec417..936f4cd21d5 100644 --- a/src/goto-cc/compile.h +++ b/src/goto-cc/compile.h @@ -61,10 +61,14 @@ class compilet:public language_uit bool parse_source(const std::string &); - bool write_object_file( const std::string &, const symbol_tablet &, - goto_functionst &); - bool write_bin_object_file( const std::string&, const symbol_tablet &, - goto_functionst& ); + bool write_object_file( + const std::string &, + const symbol_tablet &, + goto_functionst &); + bool write_bin_object_file( + const std::string &, + const symbol_tablet &, + goto_functionst &); protected: cmdlinet &cmdline; diff --git a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h index 8e615900fc2..a0b86b72376 100644 --- a/src/goto-cc/xml_binaries/xml_goto_function_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_function_hashing.h @@ -17,15 +17,19 @@ Date: July 2006 #include "xml_irep_hashing.h" -class xml_goto_function_convertt { - private: - xml_irep_convertt::ireps_containert &ireps_container; - public: - explicit xml_goto_function_convertt(xml_irep_convertt::ireps_containert &ic) : - ireps_container(ic) {}; - - void convert( const xmlt&, goto_functionst::goto_functiont& ); - void convert( const goto_functionst::goto_functiont&, xmlt& ); +class xml_goto_function_convertt +{ +private: + xml_irep_convertt::ireps_containert &ireps_container; + +public: + explicit xml_goto_function_convertt(xml_irep_convertt::ireps_containert &ic): + ireps_container(ic) + { + } + + void convert(const xmlt&, goto_functionst::goto_functiont&); + void convert(const goto_functionst::goto_functiont&, xmlt&); }; #endif // CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_FUNCTION_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h index a8e4384506e..a3af286f1a7 100644 --- a/src/goto-cc/xml_binaries/xml_goto_program_hashing.h +++ b/src/goto-cc/xml_binaries/xml_goto_program_hashing.h @@ -17,23 +17,24 @@ Date: July 2006 #include "xml_irep_hashing.h" -class xml_goto_program_convertt { - private: - xml_irep_convertt irepconverter; - public: - explicit xml_goto_program_convertt(xml_irep_convertt::ireps_containert &ic) : - irepconverter(ic) {}; +class xml_goto_program_convertt +{ +private: + xml_irep_convertt irepconverter; + +public: + explicit xml_goto_program_convertt(xml_irep_convertt::ireps_containert &ic): + irepconverter(ic) + { + } void convert(const goto_programt&, xmlt&); void convert(const xmlt&, goto_programt&); - goto_programt::targett - find_instruction( const xmlt &, - goto_programt::instructionst &, - const std::string &); + goto_programt::targett find_instruction( + const xmlt &, + goto_programt::instructionst &, + const std::string &); }; - - - #endif // CPROVER_GOTO_CC_XML_BINARIES_XML_GOTO_PROGRAM_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_irep_hashing.h b/src/goto-cc/xml_binaries/xml_irep_hashing.h index 7540f775688..5d3887cb5e0 100644 --- a/src/goto-cc/xml_binaries/xml_irep_hashing.h +++ b/src/goto-cc/xml_binaries/xml_irep_hashing.h @@ -14,81 +14,96 @@ Date: July 2006 #include #include -class xml_irep_convertt { - private: - - struct ul_hash +class xml_irep_convertt +{ +private: + struct ul_hash + { + unsigned short operator()(const unsigned long l) const { - unsigned short operator()(const unsigned long l) const - { - return (l & 0xFFFF); - } - }; - struct ul_eq + return (l & 0xFFFF); + } + }; + + struct ul_eq + { + bool operator()(const unsigned long l, const unsigned long r) const { - bool operator()(const unsigned long l, const unsigned long r) const - { - return (l==r); - } - }; - struct irep_full_hash + return (l==r); + } + }; + + struct irep_full_hash + { + size_t operator()(const irept &i) const { - size_t operator()(const irept &i) const - { - return i.full_hash(); - } - }; - struct irep_content_eq + return i.full_hash(); + } + }; + + struct irep_content_eq + { + bool operator()(const irept &l, const irept &r) const { - bool operator()(const irept &l, const irept &r) const + return l.full_eq(l, r); + } + }; + +public: + struct ireps_containert + { + typedef std::unordered_map + id_containert; + id_containert id_container; + + typedef std::unordered_map + content_containert; + content_containert content_container; + + typedef std::map id_replace_mapt; + id_replace_mapt id_replace_map; + + void clear() { - return l.full_eq(l,r); + id_container.clear(); + content_container.clear(); + id_replace_map.clear(); } - }; - - public: - class ireps_containert { - public: - typedef std::unordered_map id_containert; - id_containert id_container; - typedef std::unordered_map content_containert; - content_containert content_container; - typedef std::map id_replace_mapt; - id_replace_mapt id_replace_map; - - void clear( void ) { - id_container.clear(); - content_container.clear(); - id_replace_map.clear(); - } - }; - - xml_irep_convertt(ireps_containert& ic) : ireps_container(ic) {}; - - unsigned long insert(unsigned long, const irept&); - unsigned long insert(const std::string&, const irept&); - - void convert(const irept &irep, xmlt &xml); - void convert(const xmlt &xml, irept &irep); - void reference_convert(const irept &irep, xmlt &xml); - void resolve_references( const irept &cur ); - - void convert_map(xmlt &xml); - void output_map(std::ostream &out, unsigned indent); - - void clear( void ) { ireps_container.clear(); } - private: - ireps_containert& ireps_container; - - ireps_containert::id_containert::const_iterator - find_irep_by_id(const unsigned int); - ireps_containert::content_containert::const_iterator - find_irep_by_content(const irept &irep); - - std::string long_to_string(const unsigned long); - unsigned long string_to_long(const std::string &); - - unsigned long add_with_childs(const irept&); + }; + + explicit xml_irep_convertt(ireps_containert& ic):ireps_container(ic) + { + }; + + unsigned long insert(unsigned long, const irept&); + unsigned long insert(const std::string&, const irept&); + + void convert(const irept &irep, xmlt &xml); + void convert(const xmlt &xml, irept &irep); + void reference_convert(const irept &irep, xmlt &xml); + void resolve_references(const irept &cur); + + void convert_map(xmlt &xml); + void output_map(std::ostream &out, unsigned indent); + + void clear() + { + ireps_container.clear(); + } + +private: + ireps_containert &ireps_container; + + ireps_containert::id_containert::const_iterator + find_irep_by_id(const unsigned int); + ireps_containert::content_containert::const_iterator + find_irep_by_content(const irept &irep); + + std::string long_to_string(const unsigned long); + unsigned long string_to_long(const std::string &); + + unsigned long add_with_childs(const irept&); }; #endif // CPROVER_GOTO_CC_XML_BINARIES_XML_IREP_HASHING_H diff --git a/src/goto-cc/xml_binaries/xml_symbol_hashing.h b/src/goto-cc/xml_binaries/xml_symbol_hashing.h index 796e6392789..0ade830430e 100644 --- a/src/goto-cc/xml_binaries/xml_symbol_hashing.h +++ b/src/goto-cc/xml_binaries/xml_symbol_hashing.h @@ -16,14 +16,17 @@ Date: July 2006 #include "xml_irep_hashing.h" -class xml_symbol_convertt { - private: - xml_irep_convertt irepconverter; - std::list irepcache; - - public: - explicit xml_symbol_convertt(xml_irep_convertt::ireps_containert &ic) : - irepconverter(ic) {}; +class xml_symbol_convertt +{ +private: + xml_irep_convertt irepconverter; + std::list irepcache; + +public: + explicit xml_symbol_convertt(xml_irep_convertt::ireps_containert &ic): + irepconverter(ic) + { + } void convert(const symbolt &, xmlt &); void convert(const xmlt &, symbolt &); diff --git a/src/goto-diff/change_impact.cpp b/src/goto-diff/change_impact.cpp index a8ab174ee68..4c254e853b1 100644 --- a/src/goto-diff/change_impact.cpp +++ b/src/goto-diff/change_impact.cpp @@ -127,7 +127,8 @@ void full_slicert::operator()( req_it!=cfg[e].required_by.end(); ++req_it) { - if(req_it!=cfg[e].required_by.begin()) c+=","; + if(req_it!=cfg[e].required_by.begin()) + c+=","; c+=std::to_string(*req_it); } i_it->source_location.set_column(c); // for show-goto-functions @@ -286,12 +287,16 @@ class change_impactt goto_program_change_impactt &old_impact, goto_program_change_impactt &new_impact); - void propogate_dep_back(const dependence_grapht::nodet &d_node, - const dependence_grapht &dep_graph, - goto_functions_change_impactt &change_impact, bool del); - void propogate_dep_forward(const dependence_grapht::nodet &d_node, - const dependence_grapht &dep_graph, - goto_functions_change_impactt &change_impact, bool del); + void propogate_dep_back( + const dependence_grapht::nodet &d_node, + const dependence_grapht &dep_graph, + goto_functions_change_impactt &change_impact, + bool del); + void propogate_dep_forward( + const dependence_grapht::nodet &d_node, + const dependence_grapht &dep_graph, + goto_functions_change_impactt &change_impact, + bool del); void output_change_impact( const irep_idt &function, @@ -440,10 +445,18 @@ void change_impactt::change_impact( const dependence_grapht::nodet &d_node= old_dep_graph[old_dep_graph[o_it].get_node_id()]; - if(impact_mode == BACKWARD || impact_mode == BOTH) - propogate_dep_back(d_node, old_dep_graph, old_change_impact, true); - if(impact_mode == FORWARD || impact_mode == BOTH) - propogate_dep_forward(d_node, old_dep_graph, old_change_impact, true); + if(impact_mode==BACKWARD || impact_mode==BOTH) + propogate_dep_back( + d_node, + old_dep_graph, + old_change_impact, + true); + if(impact_mode==FORWARD || impact_mode==BOTH) + propogate_dep_forward( + d_node, + old_dep_graph, + old_change_impact, + true); } old_impact[o_it]|=DELETED; ++o_it; @@ -455,10 +468,18 @@ void change_impactt::change_impact( const dependence_grapht::nodet &d_node= new_dep_graph[new_dep_graph[n_it].get_node_id()]; - if(impact_mode == BACKWARD || impact_mode == BOTH) - propogate_dep_back(d_node, new_dep_graph, new_change_impact, false); - if(impact_mode == FORWARD || impact_mode == BOTH) - propogate_dep_forward(d_node, new_dep_graph, new_change_impact, false); + if(impact_mode==BACKWARD || impact_mode==BOTH) + propogate_dep_back( + d_node, + new_dep_graph, + new_change_impact, + false); + if(impact_mode==FORWARD || impact_mode==BOTH) + propogate_dep_forward( + d_node, + new_dep_graph, + new_change_impact, + false); } new_impact[n_it]|=NEW; ++n_it; @@ -480,9 +501,12 @@ Function: change_impactt::propogate_dep_forward \*******************************************************************/ -void change_impactt::propogate_dep_forward(const dependence_grapht::nodet &d_node, - const dependence_grapht &dep_graph, - goto_functions_change_impactt &change_impact, bool del) { +void change_impactt::propogate_dep_forward( + const dependence_grapht::nodet &d_node, + const dependence_grapht &dep_graph, + goto_functions_change_impactt &change_impact, + bool del) +{ for(dependence_grapht::edgest::const_iterator it = d_node.out.begin(); it != d_node.out.end(); ++it) { @@ -516,9 +540,12 @@ Function: change_impactt::propogate_dep_back \*******************************************************************/ -void change_impactt::propogate_dep_back(const dependence_grapht::nodet &d_node, - const dependence_grapht &dep_graph, - goto_functions_change_impactt &change_impact, bool del) { +void change_impactt::propogate_dep_back( + const dependence_grapht::nodet &d_node, + const dependence_grapht &dep_graph, + goto_functions_change_impactt &change_impact, + bool del) +{ for(dependence_grapht::edgest::const_iterator it = d_node.in.begin(); it != d_node.in.end(); ++it) { @@ -834,10 +861,11 @@ void change_impactt::output_instruction(char prefix, return; const irep_idt &file=target->source_location.get_file(); const irep_idt &line=target->source_location.get_line(); - if (!file.empty() && !line.empty()) + if(!file.empty() && !line.empty()) std::cout << prefix << " " << id2string(file) - << " " << id2string(line) << std::endl; - } else + << " " << id2string(line) << std::endl; + } + else { std::cout << prefix; goto_program.output_instruction(ns, function, std::cout, target); diff --git a/src/goto-diff/goto_diff.h b/src/goto-diff/goto_diff.h index 65d9324364d..94155664129 100644 --- a/src/goto-diff/goto_diff.h +++ b/src/goto-diff/goto_diff.h @@ -16,7 +16,7 @@ Author: Peter Schrammel #include -class goto_difft : public messaget +class goto_difft:public messaget { public: explicit goto_difft( @@ -34,14 +34,14 @@ class goto_difft : public messaget virtual bool operator()()=0; - void set_ui(language_uit::uit _ui) { ui=_ui; } + void set_ui(language_uit::uit _ui) { ui=_ui; } virtual std::ostream &output_functions(std::ostream &out) const; protected: const goto_modelt &goto_model1; const goto_modelt &goto_model2; - language_uit::uit ui; + language_uit::uit ui; unsigned total_functions_count; typedef std::set irep_id_sett; @@ -53,7 +53,6 @@ class goto_difft : public messaget void convert_function( json_objectt &result, const irep_idt &function_name) const; - }; #endif // CPROVER_GOTO_DIFF_GOTO_DIFF_H diff --git a/src/goto-diff/goto_diff_languages.h b/src/goto-diff/goto_diff_languages.h index 251c3ce1a91..cb30febbf04 100644 --- a/src/goto-diff/goto_diff_languages.h +++ b/src/goto-diff/goto_diff_languages.h @@ -12,8 +12,7 @@ Author: Peter Schrammel #include #include -class goto_diff_languagest : - public language_uit +class goto_diff_languagest:public language_uit { public: explicit goto_diff_languagest( @@ -26,7 +25,6 @@ class goto_diff_languagest : protected: virtual void register_languages(); - }; #endif // CPROVER_GOTO_DIFF_GOTO_DIFF_LANGUAGES_H diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index da9a6949436..d14a362d364 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -107,7 +107,8 @@ void goto_diff_parse_optionst::eval_verbosity() if(cmdline.isset("verbosity")) { v=unsafe_string2unsigned(cmdline.get_value("verbosity")); - if(v>10) v=10; + if(v>10) + v=10; } ui_message_handler.set_verbosity(v); @@ -263,17 +264,18 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options) if(cmdline.isset("cover")) options.set_option("unwinding-assertions", false); else - options.set_option("unwinding-assertions", + options.set_option( + "unwinding-assertions", cmdline.isset("unwinding-assertions")); // generate unwinding assumptions otherwise - options.set_option("partial-loops", - cmdline.isset("partial-loops")); + options.set_option("partial-loops", cmdline.isset("partial-loops")); if(options.get_bool_option("partial-loops") && options.get_bool_option("unwinding-assertions")) { - error() << "--partial-loops and --unwinding-assertions must not be given together" << eom; + error() << "--partial-loops and --unwinding-assertions" + << " must not be given together" << eom; exit(1); } } @@ -339,18 +341,23 @@ int goto_diff_parse_optionst::doit() } if(cmdline.isset("change-impact") || - cmdline.isset("forward-impact")|| - cmdline.isset("backward-impact")) + cmdline.isset("forward-impact") || + cmdline.isset("backward-impact")) { - //Workaround to avoid deps not propagating between return and end_func + // Workaround to avoid deps not propagating between return and end_func remove_returns(goto_model1); remove_returns(goto_model2); - impact_modet impact_mode = - cmdline.isset("forward-impact") ? - FORWARD : (cmdline.isset("backward-impact") ? BACKWARD : BOTH); - change_impact(goto_model1, goto_model2, impact_mode, - cmdline.isset("compact-output")); + impact_modet impact_mode= + cmdline.isset("forward-impact") ? + FORWARD : + (cmdline.isset("backward-impact") ? BACKWARD : BOTH); + change_impact( + goto_model1, + goto_model2, + impact_mode, + cmdline.isset("compact-output")); + return 0; } @@ -366,7 +373,7 @@ int goto_diff_parse_optionst::doit() std::unique_ptr goto_diff; goto_diff = std::unique_ptr( - new syntactic_difft(goto_model1, goto_model2,get_message_handler())); + new syntactic_difft(goto_model1, goto_model2, get_message_handler())); goto_diff->set_ui(get_ui()); (*goto_diff)(); @@ -397,9 +404,11 @@ int goto_diff_parse_optionst::get_goto_program( if(is_goto_binary(cmdline.args[0])) { - if(read_goto_binary(cmdline.args[0], - goto_model.symbol_table, goto_model.goto_functions, - languages.get_message_handler())) + if(read_goto_binary( + cmdline.args[0], + goto_model.symbol_table, + goto_model.goto_functions, + languages.get_message_handler())) return 6; config.set(cmdline); @@ -419,9 +428,10 @@ int goto_diff_parse_optionst::get_goto_program( cmdline.args.erase(--cmdline.args.end()); } - if(languages.parse()) return 6; - if(languages.typecheck()) return 6; - if(languages.final()) return 6; + if(languages.parse() || + languages.typecheck() || + languages.final()) + return 6; // we no longer need any parse trees or language files languages.clear_parse(); @@ -429,8 +439,10 @@ int goto_diff_parse_optionst::get_goto_program( status() << "Generating GOTO Program" << eom; goto_model.symbol_table=languages.symbol_table; - goto_convert(goto_model.symbol_table, goto_model.goto_functions, - ui_message_handler); + goto_convert( + goto_model.symbol_table, + goto_model.goto_functions, + ui_message_handler); // if we had a second argument then we will handle it next if(arg2!="") @@ -474,7 +486,9 @@ bool goto_diff_parse_optionst::process_goto_program( // remove function pointers status() << "Function Pointer Removal" << eom; - remove_function_pointers(symbol_table, goto_functions, + remove_function_pointers( + symbol_table, + goto_functions, cmdline.isset("pointer-check")); // do partial inlining diff --git a/src/goto-diff/syntactic_diff.cpp b/src/goto-diff/syntactic_diff.cpp index af1e910fd66..4c0e831dfdc 100644 --- a/src/goto-diff/syntactic_diff.cpp +++ b/src/goto-diff/syntactic_diff.cpp @@ -61,7 +61,6 @@ bool syntactic_difft::operator()() break; } } - } forall_goto_functions(it, goto_model2.goto_functions) { diff --git a/src/goto-diff/syntactic_diff.h b/src/goto-diff/syntactic_diff.h index 3ffc28fd722..dd10374dc4b 100644 --- a/src/goto-diff/syntactic_diff.h +++ b/src/goto-diff/syntactic_diff.h @@ -11,20 +11,18 @@ Author: Peter Schrammel #include "goto_diff.h" -class syntactic_difft : public goto_difft +class syntactic_difft:public goto_difft { public: explicit syntactic_difft( const goto_modelt &_goto_model1, const goto_modelt &_goto_model2, - message_handlert &_message_handler - ) - : + message_handlert &_message_handler): goto_difft(_goto_model1, _goto_model2, _message_handler) - {} + { + } virtual bool operator()(); - }; #endif // CPROVER_GOTO_DIFF_SYNTACTIC_DIFF_H diff --git a/src/goto-diff/unified_diff.cpp b/src/goto-diff/unified_diff.cpp index e8a5c3d4e25..8cf1f8f27b3 100644 --- a/src/goto-diff/unified_diff.cpp +++ b/src/goto-diff/unified_diff.cpp @@ -313,7 +313,8 @@ void unified_difft::lcss( for(j=0; j<=new_count; ++j) { std::cerr << " "; - if(lcss_matrix[i][j]<10) std::cerr << " "; + if(lcss_matrix[i][j]<10) + std::cerr << " "; std::cerr << lcss_matrix[i][j]; } std::cerr << std::endl; diff --git a/src/goto-instrument/object_id.h b/src/goto-instrument/object_id.h index 336585d7260..f62ec25e60d 100644 --- a/src/goto-instrument/object_id.h +++ b/src/goto-instrument/object_id.h @@ -32,7 +32,7 @@ class object_idt inline bool operator<(const object_idt &other) const { - return id < other.id; + return id dereferenced; - void track_deref(const entryt& entry, bool read) { + void track_deref(const entryt& entry, bool read) + { if(dereferencing && dereferenced.size()==0) { dereferenced.insert(dereferenced.begin(), entry); @@ -257,15 +258,17 @@ class rw_set_with_trackt:public _rw_set_loct set_reads.insert(entry.object); } else if(dereferencing && dereferenced.size()>0) - dereferenced_from.insert(std::make_pair(entry.object, - dereferenced.front().object)); + dereferenced_from.insert( + std::make_pair(entry.object, dereferenced.front().object)); } - void set_track_deref() { + void set_track_deref() + { dereferencing=true; } - void reset_track_deref() { + void reset_track_deref() + { dereferencing=false; dereferenced.clear(); } diff --git a/src/goto-instrument/uninitialized.cpp b/src/goto-instrument/uninitialized.cpp index 756ed35c5fe..aecd0808057 100644 --- a/src/goto-instrument/uninitialized.cpp +++ b/src/goto-instrument/uninitialized.cpp @@ -162,7 +162,7 @@ void uninitializedt::add_assertions(goto_programt &goto_program) std::list written=objects_written(instruction); // if(instruction.is_function_call()) - //const code_function_callt &code_function_call= + // const code_function_callt &code_function_call= // to_code_function_call(instruction.code); const std::set &uninitialized= @@ -185,7 +185,8 @@ void uninitializedt::add_assertions(goto_programt &goto_program) assertion.type=ASSERT; assertion.guard=symbol_exprt(new_identifier, bool_typet()); assertion.source_location=instruction.source_location; - assertion.source_location.set_comment("use of uninitialized local variable"); + assertion.source_location.set_comment( + "use of uninitialized local variable"); assertion.source_location.set_property_class("uninitialized local"); goto_program.insert_before_swap(i_it, assertion); @@ -276,5 +277,4 @@ void show_uninitialized( uninitialized_analysis.output(ns, f_it->second.body, out); } } - } diff --git a/src/goto-instrument/unwind.cpp b/src/goto-instrument/unwind.cpp index b6ae3e79555..870b5001b38 100644 --- a/src/goto-instrument/unwind.cpp +++ b/src/goto-instrument/unwind.cpp @@ -331,7 +331,7 @@ void goto_unwindt::unwind( // after unwound part copies.destructive_append(rest_program); - + // now insert copies before loop_exit goto_program.destructive_insert(loop_exit, copies); } @@ -355,7 +355,7 @@ int goto_unwindt::get_k( const unwind_sett &unwind_set) const { assert(global_k>=-1); - + unwind_sett::const_iterator f_it=unwind_set.find(func); if(f_it==unwind_set.end()) return global_k; diff --git a/src/goto-programs/goto_program_template.h b/src/goto-programs/goto_program_template.h index a0bbff9623c..dca22ae3a9a 100644 --- a/src/goto-programs/goto_program_template.h +++ b/src/goto-programs/goto_program_template.h @@ -23,27 +23,28 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -typedef enum { NO_INSTRUCTION_TYPE=0, - GOTO=1, // branch, possibly guarded - ASSUME=2, // non-failing guarded self loop - ASSERT=3, // assertions - OTHER=4, // anything else - SKIP=5, // just advance the PC - START_THREAD=6, // spawns an asynchronous thread - END_THREAD=7, // end the current thread - LOCATION=8, // semantically like SKIP - END_FUNCTION=9, // exit point of a function - ATOMIC_BEGIN=10, // marks a block without interleavings - ATOMIC_END=11, // end of a block without interleavings - RETURN=12, // set function return value (no control-flow change) - ASSIGN=13, // assignment lhs:=rhs - DECL=14, // declare a local variable - DEAD=15, // marks the end-of-live of a local variable - FUNCTION_CALL=16,// call a function - THROW=17, // throw an exception - CATCH=18 // catch an exception - } - goto_program_instruction_typet; +typedef enum +{ + NO_INSTRUCTION_TYPE=0, + GOTO=1, // branch, possibly guarded + ASSUME=2, // non-failing guarded self loop + ASSERT=3, // assertions + OTHER=4, // anything else + SKIP=5, // just advance the PC + START_THREAD=6, // spawns an asynchronous thread + END_THREAD=7, // end the current thread + LOCATION=8, // semantically like SKIP + END_FUNCTION=9, // exit point of a function + ATOMIC_BEGIN=10, // marks a block without interleavings + ATOMIC_END=11, // end of a block without interleavings + RETURN=12, // set function return value (no control-flow change) + ASSIGN=13, // assignment lhs:=rhs + DECL=14, // declare a local variable + DEAD=15, // marks the end-of-live of a local variable + FUNCTION_CALL=16, // call a function + THROW=17, // throw an exception + CATCH=18 // catch an exception +} goto_program_instruction_typet; std::ostream &operator<<(std::ostream &, goto_program_instruction_typet); @@ -142,7 +143,6 @@ class goto_program_templatet inline void make_goto() { clear(GOTO); } inline void make_return() { clear(RETURN); } - inline void make_function_call(const codeT &_code) { clear(FUNCTION_CALL); code=_code; } inline void make_skip() { clear(SKIP); } inline void make_throw() { clear(THROW); } inline void make_catch() { clear(CATCH); } @@ -167,11 +167,17 @@ class goto_program_templatet guard=g; } + inline void make_function_call(const codeT &_code) + { + clear(FUNCTION_CALL); + code=_code; + } + inline bool is_goto () const { return type==GOTO; } inline bool is_return () const { return type==RETURN; } inline bool is_assign () const { return type==ASSIGN; } inline bool is_function_call() const { return type==FUNCTION_CALL; } - inline bool is_throw () const { return type==THROW; } + inline bool is_throw () const { return type==THROW; } inline bool is_catch () const { return type==CATCH; } inline bool is_skip () const { return type==SKIP; } inline bool is_location () const { return type==LOCATION; } @@ -310,7 +316,9 @@ class goto_program_templatet //! Insertion that preserves jumps to "target". //! The program p is destroyed. - void insert_before_swap(targett target, goto_program_templatet &p) + void insert_before_swap( + targett target, + goto_program_templatet &p) { assert(target!=instructions.end()); if(p.instructions.empty()) return; @@ -327,7 +335,7 @@ class goto_program_templatet { return instructions.insert(target, instructiont()); } - + //! Insertion before the given target //! \return newly inserted location inline targett insert_before(const_targett target) @@ -358,8 +366,7 @@ class goto_program_templatet targett target, goto_program_templatet &p) { - instructions.splice(target, - p.instructions); + instructions.splice(target, p.instructions); // BUG: The iterators to p-instructions are invalidated! } @@ -369,8 +376,7 @@ class goto_program_templatet const_targett target, goto_program_templatet &p) { - instructions.splice(target, - p.instructions); + instructions.splice(target, p.instructions); // BUG: The iterators to p-instructions are invalidated! } @@ -649,7 +655,6 @@ void goto_program_templatet::compute_target_numbers() } } } - } template diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index a021e96f448..84867792c4f 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -64,8 +64,9 @@ class remove_function_pointerst const typet &function_type); void fix_argument_types(code_function_callt &function_call); - void fix_return_type(code_function_callt &function_call, - goto_programt &dest); + void fix_return_type( + code_function_callt &function_call, + goto_programt &dest); symbolt &new_tmp_symbol(); @@ -129,8 +130,10 @@ symbolt &remove_function_pointerst::new_tmp_symbol() do { - new_symbol.base_name="tmp_return_val$"+std::to_string(++temporary_counter); - new_symbol.name="remove_function_pointers::"+id2string(new_symbol.base_name); + new_symbol.base_name= + "tmp_return_val$"+std::to_string(++temporary_counter); + new_symbol.name= + "remove_function_pointers::"+id2string(new_symbol.base_name); } while(symbol_table.move(new_symbol, symbol_ptr)); return *symbol_ptr; @@ -459,7 +462,8 @@ void remove_function_pointerst::remove_function_pointer( irep_idt comment=it->source_location.get_comment(); it->source_location=target->source_location; it->function=target->function; - if(!property_class.empty()) it->source_location.set_property_class(property_class); + if(!property_class.empty()) + it->source_location.set_property_class(property_class); if(!comment.empty()) it->source_location.set_comment(comment); } diff --git a/src/goto-symex/slice_by_trace.h b/src/goto-symex/slice_by_trace.h index 4e275ff0456..8223e6589e1 100644 --- a/src/goto-symex/slice_by_trace.h +++ b/src/goto-symex/slice_by_trace.h @@ -18,8 +18,9 @@ class symex_slice_by_tracet { } - void slice_by_trace(std::string trace_files, - symex_target_equationt &equation); + void slice_by_trace( + std::string trace_files, + symex_target_equationt &equation); protected: const namespacet &ns; @@ -69,9 +70,9 @@ class symex_slice_by_tracet void assign_merges(symex_target_equationt &equation); - std::set implied_guards (exprt e); + std::set implied_guards(exprt e); - bool implies_false (exprt e); + bool implies_false(exprt e); }; #endif // CPROVER_GOTO_SYMEX_SLICE_BY_TRACE_H diff --git a/src/goto-symex/symex_target_equation.h b/src/goto-symex/symex_target_equation.h index 5801045a0a6..a16dd810f01 100644 --- a/src/goto-symex/symex_target_equation.h +++ b/src/goto-symex/symex_target_equation.h @@ -308,7 +308,11 @@ inline bool operator<( return &(*a)<&(*b); } -std::ostream &operator<<(std::ostream &out, const symex_target_equationt::SSA_stept &step); -std::ostream &operator<<(std::ostream &out, const symex_target_equationt &equation); +std::ostream &operator<<( + std::ostream &out, + const symex_target_equationt::SSA_stept &step); +std::ostream &operator<<( + std::ostream &out, + const symex_target_equationt &equation); #endif // CPROVER_GOTO_SYMEX_SYMEX_TARGET_EQUATION_H diff --git a/src/path-symex/locs.h b/src/path-symex/locs.h index 57b39865801..ac24b41057e 100644 --- a/src/path-symex/locs.h +++ b/src/path-symex/locs.h @@ -18,10 +18,11 @@ Author: Daniel Kroening, kroening@kroening.com struct loct { public: - loct(goto_programt::const_targett _target, - const irep_idt &_function): - target(_target), - function(_function) + loct( + goto_programt::const_targett _target, + const irep_idt &_function): + target(_target), + function(_function) { } @@ -55,13 +56,13 @@ class locst inline loct &operator[] (loc_reft l) { - assert(l.loc_number>=0 && l.loc_number < loc_vector.size()); + assert(l.loc_number>=0 && l.loc_number=0 && l.loc_number < loc_vector.size()); + assert(l.loc_number>=0 && l.loc_number { public: - explicit value_set_analysist(const namespacet &_ns): - static_analysist(_ns) - { - } + explicit value_set_analysist(const namespacet &_ns): + static_analysist(_ns) + { + } typedef static_analysist baset; diff --git a/src/pointer-analysis/value_set_dereference.cpp b/src/pointer-analysis/value_set_dereference.cpp index df1d163e1b0..0e95cdabcc6 100644 --- a/src/pointer-analysis/value_set_dereference.cpp +++ b/src/pointer-analysis/value_set_dereference.cpp @@ -6,7 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -//#define DEBUG +// #define DEBUG #ifdef DEBUG #include @@ -385,7 +385,7 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( } else if(root_object.id()==ID_dynamic_object) { - //const dynamic_object_exprt &dynamic_object= + // const dynamic_object_exprt &dynamic_object= // to_dynamic_object_expr(root_object); // the object produced by malloc @@ -406,7 +406,7 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( if(options.get_bool_option("pointer-check")) { - //if(!dynamic_object.valid().is_true()) + // if(!dynamic_object.valid().is_true()) { // check if it is still alive guardt tmp_guard(guard); @@ -541,7 +541,9 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( result.value.make_typecast(dereference_type); } else if(root_object_type.id()==ID_array && - dereference_type_compare(root_object_type.subtype(), dereference_type)) + dereference_type_compare( + root_object_type.subtype(), + dereference_type)) { // We have an array with a subtype that matches // the dereferencing type. @@ -587,8 +589,11 @@ value_set_dereferencet::valuet value_set_dereferencet::build_reference_to( if(ns.follow(result.value.type())!=ns.follow(dereference_type)) result.value.make_typecast(dereference_type); } - else if(get_subexpression_at_offset(root_object_subexpression, o.offset(), - dereference_type, ns)) + else if(get_subexpression_at_offset( + root_object_subexpression, + o.offset(), + dereference_type, + ns)) { // Successfully found a member, array index, or combination thereof // that matches the desired type and offset: diff --git a/src/solvers/dplib/dplib_prop.h b/src/solvers/dplib/dplib_prop.h index d41bfd30457..be79a4d7ba6 100644 --- a/src/solvers/dplib/dplib_prop.h +++ b/src/solvers/dplib/dplib_prop.h @@ -43,7 +43,7 @@ class dplib_propt:virtual public propt virtual literalt new_variable(); virtual size_t no_variables() const { return _no_variables; } virtual void set_no_variables(size_t no) { assert(false); } - //virtual unsigned no_clauses()=0; + // virtual unsigned no_clauses()=0; virtual void lcnf(const bvt &bv); diff --git a/src/solvers/flattening/boolbv.cpp b/src/solvers/flattening/boolbv.cpp index cbb6e01254c..936417bdfb8 100644 --- a/src/solvers/flattening/boolbv.cpp +++ b/src/solvers/flattening/boolbv.cpp @@ -27,7 +27,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "../floatbv/float_utils.h" -//#define DEBUG +// #define DEBUG /*******************************************************************\ @@ -142,7 +142,9 @@ const bvt& boolbvt::convert_bv(const exprt &expr) bv_cache.insert(std::make_pair(expr, bvt())); if(!cache_result.second) { - //std::cerr << "Cache hit on " << expr << "\n"; + #ifdef DEBUG + std::cout << "Cache hit on " << expr << "\n"; + #endif return cache_result.first->second; } @@ -327,7 +329,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr) return convert_array_of(to_array_of_expr(expr)); else if(expr.id()==ID_let) { - //const let_exprt &let_expr=to_let_expr(expr); + // const let_exprt &let_expr=to_let_expr(expr); throw "let is todo"; } else if(expr.id()==ID_function_application) @@ -555,8 +557,7 @@ literalt boolbvt::convert_rest(const exprt &expr) if(expr.operands().size()!=2) throw "notequal expects two operands"; - return !convert_equality( - equal_exprt(expr.op0(), expr.op1())); + return !convert_equality(equal_exprt(expr.op0(), expr.op1())); } else if(expr.id()==ID_ieee_float_equal || expr.id()==ID_ieee_float_notequal) diff --git a/src/solvers/flattening/boolbv_typecast.cpp b/src/solvers/flattening/boolbv_typecast.cpp index c7ab6410214..20bfb3b40b8 100644 --- a/src/solvers/flattening/boolbv_typecast.cpp +++ b/src/solvers/flattening/boolbv_typecast.cpp @@ -63,12 +63,20 @@ bool boolbvt::type_conversion( bvtypet src_bvtype=get_bvtype(src_type); if(src_bvtype==IS_C_BIT_FIELD) - return type_conversion( - c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns), src, dest_type, dest); + return + type_conversion( + c_bit_field_replacement_type(to_c_bit_field_type(src_type), ns), + src, + dest_type, + dest); if(dest_bvtype==IS_C_BIT_FIELD) - return type_conversion( - src_type, src, c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns), dest); + return + type_conversion( + src_type, + src, + c_bit_field_replacement_type(to_c_bit_field_type(dest_type), ns), + dest); std::size_t src_width=src.size(); std::size_t dest_width=boolbv_width(dest_type); @@ -98,8 +106,16 @@ bool boolbvt::type_conversion( bvt lower, upper, lower_res, upper_res; lower.assign(src.begin(), src.begin()+src.size()/2); upper.assign(src.begin()+src.size()/2, src.end()); - type_conversion(ns.follow(src_type.subtype()), lower, ns.follow(dest_type.subtype()), lower_res); - type_conversion(ns.follow(src_type.subtype()), upper, ns.follow(dest_type.subtype()), upper_res); + type_conversion( + ns.follow(src_type.subtype()), + lower, + ns.follow(dest_type.subtype()), + lower_res); + type_conversion( + ns.follow(src_type.subtype()), + upper, + ns.follow(dest_type.subtype()), + upper_res); assert(lower_res.size()+upper_res.size()==dest_width); dest=lower_res; dest.insert(dest.end(), upper_res.begin(), upper_res.end()); @@ -225,10 +241,12 @@ bool boolbvt::type_conversion( { // fixed to fixed - std::size_t dest_fraction_bits=to_fixedbv_type(dest_type).get_fraction_bits(), - dest_int_bits=dest_width-dest_fraction_bits; - std::size_t op_fraction_bits=to_fixedbv_type(src_type).get_fraction_bits(), - op_int_bits=src_width-op_fraction_bits; + std::size_t dest_fraction_bits= + to_fixedbv_type(dest_type).get_fraction_bits(); + std::size_t dest_int_bits=dest_width-dest_fraction_bits; + std::size_t op_fraction_bits= + to_fixedbv_type(src_type).get_fraction_bits(); + std::size_t op_int_bits=src_width-op_fraction_bits; dest.resize(dest_width); @@ -518,8 +536,7 @@ bool boolbvt::type_conversion( } else if(dest_type.id()==ID_struct) { - const struct_typet &dest_struct = - to_struct_type(dest_type); + const struct_typet &dest_struct=to_struct_type(dest_type); if(src_type.id()==ID_struct) { @@ -527,8 +544,7 @@ bool boolbvt::type_conversion( dest.resize(dest_width, const_literal(false)); - const struct_typet &op_struct = - to_struct_type(src_type); + const struct_typet &op_struct=to_struct_type(src_type); const struct_typet::componentst &dest_comp= dest_struct.components(); @@ -590,7 +606,6 @@ bool boolbvt::type_conversion( return false; } } - } return true; diff --git a/src/solvers/flattening/bv_utils.h b/src/solvers/flattening/bv_utils.h index 992d7229b7c..42dd4ea7037 100644 --- a/src/solvers/flattening/bv_utils.h +++ b/src/solvers/flattening/bv_utils.h @@ -19,7 +19,7 @@ Author: Daniel Kroening, kroening@kroening.com // Shares variables between var == const tests for registered variables. // Gives ~15% memory savings on some programs using constant arrays // but seems to give a run-time penalty. -//#define COMPACT_EQUAL_CONST +// #define COMPACT_EQUAL_CONST class bv_utilst @@ -45,14 +45,24 @@ class bv_utilst // bit-wise negation bvt inverted(const bvt &op); - literalt full_adder(const literalt a, const literalt b, const literalt carry_in, literalt &carry_out); + literalt full_adder( + const literalt a, + const literalt b, + const literalt carry_in, + literalt &carry_out); literalt carry(literalt a, literalt b, literalt c); bvt add_sub(const bvt &op0, const bvt &op1, bool subtract); bvt add_sub(const bvt &op0, const bvt &op1, literalt subtract); - bvt add_sub_no_overflow(const bvt &op0, const bvt &op1, bool subtract, representationt rep); + bvt add_sub_no_overflow( + const bvt &op0, + const bvt &op1, + bool subtract, + representationt rep); + bvt add(const bvt &op0, const bvt &op1) { return add_sub(op0, op1, false); } bvt sub(const bvt &op0, const bvt &op1) { return add_sub(op0, op1, true); } + literalt overflow_add(const bvt &op0, const bvt &op1, representationt rep); literalt overflow_sub(const bvt &op0, const bvt &op1, representationt rep); literalt carry_out(const bvt &op0, const bvt &op1, literalt carry_in); @@ -64,32 +74,43 @@ class bv_utilst bvt unsigned_multiplier(const bvt &op0, const bvt &op1); bvt signed_multiplier(const bvt &op0, const bvt &op1); bvt multiplier(const bvt &op0, const bvt &op1, representationt rep); - bvt multiplier_no_overflow(const bvt &op0, const bvt &op1, representationt rep); + bvt multiplier_no_overflow( + const bvt &op0, + const bvt &op1, + representationt rep); - bvt divider(const bvt &op0, const bvt &op1, - representationt rep) + bvt divider(const bvt &op0, const bvt &op1, representationt rep) { bvt res, rem; divider(op0, op1, res, rem, rep); return res; } - bvt remainder(const bvt &op0, const bvt &op1, - representationt rep) + bvt remainder(const bvt &op0, const bvt &op1, representationt rep) { bvt res, rem; divider(op0, op1, res, rem, rep); return rem; } - void divider(const bvt &op0, const bvt &op1, - bvt &res, bvt &rem, representationt rep); + void divider( + const bvt &op0, + const bvt &op1, + bvt &res, + bvt &rem, + representationt rep); - void signed_divider(const bvt &op0, const bvt &op1, - bvt &res, bvt &rem); + void signed_divider( + const bvt &op0, + const bvt &op1, + bvt &res, + bvt &rem); - void unsigned_divider(const bvt &op0, const bvt &op1, - bvt &res, bvt &rem); + void unsigned_divider( + const bvt &op0, + const bvt &op1, + bvt &res, + bvt &rem); #ifdef COMPACT_EQUAL_CONST typedef std::set equal_const_registeredt; @@ -100,7 +121,7 @@ class bv_utilst typedef std::map equal_const_cachet; equal_const_cachet equal_const_cache; - literalt equal_const_rec (bvt &var, bvt &constant); + literalt equal_const_rec(bvt &var, bvt &constant); literalt equal_const(const bvt &var, const bvt &constant); #endif @@ -130,14 +151,18 @@ class bv_utilst literalt is_all_ones(const bvt &op) { return prop.land(op); } - literalt lt_or_le(bool or_equal, - const bvt &bv0, - const bvt &bv1, - representationt rep); + literalt lt_or_le( + bool or_equal, + const bvt &bv0, + const bvt &bv1, + representationt rep); // id is one of ID_lt, le, gt, ge, equal, notequal - literalt rel(const bvt &bv0, irep_idt id, const bvt &bv1, - representationt rep); + literalt rel( + const bvt &bv0, + irep_idt id, + const bvt &bv1, + representationt rep); literalt unsigned_less_than(const bvt &bv0, const bvt &bv1); literalt signed_less_than(const bvt &bv0, const bvt &bv1); @@ -190,8 +215,11 @@ class bv_utilst protected: propt ∝ - void adder(bvt &sum, const bvt &op, - literalt carry_in, literalt &carry_out); + void adder( + bvt &sum, + const bvt &op, + literalt carry_in, + literalt &carry_out); void adder_no_overflow( bvt &sum, diff --git a/src/solvers/floatbv/float_bv.h b/src/solvers/floatbv/float_bv.h index 6a8481cba30..c89d58adc6d 100644 --- a/src/solvers/floatbv/float_bv.h +++ b/src/solvers/floatbv/float_bv.h @@ -42,23 +42,63 @@ class float_bvt exprt isfinite(const exprt &, const ieee_float_spect &); // add/sub - exprt add_sub(bool subtract, const exprt &, const exprt &, const exprt &rm, const ieee_float_spect &); + exprt add_sub( + bool subtract, + const exprt &, + const exprt &, + const exprt &rm, + const ieee_float_spect &); // mul/div - exprt mul(const exprt &, const exprt &, const exprt &rm, const ieee_float_spect &); - exprt div(const exprt &, const exprt &, const exprt &rm, const ieee_float_spect &); + exprt mul( + const exprt &, + const exprt &, + const exprt &rm, + const ieee_float_spect &); + exprt div( + const exprt &, + const exprt &, + const exprt &rm, + const ieee_float_spect &); // conversion - exprt from_unsigned_integer(const exprt &, const exprt &rm, const ieee_float_spect &); - exprt from_signed_integer(const exprt &, const exprt &rm, const ieee_float_spect &); - exprt to_signed_integer(const exprt &src, std::size_t dest_width, const exprt &rm, const ieee_float_spect &); - exprt to_unsigned_integer(const exprt &src, std::size_t dest_width, const exprt &rm, const ieee_float_spect &); - exprt to_integer(const exprt &src, std::size_t dest_width, bool is_signed, const exprt &rm, const ieee_float_spect &); - exprt conversion(const exprt &src, const exprt &rm, const ieee_float_spect &src_spec, const ieee_float_spect &dest_spec); + exprt from_unsigned_integer( + const exprt &, + const exprt &rm, + const ieee_float_spect &); + exprt from_signed_integer( + const exprt &, + const exprt &rm, + const ieee_float_spect &); + exprt to_signed_integer( + const exprt &src, + std::size_t dest_width, + const exprt &rm, + const ieee_float_spect &); + exprt to_unsigned_integer( + const exprt &src, + std::size_t dest_width, + const exprt &rm, + const ieee_float_spect &); + exprt to_integer( + const exprt &src, + std::size_t dest_width, + bool is_signed, + const exprt &rm, + const ieee_float_spect &); + exprt conversion( + const exprt &src, + const exprt &rm, + const ieee_float_spect &src_spec, + const ieee_float_spect &dest_spec); // relations typedef enum { LT, LE, EQ, GT, GE } relt; - exprt relation(const exprt &, relt rel, const exprt &, const ieee_float_spect &); + exprt relation( + const exprt &, + relt rel, + const exprt &, + const ieee_float_spect &); protected: // helpers @@ -86,7 +126,10 @@ class float_bvt // unpacked void normalization_shift(exprt &fraction, exprt &exponent); - void denormalization_shift(exprt &fraction, exprt &exponent, const ieee_float_spect &); + void denormalization_shift( + exprt &fraction, + exprt &exponent, + const ieee_float_spect &); exprt add_bias(const exprt &exponent, const ieee_float_spect &); exprt sub_bias(const exprt &exponent, const ieee_float_spect &); @@ -122,12 +165,21 @@ class float_bvt biased_floatt bias(const unbiased_floatt &, const ieee_float_spect &); // this takes unpacked format, and returns packed - virtual exprt rounder(const unbiased_floatt &, const exprt &rm, const ieee_float_spect &); + virtual exprt rounder( + const unbiased_floatt &, + const exprt &rm, + const ieee_float_spect &); exprt pack(const biased_floatt &, const ieee_float_spect &); unbiased_floatt unpack(const exprt &, const ieee_float_spect &); - void round_fraction(unbiased_floatt &result, const rounding_mode_bitst &, const ieee_float_spect &); - void round_exponent(unbiased_floatt &result, const rounding_mode_bitst &, const ieee_float_spect &); + void round_fraction( + unbiased_floatt &result, + const rounding_mode_bitst &, + const ieee_float_spect &); + void round_exponent( + unbiased_floatt &result, + const rounding_mode_bitst &, + const ieee_float_spect &); // rounding decision for fraction exprt fraction_rounding_decision( diff --git a/src/solvers/floatbv/float_utils.h b/src/solvers/floatbv/float_utils.h index 6d83758bd94..ca486ade9bc 100644 --- a/src/solvers/floatbv/float_utils.h +++ b/src/solvers/floatbv/float_utils.h @@ -104,8 +104,16 @@ class float_utilst // add/sub virtual bvt add_sub(const bvt &src1, const bvt &src2, bool subtract); - bvt add(const bvt &src1, const bvt &src2) { return add_sub(src1, src2, false); } - bvt sub(const bvt &src1, const bvt &src2) { return add_sub(src1, src2, true); } + + bvt add(const bvt &src1, const bvt &src2) + { + return add_sub(src1, src2, false); + } + + bvt sub(const bvt &src1, const bvt &src2) + { + return add_sub(src1, src2, true); + } // mul/div/rem virtual bvt mul(const bvt &src1, const bvt &src2); diff --git a/src/solvers/refinement/refine_arithmetic.cpp b/src/solvers/refinement/refine_arithmetic.cpp index 58c0b7f4f53..b1cafc9c92b 100644 --- a/src/solvers/refinement/refine_arithmetic.cpp +++ b/src/solvers/refinement/refine_arithmetic.cpp @@ -317,7 +317,7 @@ void bv_refinementt::check_SAT(approximationt &a) << "==" << integer2binary(result.pack(), spec.width()) << eom; #endif - //if(a.over_state==1) { debug() << "DISAGREEMENT!\n"; exit(1); } + // if(a.over_state==1) { debug() << "DISAGREEMENT!\n"; exit(1); } if(a.over_statesecond; @@ -1235,7 +1241,7 @@ void smt2_convt::convert_expr(const exprt &expr) { if(use_datatypes) { - assert(datatype_map.find(expr.type()) != datatype_map.end()); + assert(datatype_map.find(expr.type())!=datatype_map.end()); const std::string smt_typename= datatype_map.find(expr.type())->second; @@ -1282,7 +1288,7 @@ void smt2_convt::convert_expr(const exprt &expr) } else if(expr.id()==ID_sign) { - assert(expr.operands().size() == 1); + assert(expr.operands().size()==1); const typet &op_type=expr.op0().type(); @@ -1306,7 +1312,7 @@ void smt2_convt::convert_expr(const exprt &expr) out << " (_ bv0 " << op_width << "))"; } else - UNEXPECTEDCASE("sign applied to type " + expr.type().id_string()); + UNEXPECTEDCASE("sign applied to type "+expr.type().id_string()); } else if(expr.id()==ID_if) { @@ -1527,12 +1533,15 @@ void smt2_convt::convert_expr(const exprt &expr) } } else - UNEXPECTEDCASE("unsupported op1 type for "+expr.id_string()+": "+type.id_string()); + UNEXPECTEDCASE( + "unsupported op1 type for "+expr.id_string()+": "+ + type.id_string()); out << ")"; // bv*sh } else - UNEXPECTEDCASE("unsupported type for "+expr.id_string()+": "+type.id_string()); + UNEXPECTEDCASE( + "unsupported type for "+expr.id_string()+": "+type.id_string()); } else if(expr.id()==ID_with) { @@ -2021,10 +2030,13 @@ void smt2_convt::convert_expr(const exprt &expr) } else if(expr.id()==ID_constraint_select_one) { - UNEXPECTEDCASE("smt2_convt::convert_expr: `"+expr.id_string()+"' is not yet supported"); + UNEXPECTEDCASE( + "smt2_convt::convert_expr: `"+expr.id_string()+ + "' is not yet supported"); } else - UNEXPECTEDCASE("smt2_convt::convert_expr: `"+expr.id_string()+"' is unsupported"); + UNEXPECTEDCASE( + "smt2_convt::convert_expr: `"+expr.id_string()+"' is unsupported"); } /*******************************************************************\ @@ -2203,15 +2215,19 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) convert_expr(src); } } - else if (dest_type.id()==ID_signedbv) + else if(dest_type.id()==ID_signedbv) { // this should be floatbv_typecast, not typecast - UNEXPECTEDCASE("typecast unexpected "+src_type.id_string()+" -> "+dest_type.id_string()); + UNEXPECTEDCASE( + "typecast unexpected "+src_type.id_string()+" -> "+ + dest_type.id_string()); } - else if (dest_type.id()==ID_unsignedbv) + else if(dest_type.id()==ID_unsignedbv) { // this should be floatbv_typecast, not typecast - UNEXPECTEDCASE("typecast unexpected "+src_type.id_string()+" -> "+dest_type.id_string()); + UNEXPECTEDCASE( + "typecast unexpected "+src_type.id_string()+" -> "+ + dest_type.id_string()); } } else if(src_type.id()==ID_bool) // from boolean to int @@ -2299,7 +2315,9 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) } else { - UNEXPECTEDCASE("TODO typecast2 "+src_type.id_string()+" -> "+dest_type.id_string() + " src == " + from_expr(ns, "", src)); + UNEXPECTEDCASE( + "TODO typecast2 "+src_type.id_string()+" -> "+ + dest_type.id_string()+" src == "+from_expr(ns, "", src)); } } else if(dest_type.id()==ID_fixedbv) // to fixedbv @@ -2515,7 +2533,8 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr) } } else - UNEXPECTEDCASE("TODO typecast8 "+src_type.id_string()+" -> "+dest_type.id_string()); + UNEXPECTEDCASE( + "TODO typecast8 "+src_type.id_string()+" -> "+dest_type.id_string()); } /*******************************************************************\ @@ -2533,7 +2552,7 @@ Function: smt2_convt::convert_floatbv_typecast void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) { const exprt &src=expr.op(); - //const exprt &rounding_mode=expr.rounding_mode(); + // const exprt &rounding_mode=expr.rounding_mode(); const typet &src_type=src.type(); const typet &dest_type=expr.type(); @@ -2631,12 +2650,15 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) // We first convert to 'underlying type' floatbv_typecast_exprt tmp=expr; - tmp.op()=typecast_exprt(src, - ns.follow_tag(to_c_enum_tag_type(src_type)).subtype()); + tmp.op()= + typecast_exprt( + src, + ns.follow_tag(to_c_enum_tag_type(src_type)).subtype()); convert_floatbv_typecast(tmp); } else - UNEXPECTEDCASE("TODO typecast11 "+src_type.id_string()+" -> "+dest_type.id_string()); + UNEXPECTEDCASE( + "TODO typecast11 "+src_type.id_string()+" -> "+dest_type.id_string()); } else if(dest_type.id()==ID_signedbv) { @@ -2668,7 +2690,8 @@ void smt2_convt::convert_floatbv_typecast(const floatbv_typecast_exprt &expr) } else { - UNEXPECTEDCASE("TODO typecast12 "+src_type.id_string()+" -> "+dest_type.id_string()); + UNEXPECTEDCASE( + "TODO typecast12 "+src_type.id_string()+" -> "+dest_type.id_string()); } } @@ -2697,7 +2720,7 @@ void smt2_convt::convert_struct(const struct_exprt &expr) if(use_datatypes) { - assert(datatype_map.find(struct_type) != datatype_map.end()); + assert(datatype_map.find(struct_type)!=datatype_map.end()); const std::string smt_typename = datatype_map.find(struct_type)->second; @@ -2889,8 +2912,8 @@ void smt2_convt::convert_constant(const constant_exprt &expr) is needed to get to IEEE-754 style representations. */ ieee_floatt v=ieee_floatt(expr); - size_t e = floatbv_type.get_e(); - size_t f = floatbv_type.get_f() + 1; + size_t e=floatbv_type.get_e(); + size_t f=floatbv_type.get_f()+1; /* Should be sufficient, but not currently supported by mathsat */ #if 0 @@ -2906,7 +2929,7 @@ void smt2_convt::convert_constant(const constant_exprt &expr) } else if(v.is_infinity()) { - if (v.get_sign()) + if(v.get_sign()) out << "(_ -oo " << e << " " << f << ")"; else out << "(_ +oo " << e << " " << f << ")"; @@ -3160,8 +3183,8 @@ void smt2_convt::convert_relation(const exprt &expr) out << ")"; } else - UNEXPECTEDCASE("unsupported type for "+expr.id_string()+": "+op_type.id_string()); - + UNEXPECTEDCASE( + "unsupported type for "+expr.id_string()+": "+op_type.id_string()); } /*******************************************************************\ @@ -3229,7 +3252,7 @@ void smt2_convt::convert_plus(const plus_exprt &expr) out << "(bvmul "; convert_expr(i); out << " (_ bv" << element_size - << " " << boolbv_width(expr.type()) << "))"; + << " " << boolbv_width(expr.type()) << "))"; } else convert_expr(i); @@ -3272,7 +3295,10 @@ void smt2_convt::convert_plus(const plus_exprt &expr) exprt tmp(ID_plus, vector_type.subtype()); forall_operands(it, expr) tmp.copy_to_operands( - index_exprt(*it, from_integer(size-i-1, index_type), vector_type.subtype())); + index_exprt( + *it, + from_integer(size-i-1, index_type), + vector_type.subtype())); out << " "; convert_expr(tmp); @@ -3330,7 +3356,9 @@ void smt2_convt::convert_rounding_mode_FPA(const exprt &expr) else if(value==3) out << "roundTowardZero"; else - INVALIDEXPR("Unknown constant rounding mode with value "+id2string(cexpr.get_value())); + INVALIDEXPR( + "Unknown constant rounding mode with value "+ + id2string(cexpr.get_value())); } else { @@ -3494,7 +3522,10 @@ void smt2_convt::convert_minus(const minus_exprt &expr) exprt tmp(ID_minus, vector_type.subtype()); forall_operands(it, expr) tmp.copy_to_operands( - index_exprt(*it, from_integer(size-i-1, index_type), vector_type.subtype())); + index_exprt( + *it, + from_integer(size-i-1, index_type), + vector_type.subtype())); out << " "; convert_expr(tmp); @@ -3851,7 +3882,7 @@ void smt2_convt::convert_with(const with_exprt &expr) if(use_datatypes) { - assert(datatype_map.find(expr_type) != datatype_map.end()); + assert(datatype_map.find(expr_type)!=datatype_map.end()); const std::string smt_typename= datatype_map.find(expr_type)->second; @@ -3993,7 +4024,9 @@ void smt2_convt::convert_with(const with_exprt &expr) out << ")"; // bvor } else - UNEXPECTEDCASE("with expects struct, union, or array type, but got "+expr.type().id_string()); + UNEXPECTEDCASE( + "with expects struct, union, or array type, but got "+ + expr.type().id_string()); } /*******************************************************************\ @@ -4125,7 +4158,8 @@ void smt2_convt::convert_index(const index_exprt &expr) } } else - UNEXPECTEDCASE("index with unsupported array type: "+array_op_type.id_string()); + UNEXPECTEDCASE( + "index with unsupported array type: "+array_op_type.id_string()); } /*******************************************************************\ @@ -4159,7 +4193,7 @@ void smt2_convt::convert_member(const member_exprt &expr) if(use_datatypes) { - assert(datatype_map.find(struct_type) != datatype_map.end()); + assert(datatype_map.find(struct_type)!=datatype_map.end()); const std::string smt_typename= datatype_map.find(struct_type)->second; @@ -4201,7 +4235,8 @@ void smt2_convt::convert_member(const member_exprt &expr) unflatten(END, expr.type()); } else - UNEXPECTEDCASE("convert_member on an unexpected type " + struct_op_type.id_string()); + UNEXPECTEDCASE( + "convert_member on an unexpected type "+struct_op_type.id_string()); } /*******************************************************************\ @@ -4230,7 +4265,7 @@ void smt2_convt::flatten2bv(const exprt &expr) { if(use_datatypes) { - assert(datatype_map.find(type) != datatype_map.end()); + assert(datatype_map.find(type)!=datatype_map.end()); const std::string smt_typename= datatype_map.find(type)->second; @@ -4266,7 +4301,7 @@ void smt2_convt::flatten2bv(const exprt &expr) { if(use_datatypes) { - assert(datatype_map.find(type) != datatype_map.end()); + assert(datatype_map.find(type)!=datatype_map.end()); const std::string smt_typename= datatype_map.find(type)->second; @@ -4343,7 +4378,7 @@ void smt2_convt::unflatten( { if(use_datatypes) { - assert(datatype_map.find(type) != datatype_map.end()); + assert(datatype_map.find(type)!=datatype_map.end()); const std::string smt_typename= datatype_map.find(type)->second; @@ -4395,7 +4430,7 @@ void smt2_convt::unflatten( { out << ")) "; - assert(datatype_map.find(type) != datatype_map.end()); + assert(datatype_map.find(type)!=datatype_map.end()); const std::string smt_typename= datatype_map.find(type)->second; @@ -4503,7 +4538,8 @@ void smt2_convt::set_to(const exprt &expr, bool value) if(equal_expr.lhs().id()==ID_symbol) { - const irep_idt &identifier=to_symbol_expr(equal_expr.lhs()).get_identifier(); + const irep_idt &identifier= + to_symbol_expr(equal_expr.lhs()).get_identifier(); if(identifier_map.find(identifier)==identifier_map.end()) { @@ -4684,10 +4720,10 @@ void smt2_convt::find_symbols(const exprt &expr) { const exprt &op = expr.op0(); - if (op.type().id() == ID_pointer || - op.type().id() == ID_reference) + if(op.type().id()==ID_pointer || + op.type().id()==ID_reference) { - if (object_sizes.find(expr)==object_sizes.end()) + if(object_sizes.find(expr)==object_sizes.end()) { irep_idt id="object_size."+std::to_string(object_sizes.size()); out << "(declare-fun " << id << " () "; @@ -4757,7 +4793,6 @@ void smt2_convt::find_symbols(const exprt &expr) out << ")\n"; // define-fun } } - } /*******************************************************************\ @@ -4776,7 +4811,7 @@ bool smt2_convt::use_array_theory(const exprt &expr) { const typet &type=ns.follow(expr.type()); assert(type.id()==ID_array); - //const array_typet &array_type=to_array_type(ns.follow(expr.type())); + // const array_typet &array_type=to_array_type(ns.follow(expr.type())); if(use_datatypes) { @@ -4992,188 +5027,189 @@ void smt2_convt::find_symbols_rec( std::set &recstack) { if(type.id()==ID_array) - { - const array_typet &array_type=to_array_type(type); - find_symbols(array_type.size()); - find_symbols_rec(array_type.subtype(), recstack); - } - else if(type.id()==ID_incomplete_array) - { - find_symbols_rec(type.subtype(), recstack); - } - else if(type.id()==ID_complex) - { - find_symbols_rec(type.subtype(), recstack); - - if(use_datatypes && - datatype_map.find(type)==datatype_map.end()) - { - std::string smt_typename = "complex."+std::to_string(datatype_map.size()); - datatype_map[type] = smt_typename; - - out << "(declare-datatypes () ((" << smt_typename << " " - << "(mk-" << smt_typename; - - out << " (" << smt_typename << ".imag "; - convert_type(type.subtype()); - out << ")"; - - out << " (" << smt_typename << ".real "; - convert_type(type.subtype()); - out << ")"; - - out << "))))\n"; - } - } - else if(type.id()==ID_vector) - { - find_symbols_rec(type.subtype(), recstack); - - if(use_datatypes && - datatype_map.find(type)==datatype_map.end()) - { - const vector_typet &vector_type=to_vector_type(type); - - mp_integer size; - if(to_integer(vector_type.size(), size)) - INVALIDEXPR("failed to convert vector size to constant"); - - std::string smt_typename = "vector."+std::to_string(datatype_map.size()); - datatype_map[type] = smt_typename; - - out << "(declare-datatypes () ((" << smt_typename << " " - << "(mk-" << smt_typename; - - for(mp_integer i=0; i!=size; ++i) - { - out << " (" << smt_typename << "." << i << " "; - convert_type(type.subtype()); - out << ")"; - } - - out << "))))\n"; - } - } - else if(type.id()==ID_struct) - { - // Cater for mutually recursive struct types - bool need_decl=false; - if(use_datatypes && - datatype_map.find(type)==datatype_map.end()) - { - std::string smt_typename = "struct."+std::to_string(datatype_map.size()); - datatype_map[type] = smt_typename; - need_decl=true; - } - - const struct_typet::componentst &components= - to_struct_type(type).components(); + { + const array_typet &array_type=to_array_type(type); + find_symbols(array_type.size()); + find_symbols_rec(array_type.subtype(), recstack); + } + else if(type.id()==ID_incomplete_array) + { + find_symbols_rec(type.subtype(), recstack); + } + else if(type.id()==ID_complex) + { + find_symbols_rec(type.subtype(), recstack); + + if(use_datatypes && + datatype_map.find(type)==datatype_map.end()) + { + std::string smt_typename = "complex."+std::to_string(datatype_map.size()); + datatype_map[type] = smt_typename; + + out << "(declare-datatypes () ((" << smt_typename << " " + << "(mk-" << smt_typename; + + out << " (" << smt_typename << ".imag "; + convert_type(type.subtype()); + out << ")"; + + out << " (" << smt_typename << ".real "; + convert_type(type.subtype()); + out << ")"; + + out << "))))\n"; + } + } + else if(type.id()==ID_vector) + { + find_symbols_rec(type.subtype(), recstack); + + if(use_datatypes && + datatype_map.find(type)==datatype_map.end()) + { + const vector_typet &vector_type=to_vector_type(type); + + mp_integer size; + if(to_integer(vector_type.size(), size)) + INVALIDEXPR("failed to convert vector size to constant"); + + std::string smt_typename = "vector."+std::to_string(datatype_map.size()); + datatype_map[type] = smt_typename; + + out << "(declare-datatypes () ((" << smt_typename << " " + << "(mk-" << smt_typename; + + for(mp_integer i=0; i!=size; ++i) + { + out << " (" << smt_typename << "." << i << " "; + convert_type(type.subtype()); + out << ")"; + } + + out << "))))\n"; + } + } + else if(type.id()==ID_struct) + { + // Cater for mutually recursive struct types + bool need_decl=false; + if(use_datatypes && + datatype_map.find(type)==datatype_map.end()) + { + std::string smt_typename = "struct."+std::to_string(datatype_map.size()); + datatype_map[type] = smt_typename; + need_decl=true; + } + + const struct_typet::componentst &components= + to_struct_type(type).components(); for(const auto &component : components) find_symbols_rec(component.type(), recstack); - // Declare the corresponding SMT type if we haven't already. - if(need_decl) - { - std::string smt_typename = datatype_map[type]; - - // We're going to create a datatype named something like `struct.0'. - // It's going to have a single constructor named `mk-struct.0' with an - // argument for each member of the struct. The declaration that - // creates this type looks like: - // - // (declare-datatypes () ((struct.0 (mk-struct.0 - // (struct.0.component1 type1) - // ... - // (struct.0.componentN typeN))))) - out << "(declare-datatypes () ((" << smt_typename << " " - << "(mk-" << smt_typename << " "; - - for(const auto &component : components) - { - out << "(" << smt_typename << "." << component.get_name() - << " "; - convert_type(component.type()); - out << ") "; - } - - out << "))))" << "\n"; - - // Let's also declare convenience functions to update individual members of - // the struct whil we're at it. The functions are named like - // `update-struct.0.component1'. Their declarations look like: - // - // (declare-fun update-struct.0.component1 - // ((s struct.0) ; first arg -- the struct to update - // (v type1)) ; second arg -- the value to update - // struct.0 ; the output type - // (mk-struct.0 ; build the new struct... - // v ; the updated value - // (struct.0.component2 s) ; retain the other members - // ... - // (struct.0.componentN s))) - - for(std::size_t i = 0; i < components.size(); i++) - { - const struct_union_typet::componentt &component = components[i]; - out << "(define-fun update-" << smt_typename << "." - << component.get_name() << " " - << "((s " << smt_typename << ") " - << "(v "; - convert_type(component.type()); - out << ")) " << smt_typename << " " - << "(mk-" << smt_typename - << " "; - - for(std::size_t j = 0; j < components.size(); j++) - { - if(j==i) - out << "v "; - else - { - out << "(" << smt_typename << "." + // Declare the corresponding SMT type if we haven't already. + if(need_decl) + { + std::string smt_typename = datatype_map[type]; + + // We're going to create a datatype named something like `struct.0'. + // It's going to have a single constructor named `mk-struct.0' with an + // argument for each member of the struct. The declaration that + // creates this type looks like: + // + // (declare-datatypes () ((struct.0 (mk-struct.0 + // (struct.0.component1 type1) + // ... + // (struct.0.componentN typeN))))) + out << "(declare-datatypes () ((" << smt_typename << " " + << "(mk-" << smt_typename << " "; + + for(const auto &component : components) + { + out << "(" << smt_typename << "." << component.get_name() + << " "; + convert_type(component.type()); + out << ") "; + } + + out << "))))" << "\n"; + + // Let's also declare convenience functions to update individual + // members of the struct whil we're at it. The functions are + // named like `update-struct.0.component1'. Their declarations + // look like: + // + // (declare-fun update-struct.0.component1 + // ((s struct.0) ; first arg -- the struct to update + // (v type1)) ; second arg -- the value to update + // struct.0 ; the output type + // (mk-struct.0 ; build the new struct... + // v ; the updated value + // (struct.0.component2 s) ; retain the other members + // ... + // (struct.0.componentN s))) + + for(std::size_t i = 0; i < components.size(); i++) + { + const struct_union_typet::componentt &component = components[i]; + out << "(define-fun update-" << smt_typename << "." + << component.get_name() << " " + << "((s " << smt_typename << ") " + << "(v "; + convert_type(component.type()); + out << ")) " << smt_typename << " " + << "(mk-" << smt_typename + << " "; + + for(std::size_t j = 0; j < components.size(); j++) + { + if(j==i) + out << "v "; + else + { + out << "(" << smt_typename << "." << components[j].get_name() << " s) "; - } - } + } + } - out << "))" << "\n"; - } + out << "))" << "\n"; + } - out << "\n"; - } - } - else if(type.id()==ID_union) - { - const union_typet::componentst &components= - to_union_type(type).components(); + out << "\n"; + } + } + else if(type.id()==ID_union) + { + const union_typet::componentst &components= + to_union_type(type).components(); - for(const auto &component : components) - find_symbols_rec(component.type(), recstack); - } - else if(type.id()==ID_code) - { - const code_typet::parameterst ¶meters= - to_code_type(type).parameters(); - for(const auto ¶m : parameters) - find_symbols_rec(param.type(), recstack); - - find_symbols_rec(to_code_type(type).return_type(), recstack); - } - else if(type.id()==ID_pointer) - { - find_symbols_rec(type.subtype(), recstack); - } - else if(type.id()==ID_symbol) - { - const symbol_typet &st=to_symbol_type(type); - const irep_idt &id=st.get_identifier(); - - if(recstack.find(id)==recstack.end()) - { - recstack.insert(id); - find_symbols_rec(ns.follow(type), recstack); - } - } + for(const auto &component : components) + find_symbols_rec(component.type(), recstack); + } + else if(type.id()==ID_code) + { + const code_typet::parameterst ¶meters= + to_code_type(type).parameters(); + for(const auto ¶m : parameters) + find_symbols_rec(param.type(), recstack); + + find_symbols_rec(to_code_type(type).return_type(), recstack); + } + else if(type.id()==ID_pointer) + { + find_symbols_rec(type.subtype(), recstack); + } + else if(type.id()==ID_symbol) + { + const symbol_typet &st=to_symbol_type(type); + const irep_idt &id=st.get_identifier(); + + if(recstack.find(id)==recstack.end()) + { + recstack.insert(id); + find_symbols_rec(ns.follow(type), recstack); + } + } } /*******************************************************************\ @@ -5216,13 +5252,13 @@ exprt smt2_convt::letify_rec( const seen_expressionst &map, unsigned i) { - if(i >= let_order.size()) + if(i>=let_order.size()) return substitute_let(expr, map); exprt current=let_order[i]; - assert(map.find(current) != map.end()); + assert(map.find(current)!=map.end()); - if (map.find(current)->second.first < LET_COUNT) + if(map.find(current)->second.first let_count_id; typedef std::unordered_map seen_expressionst; unsigned let_id_count; - const static unsigned LET_COUNT = 2; + const static unsigned LET_COUNT=2; - class let_visitort : public expr_visitort + class let_visitort:public expr_visitort { const seen_expressionst &let_map; @@ -177,13 +187,12 @@ class smt2_convt:public prop_convt void operator()(exprt &expr) { - seen_expressionst::const_iterator it = let_map.find(expr); - if (it != let_map.end() && - it->second.first >= LET_COUNT) + seen_expressionst::const_iterator it=let_map.find(expr); + if(it!=let_map.end() && + it->second.first>=LET_COUNT) { - symbol_exprt symb = it->second.second; - expr = symb; - return; + symbol_exprt symb=it->second.second; + expr=symb; } } }; diff --git a/src/solvers/smt2/smt2irep.cpp b/src/solvers/smt2/smt2irep.cpp index 3db2dbd2200..97029db66c4 100644 --- a/src/solvers/smt2/smt2irep.cpp +++ b/src/solvers/smt2/smt2irep.cpp @@ -49,13 +49,15 @@ class smt2irept:public smt2_parsert symbol(); // we don't distinguish } - virtual void open_expression() // '(' + // '(' + virtual void open_expression() { // produce sub-irep stack.push(irept()); } - virtual void close_expression() // ')' + // ')' + virtual void close_expression() { // done with sub-irep assert(!stack.empty()); // unexpected ) diff --git a/src/util/bv_arithmetic.cpp b/src/util/bv_arithmetic.cpp index 6478e4ac2f3..6be9ea6320b 100644 --- a/src/util/bv_arithmetic.cpp +++ b/src/util/bv_arithmetic.cpp @@ -219,7 +219,7 @@ Function: operator /= \*******************************************************************/ -bv_arithmetict &bv_arithmetict::operator /= (const bv_arithmetict &other) +bv_arithmetict &bv_arithmetict::operator/=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -243,7 +243,7 @@ Function: operator *= \*******************************************************************/ -bv_arithmetict &bv_arithmetict::operator *= (const bv_arithmetict &other) +bv_arithmetict &bv_arithmetict::operator*=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -265,7 +265,7 @@ Function: operator += \*******************************************************************/ -bv_arithmetict &bv_arithmetict::operator += (const bv_arithmetict &other) +bv_arithmetict &bv_arithmetict::operator+=(const bv_arithmetict &other) { assert(other.spec==spec); @@ -309,7 +309,7 @@ Function: operator %= \*******************************************************************/ -bv_arithmetict &bv_arithmetict::operator %= (const bv_arithmetict &other) +bv_arithmetict &bv_arithmetict::operator%=(const bv_arithmetict &other) { assert(other.spec==spec); diff --git a/src/util/bv_arithmetic.h b/src/util/bv_arithmetic.h index b555bfaacfd..a8c951ad546 100644 --- a/src/util/bv_arithmetic.h +++ b/src/util/bv_arithmetic.h @@ -93,11 +93,11 @@ class bv_arithmetict exprt to_expr() const; void from_expr(const exprt &expr); - bv_arithmetict &operator /= (const bv_arithmetict &other); - bv_arithmetict &operator *= (const bv_arithmetict &other); - bv_arithmetict &operator += (const bv_arithmetict &other); - bv_arithmetict &operator -= (const bv_arithmetict &other); - bv_arithmetict &operator %= (const bv_arithmetict &other); + bv_arithmetict &operator/=(const bv_arithmetict &other); + bv_arithmetict &operator*=(const bv_arithmetict &other); + bv_arithmetict &operator+=(const bv_arithmetict &other); + bv_arithmetict &operator-=(const bv_arithmetict &other); + bv_arithmetict &operator%=(const bv_arithmetict &other); bool operator<(const bv_arithmetict &other); bool operator<=(const bv_arithmetict &other); diff --git a/src/util/byte_operators.h b/src/util/byte_operators.h index 728a821a28b..d9a5010b160 100644 --- a/src/util/byte_operators.h +++ b/src/util/byte_operators.h @@ -73,7 +73,6 @@ class byte_extract_little_endian_exprt:public byte_extract_exprt byte_extract_exprt(ID_byte_extract_little_endian) { } - }; inline const byte_extract_little_endian_exprt @@ -181,7 +180,6 @@ class byte_update_little_endian_exprt:public byte_update_exprt byte_update_exprt(ID_byte_update_little_endian, _op, _offset, _value) { } - }; inline const byte_update_little_endian_exprt @@ -213,7 +211,6 @@ class byte_update_big_endian_exprt:public byte_update_exprt byte_update_exprt(ID_byte_update_big_endian, _op, _offset, _value) { } - }; inline const byte_update_big_endian_exprt diff --git a/src/util/expr.cpp b/src/util/expr.cpp index 436011e5469..2d512fe8645 100644 --- a/src/util/expr.cpp +++ b/src/util/expr.cpp @@ -140,8 +140,10 @@ Function: exprt::copy_to_operands \*******************************************************************/ -void exprt::copy_to_operands(const exprt &e1, const exprt &e2, - const exprt &e3) +void exprt::copy_to_operands( + const exprt &e1, + const exprt &e2, + const exprt &e3) { operandst &op=operands(); #ifndef USE_LIST diff --git a/src/util/expr.h b/src/util/expr.h index b3e3beee9b4..858ae9f0e46 100644 --- a/src/util/expr.h +++ b/src/util/expr.h @@ -50,11 +50,17 @@ class exprt:public irept // constructors inline exprt() { } inline explicit exprt(const irep_idt &_id):irept(_id) { } - inline exprt(const irep_idt &_id, const typet &_type):irept(_id) { add(ID_type, _type); } + inline exprt(const irep_idt &_id, const typet &_type):irept(_id) + { + add(ID_type, _type); + } // returns the type of the expression inline typet &type() { return static_cast(add(ID_type)); } - inline const typet &type() const { return static_cast(find(ID_type)); } + inline const typet &type() const + { + return static_cast(find(ID_type)); + } // returns true if there is at least one operand inline bool has_operands() const @@ -101,12 +107,14 @@ class exprt:public irept inline void reserve_operands(operandst::size_type n) { operands().reserve(n) ; } - void move_to_operands(exprt &expr); // destroys expr - void move_to_operands(exprt &e1, exprt &e2); // destroys e1, e2 - void move_to_operands(exprt &e1, exprt &e2, exprt &e3); // destroys e1, e2, e3 - void copy_to_operands(const exprt &expr); // does not destroy expr - void copy_to_operands(const exprt &e1, const exprt &e2); // does not destroy expr - void copy_to_operands(const exprt &e1, const exprt &e2, const exprt &e3); // does not destroy expr + // destroys expr, e1, e2, e3 + void move_to_operands(exprt &expr); + void move_to_operands(exprt &e1, exprt &e2); + void move_to_operands(exprt &e1, exprt &e2, exprt &e3); + // does not destroy expr, e1, e2, e3 + void copy_to_operands(const exprt &expr); + void copy_to_operands(const exprt &e1, const exprt &e2); + void copy_to_operands(const exprt &e1, const exprt &e2, const exprt &e3); // the following are deprecated -- use constructors instead void make_typecast(const typet &_type); diff --git a/src/util/expr_util.cpp b/src/util/expr_util.cpp index 09f3ef2a7c6..32159c5658f 100644 --- a/src/util/expr_util.cpp +++ b/src/util/expr_util.cpp @@ -102,7 +102,7 @@ with_exprt make_with_expr(const update_exprt &src) } else if(it->id()==ID_member_designator) { - //irep_idt component_name= + // irep_idt component_name= // to_member_designator(*it).get_component_name(); } else @@ -217,7 +217,7 @@ Function: lift_if if_exprt lift_if(const exprt &src, std::size_t operand_number) { - assert(operand_number < src.operands().size()); + assert(operand_numberd_name).c_str()); + remove((path+"/"+ent->d_name).c_str()); closedir(dir); } @@ -128,8 +128,9 @@ Function: concat_dir_file \*******************************************************************/ -std::string concat_dir_file(const std::string &directory, - const std::string &file_name) +std::string concat_dir_file( + const std::string &directory, + const std::string &file_name) { #ifdef _WIN32 return (file_name.size()>1 && diff --git a/src/util/fixedbv.cpp b/src/util/fixedbv.cpp index 3162b8719d0..675164f1d26 100644 --- a/src/util/fixedbv.cpp +++ b/src/util/fixedbv.cpp @@ -153,7 +153,10 @@ void fixedbvt::round(const fixedbv_spect &dest_spec) if(rem*2>=p) { - if(v<0) --div; else ++div; + if(v<0) + --div; + else + ++div; } result=div; diff --git a/src/util/fixedbv.h b/src/util/fixedbv.h index ec2d36679f8..ce6a6643962 100644 --- a/src/util/fixedbv.h +++ b/src/util/fixedbv.h @@ -61,7 +61,8 @@ class fixedbvt std::string format(const format_spect &format_spec) const; - bool operator == (int i) const; + bool operator==(int i) const; + bool is_zero() const { return v==0; @@ -69,10 +70,10 @@ class fixedbvt void negate(); - fixedbvt &operator /= (const fixedbvt &other); - fixedbvt &operator *= (const fixedbvt &other); - fixedbvt &operator += (const fixedbvt &other); - fixedbvt &operator -= (const fixedbvt &other); + fixedbvt &operator/=(const fixedbvt &other); + fixedbvt &operator*=(const fixedbvt &other); + fixedbvt &operator+=(const fixedbvt &other); + fixedbvt &operator-=(const fixedbvt &other); bool operator<(const fixedbvt &other) const { return v