[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 05/10] add missing virtual destructors



Several virtual desctructors were missing. Even though there might not
have been actual leaks or similar bugs, it is worth fixing these
locations as they might lead to bugs in the future.

Clang also warns at these locations:

  warning: delete called on non-final 'abigail::ir::corpus' that has virtual
  functions but non-virtual destructor [-Wdelete-non-virtual-dtor]

 * include/abg-comparison.h: add virtual destructor for corpus_diff and diff_node_visitor
 * include/abg-corpus.h: add virtual destructor for corpus
 * include/abg-reporter.h: add virtual destructor for reporter_base
 * include/abg-traverse.h: add virtual destructor for traversable_base

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 include/abg-comparison.h | 4 ++++
 include/abg-corpus.h     | 2 ++
 include/abg-reporter.h   | 1 +
 include/abg-traverse.h   | 3 +++
 4 files changed, 10 insertions(+)

diff --git a/include/abg-comparison.h b/include/abg-comparison.h
index ba4339c9b434..cf2fa4e151a7 100644
--- a/include/abg-comparison.h
+++ b/include/abg-comparison.h
@@ -2278,6 +2278,8 @@ public:
 
   class diff_stats;
 
+  virtual ~corpus_diff() {}
+
   /// A convenience typedef for a shared pointer to @ref diff_stats
   typedef shared_ptr<diff_stats> diff_stats_sptr;
 
@@ -2544,6 +2546,8 @@ public:
 
   diff_node_visitor();
 
+  virtual ~diff_node_visitor() {}
+
   diff_node_visitor(visiting_kind k);
 
   visiting_kind
diff --git a/include/abg-corpus.h b/include/abg-corpus.h
index 258056e45222..1a25b4d1458d 100644
--- a/include/abg-corpus.h
+++ b/include/abg-corpus.h
@@ -78,6 +78,8 @@ public:
 
   corpus(ir::environment*, const string& path= "");
 
+  virtual ~corpus() {}
+
   const environment*
   get_environment() const;
 
diff --git a/include/abg-reporter.h b/include/abg-reporter.h
index 4085aeb82bcd..55cb8cc79ddc 100644
--- a/include/abg-reporter.h
+++ b/include/abg-reporter.h
@@ -141,6 +141,7 @@ public:
   report(const corpus_diff& d, ostream& out,
 	 const string& indent = "") const = 0;
 
+  virtual ~reporter_base() {}
 }; //end class reporter_base
 
 class default_reporter;
diff --git a/include/abg-traverse.h b/include/abg-traverse.h
index 5d395c2a439f..848c71b2484c 100644
--- a/include/abg-traverse.h
+++ b/include/abg-traverse.h
@@ -76,6 +76,9 @@ public:
   traversable_base()
     : visiting_()
   {}
+
+  virtual ~traversable_base() {}
+
   /// This virtual method is overloaded and implemented by any single
   /// type which instance is going to be visited during the traversal
   /// of translation unit nodes.
-- 
2.21.0.392.gf8f6787159e-goog