Fix pretty representation of array types
authorDodji Seketeli <dodji@redhat.com>
Sun, 6 Nov 2016 11:15:41 +0000 (12:15 +0100)
committerDodji Seketeli <dodji@redhat.com>
Tue, 29 Nov 2016 15:51:19 +0000 (16:51 +0100)
It turned out we were wrongly emitting the pretty representation of
array types in two cases:

  1/ in case of qualified array types: a const array of string type
  was being pretty-represented as: "const string[]" instead of
  "string[] const".

  2/ in case of array with an empty sub-range DIE; that is a sub-range
  DIE with no attribute at all.  For instance an array of char with an
  empty sub-range DIE was being represented as: "char", instead of
  "char[]".

This patch fixes 1 and 2.  It also updates numerous test reference
output files.

* include/abg-ir.h (array_type_def::is_infinite): Fix indentation.
* src/abg-ir.cc (qualified_type_def::build_name): An empty set of
sub-ranges for a vector is represented by "[]".
(array_type_def::is_infinite): If a vector has no sub-range, that
means it has an infinite size.  Adjust comment.
* tests/data/test-diff-filter/test33-report-0.txt: Adjust.
* tests/data/test-read-dwarf/libtest23.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Adjust.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Adjust.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Adjust.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-ir.h
src/abg-ir.cc
tests/data/test-diff-filter/test33-report-0.txt

index 1e9b8e224d6d77e7a4333c9f56a3d9445cf5ed7e..1e3c1424a637604fd3428fbc4ad5ad4403cc7359 100644 (file)
@@ -1944,7 +1944,7 @@ public:
   virtual int
   get_dimension_count() const;
 
-   virtual bool
+  virtual bool
   is_infinite() const;
 
   virtual string
index 8bc6a21e7e3b47091846c35b7c7f11879e5802ef..09ae1732e70a9bb8d51e92108dc5afb0a2ecf048 100644 (file)
@@ -8279,7 +8279,8 @@ qualified_type_def::build_name(bool fully_qualified, bool internal) const
   if (!quals.empty())
     {
       if (is_pointer_type(get_underlying_type())
-         || is_reference_type(get_underlying_type()))
+         || is_reference_type(get_underlying_type())
+         || is_array_type(get_underlying_type()))
        {
          name += " ";
          name += quals;
@@ -9329,6 +9330,9 @@ array_type_def::subrange_type::as_string() const
 string
 array_type_def::subrange_type::vector_as_string(const vector<subrange_sptr>& v)
 {
+  if (v.empty())
+    return "[]";
+
   string r;
   for (vector<subrange_sptr>::const_iterator i = v.begin();
        i != v.end();
@@ -9540,10 +9544,14 @@ array_type_def::append_subranges(const std::vector<subrange_sptr>& subs)
     append_subrange(*i);
 }
 
-/// @return true iff one of the sub-ranges of the array is infinite.
+/// @return true if one of the sub-ranges of the array is infinite, or
+/// if the array has no sub-range at all, also meaning that the size
+/// of the array is infinite.
 bool
 array_type_def::is_infinite() const
 {
+  if (priv_->subranges_.empty())
+    return true;
 
   for (std::vector<shared_ptr<subrange_type> >::const_iterator i =
         priv_->subranges_.begin();
index 2d7c6258ecfbbbe8c276d83839b99d01f7d59619..7bc030d99382fd597ee3b1c5339e952e089ecc21 100644 (file)
@@ -3,8 +3,8 @@ Variables changes summary: 0 Removed, 1 Changed, 0 Added variable
 
 1 Changed variable:
 
-  [C]'const const size_t[2][1][17][2] _elf_fmsize' was changed to 'const size_t _elf_fmsize[2][1][17][2]':
+  [C]'const size_t[2][1][17][2] const _elf_fmsize' was changed to 'const size_t _elf_fmsize[2][1][17][2]':
     type of variable changed:
-     entity changed from 'const const size_t[2][1][17][2]' to 'const size_t[2][1][17][2]'
+     entity changed from 'const size_t[2][1][17][2] const' to 'const size_t[2][1][17][2]'