* iface/gspn/gspn.cc, src/ltlvisit/basicreduce.cc,

src/ltlvisit/destroy.cc, src/ltlvisit/dotty.cc,
src/ltlvisit/dump.cc, src/ltlvisit/length.cc,
src/ltlvisit/nenoform.cc, src/ltlvisit/reduce.cc,
src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc,
src/tgba/formula2bdd.cc, src/tgba/tgbabddconcreteproduct.cc,
src/tgba/tgbatba.cc, src/tgbaalgos/dotty.cc,
src/tgbaalgos/dupexp.cc, src/tgbaalgos/lbtt.cc,
src/tgbaalgos/ltl2tgba_lacim.cc, src/tgbaalgos/neverclaim.cc,
src/tgbaalgos/save.cc, src/tgbaalgos/stats.cc,
src/tgbaalgos/gtec/nsheap.cc, src/tgbaalgos/gtec/nsheap.hh:
Declare private classes and helper function in anonymous namespaces.
* HACKING, src/sanity/style.test: Document and check this.
Also check for trailing { after namespace or class.
* src/ltlast/predecl.hh, src/ltlast/visitor.hh,
src/tgba/tgbareduc.hh: Fix trailing {.
This commit is contained in:
Alexandre Duret-Lutz 2004-10-18 13:56:31 +00:00
parent 5176caf4d2
commit 7d27fd3796
28 changed files with 3128 additions and 3025 deletions

View file

@ -1,3 +1,22 @@
2004-10-18 Alexandre Duret-Lutz <adl@src.lip6.fr>
* iface/gspn/gspn.cc, src/ltlvisit/basicreduce.cc,
src/ltlvisit/destroy.cc, src/ltlvisit/dotty.cc,
src/ltlvisit/dump.cc, src/ltlvisit/length.cc,
src/ltlvisit/nenoform.cc, src/ltlvisit/reduce.cc,
src/ltlvisit/syntimpl.cc, src/ltlvisit/tostring.cc,
src/tgba/formula2bdd.cc, src/tgba/tgbabddconcreteproduct.cc,
src/tgba/tgbatba.cc, src/tgbaalgos/dotty.cc,
src/tgbaalgos/dupexp.cc, src/tgbaalgos/lbtt.cc,
src/tgbaalgos/ltl2tgba_lacim.cc, src/tgbaalgos/neverclaim.cc,
src/tgbaalgos/save.cc, src/tgbaalgos/stats.cc,
src/tgbaalgos/gtec/nsheap.cc, src/tgbaalgos/gtec/nsheap.hh:
Declare private classes and helper function in anonymous namespaces.
* HACKING, src/sanity/style.test: Document and check this.
Also check for trailing { after namespace or class.
* src/ltlast/predecl.hh, src/ltlast/visitor.hh,
src/tgba/tgbareduc.hh: Fix trailing {.
2004-10-15 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbaalgos/gtec/ce.cc: Reinstall change from 2004-09-21.

View file

@ -249,3 +249,9 @@ Other style recommandations
Prefer <iosfwd> when predeclarations are sufficient, and then
use for instance use just <ostream> in the corresponding .cc file.
(A plain <iostream> is needed when using std::cout, std::cerr, etc.)
* Always declare helper functions and other local class definitions
(used in a single .cc files) in anonymous namespaces. (The risk
otherwise is to declare two classes with the same name: the linker
will ignore one of the two silently. The resulting bugs are often
difficult to understand.)

View file

@ -27,6 +27,8 @@
namespace spot
{
namespace
{
// state_gspn
//////////////////////////////////////////////////////////////////////
@ -461,6 +463,8 @@ namespace spot
return bddtrue;
}
} // anonymous
// gspn_interface
//////////////////////////////////////////////////////////////////////

View file

@ -29,8 +29,10 @@
#ifndef SPOT_LTLAST_PREDECL_HH
# define SPOT_LTLAST_PREDECL_HH
namespace spot {
namespace ltl {
namespace spot
{
namespace ltl
{
struct visitor;
struct const_visitor;

View file

@ -26,9 +26,10 @@
#include "predecl.hh"
namespace spot {
namespace ltl {
namespace spot
{
namespace ltl
{
/// \brief Formula visitor that can modify the formula.
///
/// Writing visitors is the prefered way

View file

@ -31,7 +31,6 @@ namespace spot
{
namespace ltl
{
bool
is_GF(const formula* f)
{
@ -58,9 +57,9 @@ namespace spot
return false;
}
formula* basic_reduce(const formula* f);
class basic_reduce_visitor : public visitor
namespace
{
class basic_reduce_visitor: public visitor
{
public:
@ -333,7 +332,8 @@ namespace spot
// (a U b) & (c U b) = (a & c) U b
formula* ftmp = dynamic_cast<binop*>(*i)->second();
multop::vec* tmpUright = new multop::vec;
for (multop::vec::iterator j = i; j != res->end(); j++)
for (multop::vec::iterator j = i; j != res->end();
j++)
{
if (!*j)
continue;
@ -363,7 +363,8 @@ namespace spot
// (a R b) & (a R c) = a R (b & c)
formula* ftmp = dynamic_cast<binop*>(*i)->first();
multop::vec* tmpRright = new multop::vec;
for (multop::vec::iterator j = i; j != res->end(); j++)
for (multop::vec::iterator j = i; j != res->end();
j++)
{
if (!*j)
continue;
@ -442,7 +443,8 @@ namespace spot
// (a U b) | (a U c) = a U (b | c)
formula* ftmp = bo->first();
multop::vec* tmpUright = new multop::vec;
for (multop::vec::iterator j = i; j != res->end(); j++)
for (multop::vec::iterator j = i; j != res->end();
j++)
{
if (!*j)
continue;
@ -470,7 +472,8 @@ namespace spot
// (a R b) | (c R b) = (a | c) R b
formula* ftmp = dynamic_cast<binop*>(*i)->second();
multop::vec* tmpRright = new multop::vec;
for (multop::vec::iterator j = i; j != res->end(); j++)
for (multop::vec::iterator j = i; j != res->end();
j++)
{
if (!*j)
continue;
@ -579,6 +582,7 @@ namespace spot
protected:
formula* result_;
};
}
formula*
basic_reduce(const formula* f)

View file

@ -1,4 +1,4 @@
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
@ -25,8 +25,9 @@ namespace spot
{
namespace ltl
{
class destroy_visitor : public postfix_visitor
namespace
{
class destroy_visitor: public postfix_visitor
{
public:
virtual void
@ -35,6 +36,7 @@ namespace spot
formula::unref(c);
}
};
}
void
destroy(const formula* f)

View file

@ -29,8 +29,9 @@ namespace spot
{
namespace ltl
{
class dotty_visitor : public const_visitor
namespace
{
class dotty_visitor: public const_visitor
{
public:
typedef Sgi::hash_map<const formula*, int, ptr_hash<formula> > map;
@ -122,6 +123,7 @@ namespace spot
return true;
}
};
}
std::ostream&
dotty(std::ostream& os, const formula* f)

View file

@ -28,8 +28,9 @@ namespace spot
{
namespace ltl
{
class dump_visitor : public const_visitor
namespace
{
class dump_visitor: public const_visitor
{
public:
dump_visitor(std::ostream& os)
@ -88,6 +89,7 @@ namespace spot
private:
std::ostream& os_;
};
}
std::ostream&
dump(std::ostream& os, const formula* f)

View file

@ -27,8 +27,9 @@ namespace spot
{
namespace ltl
{
class length_visitor : public const_visitor
namespace
{
class length_visitor: public const_visitor
{
public:
@ -83,6 +84,7 @@ namespace spot
protected:
int result_; // size of the formula
};
}
int
length(const formula* f)

View file

@ -27,8 +27,9 @@ namespace spot
{
namespace ltl
{
class negative_normal_form_visitor : public visitor
namespace
{
class negative_normal_form_visitor: public visitor
{
public:
negative_normal_form_visitor(bool negated)
@ -93,11 +94,13 @@ namespace spot
return;
case unop::F:
/* !Fa == G!a */
result_ = unop::instance(negated_ ? unop::G : unop::F, recurse(f));
result_ = unop::instance(negated_ ? unop::G : unop::F,
recurse(f));
return;
case unop::G:
/* !Ga == F!a */
result_ = unop::instance(negated_ ? unop::F : unop::G, recurse(f));
result_ = unop::instance(negated_ ? unop::F : unop::G,
recurse(f));
return;
}
/* Unreachable code. */
@ -187,6 +190,7 @@ namespace spot
formula* result_;
bool negated_;
};
}
formula*
negative_normal_form(const formula* f, bool negated)

View file

@ -34,8 +34,9 @@ namespace spot
{
namespace ltl
{
class reduce_visitor : public visitor
namespace
{
class reduce_visitor: public visitor
{
public:
@ -287,6 +288,8 @@ namespace spot
int opt_;
};
} // anonymous
formula*
reduce(const formula* f, int opt)
{

View file

@ -31,9 +31,11 @@
namespace spot
{
namespace ltl
{
namespace
{
class eventual_universal_visitor : public const_visitor
class eventual_universal_visitor: public const_visitor
{
public:
@ -162,26 +164,10 @@ namespace spot
};
bool
is_eventual(const formula* f)
{
eventual_universal_visitor v;
const_cast<formula*>(f)->accept(v);
return v.is_eventual();
}
bool
is_universal(const formula* f)
{
eventual_universal_visitor v;
const_cast<formula*>(f)->accept(v);
return v.is_universal();
}
/////////////////////////////////////////////////////////////////////////
class inf_right_recurse_visitor : public const_visitor
class inf_right_recurse_visitor: public const_visitor
{
public:
@ -332,7 +318,7 @@ namespace spot
/////////////////////////////////////////////////////////////////////////
class inf_left_recurse_visitor : public const_visitor
class inf_left_recurse_visitor: public const_visitor
{
public:
@ -528,6 +514,24 @@ namespace spot
const formula* f;
};
} // anonymous
bool
is_eventual(const formula* f)
{
eventual_universal_visitor v;
const_cast<formula*>(f)->accept(v);
return v.is_eventual();
}
bool
is_universal(const formula* f)
{
eventual_universal_visitor v;
const_cast<formula*>(f)->accept(v);
return v.is_universal();
}
// This is called by syntactic_implication() after the
// formulae have been normalized.
bool

View file

@ -32,7 +32,8 @@ namespace spot
{
namespace ltl
{
namespace
{
static bool
is_bare_word(const char* str)
{
@ -54,7 +55,7 @@ namespace spot
return true;
}
class to_string_visitor : public const_visitor
class to_string_visitor: public const_visitor
{
public:
to_string_visitor(std::ostream& os)
@ -184,6 +185,7 @@ namespace spot
std::ostream& os_;
bool top_level_;
};
}
std::ostream&
to_string(const formula* f, std::ostream& os)

View file

@ -72,6 +72,12 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do
grep '[ ]switch (.*).*{' $tmp &&
diag 'Opening { should be on its own line.'
grep 'namespace .*{' $tmp &&
diag 'Opening { should be on its own line.'
grep 'class .*{' $tmp &&
diag 'Opening { should be on its own line.'
grep '( ' $tmp &&
diag 'No space after opening (.'
@ -137,6 +143,15 @@ for dir in "${INCDIR-..}" "${INCDIR-..}"/../iface; do
diag 'Avoid <iostream> in headers, better use <iosfwd>.'
fi
;;
*.cc)
if grep 'namespace$' $tmp >/dev/null; then
:
else
# We only check classes, but the rule should apply to functions too
grep '^[ ]*class[ ]' $tmp &&
diag 'Private definitions must be in anonymous namespace.'
fi
;;
esac

View file

@ -1,4 +1,4 @@
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
@ -30,7 +30,9 @@ namespace spot
{
using namespace ltl;
class formula_to_bdd_visitor : public ltl::const_visitor
namespace
{
class formula_to_bdd_visitor: public ltl::const_visitor
{
public:
formula_to_bdd_visitor(bdd_dict* d, void* owner)
@ -150,14 +152,6 @@ namespace spot
bdd res_;
};
bdd
formula_to_bdd(const formula* f, bdd_dict* d, void* for_me)
{
formula_to_bdd_visitor v(d, for_me);
f->accept(v);
return v.result();
}
// Convert a BDD which is known to be a conjonction into a formula.
static ltl::formula*
conj_to_formula(bdd b, const bdd_dict* d)
@ -190,6 +184,16 @@ namespace spot
return multop::instance(multop::And, v);
}
} // anonymous
bdd
formula_to_bdd(const formula* f, bdd_dict* d, void* for_me)
{
formula_to_bdd_visitor v(d, for_me);
f->accept(v);
return v.result();
}
const formula*
bdd_to_formula(bdd f, const bdd_dict* d)
{

View file

@ -1,4 +1,4 @@
// Copyright (C) 2003 Laboratoire d'Informatique de Paris 6 (LIP6),
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
@ -24,6 +24,8 @@
namespace spot
{
namespace
{
/// \brief Helper class for product().
///
/// As both automata are encoded using BDD, we just have
@ -73,6 +75,7 @@ namespace spot
tgba_bdd_core_data data_;
bdd init_;
};
}
tgba_bdd_concrete*
product(const tgba_bdd_concrete* left, const tgba_bdd_concrete* right)

View file

@ -39,8 +39,12 @@ namespace spot
typedef Sgi::vector<state_couple*> delayed_simulation_relation;
*/
class direct_simulation_relation : public simulation_relation{};
class delayed_simulation_relation : public simulation_relation{};
class direct_simulation_relation: public simulation_relation
{
};
class delayed_simulation_relation: public simulation_relation
{
};
class tgba_reduc: public tgba_explicit,

View file

@ -26,13 +26,14 @@
namespace spot
{
namespace
{
/// \brief A state for spot::tgba_tba_proxy.
///
/// This state is in fact a pair of state: the state from the tgba
/// automaton, and a state of the "counter" (we use a pointer
/// to the position in the cycle_acc_ list).
class state_tba_proxy : public state
class state_tba_proxy: public state
{
typedef tgba_tba_proxy::cycle_list::const_iterator iterator;
public:
@ -104,7 +105,8 @@ namespace spot
};
/// \brief Iterate over the successors of tgba_tba_proxy computed on the fly.
/// \brief Iterate over the successors of tgba_tba_proxy computed
/// on the fly.
class tgba_tba_proxy_succ_iterator: public tgba_succ_iterator
{
typedef tgba_tba_proxy::cycle_list list;
@ -191,6 +193,7 @@ namespace spot
const bdd the_acceptance_cond_;
};
} // anonymous
tgba_tba_proxy::tgba_tba_proxy(const tgba* a)
: a_(a)

View file

@ -28,7 +28,8 @@
namespace spot
{
namespace
{
class dotty_bfs : public tgba_reachable_iterator_breadth_first
{
public:
@ -73,6 +74,7 @@ namespace spot
private:
std::ostream& os_;
};
}
std::ostream&
dotty_reachable(std::ostream& os, const tgba* g)

View file

@ -25,8 +25,10 @@
#include <map>
#include "reachiter.hh"
namespace spot {
namespace spot
{
namespace
{
template <class T>
class dupexp_iter: public T
{
@ -93,6 +95,8 @@ namespace spot {
std::map<int, std::string> name_;
};
} // anonymous
tgba_explicit*
tgba_dupexp_bfs(const tgba* aut)
{

View file

@ -23,7 +23,9 @@
namespace spot
{
class numbered_state_heap_hash_map_const_iterator :
namespace
{
class numbered_state_heap_hash_map_const_iterator:
public numbered_state_heap_const_iterator
{
public:
@ -71,6 +73,7 @@ namespace spot
numbered_state_heap_hash_map::hash_type::const_iterator i;
const numbered_state_heap_hash_map::hash_type& h;
};
} // anonymous
numbered_state_heap_hash_map::~numbered_state_heap_hash_map()
{

View file

@ -119,12 +119,11 @@ namespace spot
virtual int size() const;
virtual numbered_state_heap_const_iterator* iterator() const;
protected:
typedef Sgi::hash_map<const state*, int,
state_ptr_hash, state_ptr_equal> hash_type;
protected:
hash_type h; ///< Map of visited states.
friend class numbered_state_heap_hash_map_const_iterator;
};
/// \brief Factory for numbered_state_heap_hash_map.

View file

@ -30,6 +30,8 @@
namespace spot
{
namespace
{
// At some point we'll need to print an acceptance set into LBTT's
// format. LBTT expects numbered acceptance sets, so first we'll
// number each acceptance condition, and latter when we have to print
@ -153,6 +155,7 @@ namespace spot
acceptance_cond_splitter acs_;
};
} // anonymous
std::ostream&
lbtt_reachable(std::ostream& os, const tgba* g)
@ -161,6 +164,4 @@ namespace spot
b.run();
return os;
}
}

View file

@ -31,6 +31,8 @@
namespace spot
{
namespace
{
using namespace ltl;
/// \brief Recursively translate a formula into a BDD.
@ -250,6 +252,7 @@ namespace spot
tgba_bdd_concrete_factory& fact_;
bool root_;
};
} // anonymous
tgba_bdd_concrete*
ltl_to_tgba_lacim(const ltl::formula* f, bdd_dict* dict)

View file

@ -32,7 +32,8 @@
namespace spot
{
namespace
{
class never_claim_bfs : public tgba_reachable_iterator_breadth_first
{
public:
@ -179,6 +180,7 @@ namespace spot
bool fi_needed_;
state* init_;
};
} // anonymous
std::ostream&
never_claim_reachable(std::ostream& os, const tgba_tba_proxy* g,

View file

@ -28,8 +28,9 @@
namespace spot
{
class save_bfs : public tgba_reachable_iterator_breadth_first
namespace
{
class save_bfs: public tgba_reachable_iterator_breadth_first
{
public:
save_bfs(const tgba* a, std::ostream& os)
@ -93,7 +94,7 @@ namespace spot
return os_;
}
};
}
std::ostream&
tgba_save_reachable(std::ostream& os, const tgba* g)

View file

@ -25,8 +25,9 @@
namespace spot
{
class stats_bfs : public tgba_reachable_iterator_breadth_first
namespace
{
class stats_bfs: public tgba_reachable_iterator_breadth_first
{
public:
stats_bfs(const tgba* a, tgba_statistics& s)
@ -49,6 +50,7 @@ namespace spot
private:
tgba_statistics& s_;
};
} // anonymous
tgba_statistics
stats_reachable(const tgba* g)