]> sourceware.org Git - libabigail.git/commitdiff
Better handle pointer-to-void in various places of the pipeline
authorDodji Seketeli <dodji@redhat.com>
Thu, 11 Dec 2014 14:47:44 +0000 (15:47 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 11 Dec 2014 15:01:07 +0000 (16:01 +0100)
This is the last patch that should fix the issue
https://sourceware.org/bugzilla/show_bug.cgi?id=17655

A pointer to void can be represented as an instance of
abigail::ir::pointer_type_def which has a NULL pointed-to attribute.

Unfortunately, there are various places in the code that assume that
abigail::ir::pointer_type_def::get_pointed_to_type() returns a
non-null value.  This patch is an attempt at fixing those spots.

* src/abg-comparison.cc (pointer_diff::report): Handle the case of
pointer to void.
* src/abg-dwarf-reader.cc (build_pointer_type_def): Assert that
the underlying pointer is non-null.
* src/abg-ir.cc (pointer_type_def::pointer_type_def): Handle the
case of pointer to void.
(equals): Likewise in the overload for const pointer_type_def.
(pointer_type_def::get_qualified_name): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-comparison.cc
src/abg-dwarf-reader.cc
src/abg-ir.cc

index fd32cc8f4048280d1dbedec58b3a0a251909e5c2..f310b29b8c9bdf942975fa8a958d2e1e8af530c9 100644 (file)
@@ -4605,10 +4605,12 @@ pointer_diff::report(ostream& out, const string& indent) const
   if (diff_sptr d = underlying_type_diff())
     {
       RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER2(d, "pointed to type");
+      string repr = d->first_subject()
+       ? d->first_subject()->get_pretty_representation()
+       : string("void");
+
       out << indent
-         << "in pointed to type '"
-         <<  d->first_subject()->get_pretty_representation()
-         << "':\n";
+         << "in pointed to type '" <<  repr << "':\n";
       d->report(out, indent + "  ");
     }
 }
index ffabd5ccb46f0c7ee78bc4a63b9f38a7edec7351..e24c61b98f4ff49fb2eff360123e1ff47bbf6675 100644 (file)
@@ -5768,6 +5768,7 @@ build_pointer_type_def(read_context&      ctxt,
 
   result.reset(new pointer_type_def(utype, size, size, location()));
 
+  assert(result->get_pointed_to_type());
   return result;
 }
 
index 118269d7afcb88806766a962d7fdca5aa4e05a27..a19e8ecdb482a88bbf07ea82cfd35fd32d2069a0 100644 (file)
@@ -4171,13 +4171,15 @@ pointer_type_def::pointer_type_def(const type_base_sptr&        pointed_to,
                                   location                     locus)
   : type_base(size_in_bits, align_in_bits),
     decl_base("", locus, "",
-             dynamic_pointer_cast<decl_base>(pointed_to)->get_visibility()),
+             pointed_to
+             ? get_type_declaration(pointed_to)->get_visibility()
+             : decl_base::VISIBILITY_DEFAULT),
     pointed_to_type_(pointed_to)
 {
   try
     {
       decl_base_sptr pto = dynamic_pointer_cast<decl_base>(pointed_to);
-      string name = pto->get_name() + "*";
+      string name = (pto ? pto->get_name() : string("void")) + "*";
       set_name(name);
     }
   catch (...)
@@ -4201,7 +4203,7 @@ pointer_type_def::pointer_type_def(const type_base_sptr&  pointed_to,
 bool
 equals(const pointer_type_def& l, const pointer_type_def& r, change_kind& k)
 {
-  bool result = (*l.get_pointed_to_type() == *r.get_pointed_to_type());
+  bool result = (l.get_pointed_to_type() == r.get_pointed_to_type());
   if (!result)
     k |= SUBTYPE_CHANGE_KIND;
 
@@ -4256,7 +4258,10 @@ pointer_type_def::get_qualified_name(string& qn) const
       decl_base_sptr td =
        get_type_declaration(get_pointed_to_type());
       string name;
-      td->get_qualified_name(name);
+      if (!td)
+       name = "void";
+      else
+       td->get_qualified_name(name);
       set_qualified_name(name + "*");
     }
   qn = peek_qualified_name();
This page took 0.066764 seconds and 5 git commands to generate.