]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Move DIE check registrar away from the class dwarflint
authorPetr Machata <pmachata@redhat.com>
Wed, 6 Apr 2011 11:14:10 +0000 (13:14 +0200)
committerPetr Machata <pmachata@redhat.com>
Wed, 6 Apr 2011 11:14:10 +0000 (13:14 +0200)
dwarflint/check_die_tree.cc
dwarflint/check_die_tree.hh
dwarflint/dwarflint.cc
dwarflint/dwarflint.hh

index d7f0786c3d5d8e7319668fb47d9fabfb3b6b50ca..14b2cf4e5e10c06347086eb1ca64610d6621ae71 100644 (file)
@@ -31,9 +31,30 @@ using namespace elfutils;
 
 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 *>
 {
@@ -127,7 +148,8 @@ public:
 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)
index 7f9a4ec048af181d6090468d51181b23bd3de360..89c7e40f8b26f9c1309628a199ced8f061875dd8 100644 (file)
 
 #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
@@ -40,6 +48,8 @@ class check_die_tree
   : public highlevel_check<check_die_tree>
 {
 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,
index 2f30415f0edcfb8c2cd875067ae316af173758ee..86468d90734a89d293d2d5d6a39f129eb16db43d 100644 (file)
@@ -113,13 +113,6 @@ dwarflint::main_registrar ()
   return &inst;
 }
 
-die_check_registrar *
-dwarflint::die_registrar ()
-{
-  static die_check_registrar inst;
-  return &inst;
-}
-
 namespace
 {
   template <class T>
index 199ed7ea6537af3d41b2951cec5ddf63e980762f..fdb4443ab27628473e92a13f179eb23a6ed4559b 100644 (file)
@@ -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<die_check_item>
-{
-public:
-  friend class dwarflint;
-  void run (checkstack &stack, dwarflint &lint);
-};
-
-
 class checkstack
   : public std::vector <checkdescriptor const *>
 {};
@@ -155,7 +137,6 @@ public:
   }
 
   static main_check_registrar *main_registrar ();
-  static die_check_registrar *die_registrar ();
 
   static void list_checks ();
 };