namespace
{
+ class die_check_registrar
+ : public check_registrar_T<die_check_item>
+ {
+ public:
+ friend class dwarflint;
+ void run (checkstack &stack, dwarflint &lint);
+
+ static die_check_registrar *
+ inst ()
+ {
+ static die_check_registrar inst;
+ return &inst;
+ }
+ };
+
reg<check_die_tree> reg;
}
+void
+check_die_tree::register_check (die_check_item *check)
+{
+ die_check_registrar::inst ()->push_back (check);
+}
+
class die_check_context
: protected std::vector<die_check *>
{
check_die_tree::check_die_tree (checkstack &stack, dwarflint &lint)
: highlevel_check<check_die_tree> (stack, lint)
{
- die_check_context ctx (this, descriptor (), lint, *dwarflint::die_registrar ());
+ die_check_context ctx (this, descriptor (), lint,
+ *die_check_registrar::inst ());
for (all_dies_iterator<dwarf> it = all_dies_iterator<dwarf> (dw);
it != all_dies_iterator<dwarf> (); ++it)
#include <c++/dwarf>
+struct die_check_item
+{
+ virtual checkdescriptor const *descriptor () const = 0;
+ virtual ~die_check_item () {}
+ virtual die_check *create (highlevel_check_i *check,
+ checkstack &stack, dwarflint &lint) = 0;
+};
+
/// Top-level check that iterates over all DIEs in a file and
/// dispatches per-DIE checks on each one. Per-DIE checks are written
/// as subclasses of die_check (see below) and registered using
: public highlevel_check<check_die_tree>
{
public:
+ static void register_check (die_check_item *check);
+
static checkdescriptor const *descriptor ()
{
static checkdescriptor cd
{
reg_die_check ()
{
- dwarflint::die_registrar ()->push_back (this);
+ check_die_tree::register_check (this);
}
virtual die_check *create (highlevel_check_i *check,
return &inst;
}
-die_check_registrar *
-dwarflint::die_registrar ()
-{
- static die_check_registrar inst;
- return &inst;
-}
-
namespace
{
template <class T>
void run (dwarflint &lint);
};
-// Classes for simplified single-die passes.
-struct die_check_item
-{
- virtual checkdescriptor const *descriptor () const = 0;
- virtual ~die_check_item () {}
- virtual die_check *create (highlevel_check_i *check,
- checkstack &stack, dwarflint &lint) = 0;
-};
-
-class die_check_registrar
- : public check_registrar_T<die_check_item>
-{
-public:
- friend class dwarflint;
- void run (checkstack &stack, dwarflint &lint);
-};
-
-
class checkstack
: public std::vector <checkdescriptor const *>
{};
}
static main_check_registrar *main_registrar ();
- static die_check_registrar *die_registrar ();
static void list_checks ();
};