Patchwork [pushed] Make mapped_debug_names and mapped_index final

login
register
mail settings
Submitter Simon Marchi
Date Dec. 30, 2017, 5:11 a.m.
Message ID <1514610666-10842-1-git-send-email-simon.marchi@ericsson.com>
Download mbox | patch
Permalink /patch/25147/
State New
Headers show

Comments

Simon Marchi - Dec. 30, 2017, 5:11 a.m.
When compiling with Clang 6, I see these warnings:

/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25421:5: error: destructor called on non-final 'mapped_index' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
    data->index_table->~mapped_index ();
    ^
In file included from /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:31:
In file included from /home/emaisin/src/binutils-gdb/gdb/defs.h:28:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/common-defs.h:92:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:23:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/memory:81:
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:76:2: error: delete called on non-final 'mapped_debug_names' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
        delete __ptr;
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:236:4: note: in instantiation of member function 'std::default_delete<mapped_debug_names>::operator()' requested here
          get_deleter()(__ptr);
          ^
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:2374:21: note: in instantiation of member function 'std::unique_ptr<mapped_debug_names, std::default_delete<mapped_debug_names> >::~unique_ptr' requested here
dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_,
                    ^

This patch silences these warnings by making the classes final.

gdb/ChangeLog:

	* dwarf2read.c (struct mapped_debug_names): Make final.
	(struct mapped_index): Make final.
---
 gdb/ChangeLog    | 5 +++++
 gdb/dwarf2read.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9cc060e..b94384b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2017-12-30  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* dwarf2read.c (struct mapped_debug_names): Make final.
+	(struct mapped_index): Make final.
+
 2017-12-29  Simon Marchi  <simon.marchi@ericsson.com>
 
 	* common/diagnostics.h
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 484cbce..85e33f0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -277,7 +277,7 @@  protected:
 
 /* A description of the mapped index.  The file format is described in
    a comment by the code that writes the index.  */
-struct mapped_index : public mapped_index_base
+struct mapped_index final : public mapped_index_base
 {
   /* A slot/bucket in the symbol table hash.  */
   struct symbol_table_slot
@@ -318,7 +318,7 @@  struct mapped_index : public mapped_index_base
 
 /* A description of the mapped .debug_names.
    Uninitialized map has CU_COUNT 0.  */
-struct mapped_debug_names : public mapped_index_base
+struct mapped_debug_names final : public mapped_index_base
 {
   bfd_endian dwarf5_byte_order;
   bool dwarf5_is_dwarf64;