]> sourceware.org Git - libabigail.git/commitdiff
Extend detection of compatible types to arrays
authorDodji Seketeli <dodji@redhat.com>
Fri, 12 Dec 2014 13:30:31 +0000 (14:30 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 12 Dec 2014 13:44:24 +0000 (14:44 +0100)
* include/abg-fwd.h (is_array_type): Renamed is_array_type_def()
into this for consistency.
* src/abg-comparison.cc (type_suppression::suppresses_diff):
Adjust.
* src/abg-dwarf-reader.cc (build_array_type): Remove useless code
that was trying to read a DW_AT_byte_size attribute from the DIE
of the array, but then wasn't doing anything with the value.  But
then if the attribute was not present, the array type wouldn't be
built.
* src/abg-ir.cc (strip_typedef): Strip typedefs from sub-types of
array types too.
(is_array_type): Rename is_array_def() to this, for consistency.
(var_decl::get_pretty_representation): Adjust.
* tests/data/test-diff-filter/libtest24-compatible-vars-v0.so: New
test input data.
* tests/data/test-diff-filter/libtest24-compatible-vars-v1.so: Likewise.
* tests/data/test-diff-filter/test24-compatible-vars-report-0.txt:
Likewise.
* tests/data/test-diff-filter/test24-compatible-vars-v0.c: Source
code for the first binary above.
* tests/data/test-diff-filter/test24-compatible-vars-v1.c: Source
code for the second binary above.
* tests/data/Makefile.am: Add the new test input data to source
distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the new test input
data to the list of input to run this test harness over.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 files changed:
include/abg-fwd.h
src/abg-comparison.cc
src/abg-dwarf-reader.cc
src/abg-ir.cc
tests/data/Makefile.am
tests/data/test-diff-filter/libtest24-compatible-vars-v0.so [new file with mode: 0755]
tests/data/test-diff-filter/libtest24-compatible-vars-v1.so [new file with mode: 0755]
tests/data/test-diff-filter/test24-compatible-vars-report-0.txt [new file with mode: 0644]
tests/data/test-diff-filter/test24-compatible-vars-report-1.txt [new file with mode: 0644]
tests/data/test-diff-filter/test24-compatible-vars-v0.c [new file with mode: 0644]
tests/data/test-diff-filter/test24-compatible-vars-v1.c [new file with mode: 0644]
tests/test-diff-filter.cc

index c63378c0f1f6c93e5555720219ee712142d10d93..d5714b753dc00ed94aea8bb7ddf5ba655a0e8300 100644 (file)
@@ -298,7 +298,7 @@ shared_ptr<var_decl>
 is_data_member(const shared_ptr<decl_base>&);
 
 shared_ptr<array_type_def>
-is_array_def(const shared_ptr<type_base> decl);
+is_array_type(const shared_ptr<type_base> decl);
 
 void
 set_data_member_offset(shared_ptr<var_decl>, size_t);
index f310b29b8c9bdf942975fa8a958d2e1e8af530c9..105a58fc6209d6d83a895965e64ecd936919396c 100644 (file)
@@ -542,7 +542,7 @@ type_suppression::suppresses_diff(const diff* diff) const
            return false;
          break;
        case type_suppression::ARRAY_TYPE_KIND:
-         if (!is_array_def(ft) && !is_array_def(st))
+         if (!is_array_type(ft) && !is_array_type(st))
            return false;
          break;
        case type_suppression::TYPEDEF_TYPE_KIND:
index e24c61b98f4ff49fb2eff360123e1ff47bbf6675..383a7b8b0403eeb57c817180e3b4a585ffc22017 100644 (file)
@@ -5889,12 +5889,6 @@ build_array_type(read_context&   ctxt,
   if (!type_decl)
     return result;
 
-  size_t type_size;
-  if (!die_unsigned_constant_attribute(&type_die,
-                                      DW_AT_byte_size,
-                                      type_size))
-    return result;
-
   type_base_sptr type = is_type(type_decl);
   assert(type);
 
index d2e906767ecab604f7b97ca949cc3147f694b8e1..6f7597e2beac8545bbd3d7a9bf91bb7f6df7c4f4 100644 (file)
@@ -2288,6 +2288,10 @@ strip_typedef(const type_base_sptr type)
     t.reset(new qualified_type_def(strip_typedef(ty->get_underlying_type()),
                                   ty->get_cv_quals(),
                                   ty->get_location()));
+  else if (const array_type_def_sptr ty = is_array_type(t))
+    t.reset(new array_type_def(strip_typedef(ty->get_element_type()),
+                              ty->get_subranges(),
+                              ty->get_location()));
   else if (const method_type_sptr ty = is_method_type(t))
     {
       function_decl::parameters parm;
@@ -3244,7 +3248,7 @@ is_function_template_pattern(const shared_ptr<decl_base> decl)
 ///
 /// @return true iff decl is an array_type_def.
 array_type_def_sptr
-is_array_def(const type_base_sptr decl)
+is_array_type(const type_base_sptr decl)
 {return dynamic_pointer_cast<array_type_def>(decl);}
 
 /// Tests whether a decl is a template.
@@ -5208,7 +5212,7 @@ var_decl::get_pretty_representation() const
 
   if (is_member_decl(this) && get_member_is_static(this))
     result = "static ";
-  if(array_type_def_sptr t = is_array_def(get_type()))
+  if(array_type_def_sptr t = is_array_type(get_type()))
     result += get_type_declaration(t->get_element_type())->get_qualified_name()
       + " " + get_qualified_name() + t->get_subrange_representation();
   else
index ddddc11ebf42864656df2b40a93b83f3da223653..277d175f4b397f3079221ba42f3168996481a7b2 100644 (file)
@@ -334,6 +334,12 @@ test-diff-filter/libtest23-redundant-fn-parm-change-v1.so \
 test-diff-filter/test23-redundant-fn-parm-change-report-0.txt \
 test-diff-filter/test23-redundant-fn-parm-change-v0.c \
 test-diff-filter/test23-redundant-fn-parm-change-v1.c \
+test-diff-filter/libtest24-compatible-vars-v0.so \
+test-diff-filter/libtest24-compatible-vars-v1.so \
+test-diff-filter/test24-compatible-vars-report-0.txt \
+test-diff-filter/test24-compatible-vars-report-1.txt \
+test-diff-filter/test24-compatible-vars-v0.c \
+test-diff-filter/test24-compatible-vars-v1.c \
 \
 test-diff-suppr/test0-type-suppr-v0.cc \
 test-diff-suppr/test0-type-suppr-v1.cc \
diff --git a/tests/data/test-diff-filter/libtest24-compatible-vars-v0.so b/tests/data/test-diff-filter/libtest24-compatible-vars-v0.so
new file mode 100755 (executable)
index 0000000..4dccb45
Binary files /dev/null and b/tests/data/test-diff-filter/libtest24-compatible-vars-v0.so differ
diff --git a/tests/data/test-diff-filter/libtest24-compatible-vars-v1.so b/tests/data/test-diff-filter/libtest24-compatible-vars-v1.so
new file mode 100755 (executable)
index 0000000..732568a
Binary files /dev/null and b/tests/data/test-diff-filter/libtest24-compatible-vars-v1.so differ
diff --git a/tests/data/test-diff-filter/test24-compatible-vars-report-0.txt b/tests/data/test-diff-filter/test24-compatible-vars-report-0.txt
new file mode 100644 (file)
index 0000000..fa4b750
--- /dev/null
@@ -0,0 +1,3 @@
+Functions changes summary: 0 Removed, 0 Changed, 0 Added function
+Variables changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added variable
+
diff --git a/tests/data/test-diff-filter/test24-compatible-vars-report-1.txt b/tests/data/test-diff-filter/test24-compatible-vars-report-1.txt
new file mode 100644 (file)
index 0000000..fb9b111
--- /dev/null
@@ -0,0 +1,9 @@
+Functions changes summary: 0 Removed, 0 Changed, 0 Added function
+Variables changes summary: 0 Removed, 1 Changed, 0 Added variable
+
+1 Changed variable:
+  'S a[2]' was changed to 'typedef_of_S a[2]':
+    type of variable changed:
+     array element type 'S' changed:
+       entity changed from 'struct S' to compatible type 'typedef typedef_of_S'
+
diff --git a/tests/data/test-diff-filter/test24-compatible-vars-v0.c b/tests/data/test-diff-filter/test24-compatible-vars-v0.c
new file mode 100644 (file)
index 0000000..3b73c0a
--- /dev/null
@@ -0,0 +1,10 @@
+/* Compile with:
+     gcc -Wall -g -shared -o libtest24-compatible-vars-v0.so test24-compatible-vars-v0.c
+ */
+
+struct S
+{
+  int m0;
+};
+
+struct S a[2];
diff --git a/tests/data/test-diff-filter/test24-compatible-vars-v1.c b/tests/data/test-diff-filter/test24-compatible-vars-v1.c
new file mode 100644 (file)
index 0000000..9eab861
--- /dev/null
@@ -0,0 +1,12 @@
+/* Compile with:
+     gcc -Wall -g -fPIC -shared -o libtest24-compatible-vars-v1.so test24-compatible-vars-v1.c
+ */
+
+struct S
+{
+  int m0;
+};
+
+typedef struct S typedef_of_S;
+
+typedef_of_S a[2];
index 46d3a3ffb599bcce7be61a6632bbdd3bd32174d4..aa2e7163d6c89c4963d915df685fc816e2db3923 100644 (file)
@@ -278,6 +278,20 @@ InOutSpec in_out_specs[] =
     "data/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt ",
     "output/test-diff-filter/test23-redundant-fn-parm-change-report-0.txt ",
   },
+  {
+    "data/test-diff-filter/libtest24-compatible-vars-v0.so",
+    "data/test-diff-filter/libtest24-compatible-vars-v1.so",
+    "",
+    "data/test-diff-filter/test24-compatible-vars-report-0.txt ",
+    "output/test-diff-filter/test24-compatible-vars-report-0.txt ",
+  },
+  {
+    "data/test-diff-filter/libtest24-compatible-vars-v0.so",
+    "data/test-diff-filter/libtest24-compatible-vars-v1.so",
+    "--harmless",
+    "data/test-diff-filter/test24-compatible-vars-report-1.txt ",
+    "output/test-diff-filter/test24-compatible-vars-report-1.txt ",
+  },
   // This should be the last entry
   {NULL, NULL, NULL, NULL, NULL}
 };
This page took 0.075107 seconds and 5 git commands to generate.