From: Petr Machata Date: Wed, 6 Apr 2011 11:14:10 +0000 (+0200) Subject: dwarflint: Move DIE check registrar away from the class dwarflint X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdde5f64e390846e3b6e0d0a0633ed6e7c3fa94b;p=thirdparty%2Felfutils.git dwarflint: Move DIE check registrar away from the class dwarflint --- diff --git a/dwarflint/check_die_tree.cc b/dwarflint/check_die_tree.cc index d7f0786c3..14b2cf4e5 100644 --- a/dwarflint/check_die_tree.cc +++ b/dwarflint/check_die_tree.cc @@ -31,9 +31,30 @@ using namespace elfutils; namespace { + class die_check_registrar + : public check_registrar_T + { + public: + friend class dwarflint; + void run (checkstack &stack, dwarflint &lint); + + static die_check_registrar * + inst () + { + static die_check_registrar inst; + return &inst; + } + }; + reg 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 { @@ -127,7 +148,8 @@ public: check_die_tree::check_die_tree (checkstack &stack, dwarflint &lint) : highlevel_check (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 it = all_dies_iterator (dw); it != all_dies_iterator (); ++it) diff --git a/dwarflint/check_die_tree.hh b/dwarflint/check_die_tree.hh index 7f9a4ec04..89c7e40f8 100644 --- a/dwarflint/check_die_tree.hh +++ b/dwarflint/check_die_tree.hh @@ -32,6 +32,14 @@ #include +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 @@ -40,6 +48,8 @@ class check_die_tree : public highlevel_check { public: + static void register_check (die_check_item *check); + static checkdescriptor const *descriptor () { static checkdescriptor cd @@ -66,7 +76,7 @@ struct reg_die_check { reg_die_check () { - dwarflint::die_registrar ()->push_back (this); + check_die_tree::register_check (this); } virtual die_check *create (highlevel_check_i *check, diff --git a/dwarflint/dwarflint.cc b/dwarflint/dwarflint.cc index 2f30415f0..86468d907 100644 --- a/dwarflint/dwarflint.cc +++ b/dwarflint/dwarflint.cc @@ -113,13 +113,6 @@ dwarflint::main_registrar () return &inst; } -die_check_registrar * -dwarflint::die_registrar () -{ - static die_check_registrar inst; - return &inst; -} - namespace { template diff --git a/dwarflint/dwarflint.hh b/dwarflint/dwarflint.hh index 199ed7ea6..fdb4443ab 100644 --- a/dwarflint/dwarflint.hh +++ b/dwarflint/dwarflint.hh @@ -55,24 +55,6 @@ public: 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 -{ -public: - friend class dwarflint; - void run (checkstack &stack, dwarflint &lint); -}; - - class checkstack : public std::vector {}; @@ -155,7 +137,6 @@ public: } static main_check_registrar *main_registrar (); - static die_check_registrar *die_registrar (); static void list_checks (); };