void
set_element_type(const type_base_sptr& element_type);
- virtual void
- append_subrange(subrange_sptr sub);
-
virtual void
append_subranges(const std::vector<subrange_sptr>& subs);
/// re-compute the canonical type of the array, if one has already
/// been computed.
///
+/// The intended use of this method is to permit in-place adjustment
+/// of the element type's qualifiers. In particular, the size of the
+/// element type should not be changed.
+///
/// @param element_type the new element type to set.
void
array_type_def::set_element_type(const type_base_sptr& element_type)
priv_->element_type_ = element_type;
}
-// Append a single subrange @param sub.
-void
-array_type_def::append_subrange(subrange_sptr sub)
-{
- priv_->subranges_.push_back(sub);
- size_t s = get_size_in_bits();
- s += sub->get_length() * get_element_type()->get_size_in_bits();
- set_size_in_bits(s);
- string r = get_pretty_representation();
- const environment* env = get_environment();
- ABG_ASSERT(env);
- set_name(env->intern(r));
-}
-
/// Append subranges from the vector @param subs to the current
/// vector of subranges.
void
array_type_def::append_subranges(const std::vector<subrange_sptr>& subs)
{
+ size_t s = get_element_type()->get_size_in_bits();
+
for (std::vector<shared_ptr<subrange_type> >::const_iterator i = subs.begin();
i != subs.end();
++i)
- append_subrange(*i);
+ {
+ priv_->subranges_.push_back(*i);
+ s *= (*i)->get_length();
+ }
+
+ const environment* env = get_environment();
+ ABG_ASSERT(env);
+ set_name(env->intern(get_pretty_representation()));
+ set_size_in_bits(s);
}
/// @return true if one of the sub-ranges of the array is infinite, or
#include "abg-suppression-priv.h"
#include "abg-internal.h"
+#include "abg-tools-utils.h"
+
// <headers defining libabigail's API go under here>
ABG_BEGIN_EXPORT_DECLARATIONS
!= ar_type->get_element_type()->get_alignment_in_bits()))
return nil;
- if (has_size_in_bits)
- if (size_in_bits != ar_type->get_size_in_bits())
- {
- ABG_ASSERT(size_in_bits == (size_t) -1
- || ar_type->get_element_type()->get_size_in_bits() == (size_t)-1
- || ar_type->get_element_type()->get_size_in_bits() == 0);
- }
+ if (has_size_in_bits && size_in_bits != (size_t) -1
+ && size_in_bits != ar_type->get_size_in_bits())
+ {
+ // We have a potential discrepancy between calculated and recorded sizes.
+ size_t element_size = ar_type->get_element_type()->get_size_in_bits();
+ if (element_size && element_size != (size_t)-1)
+ {
+ // Older versions miscalculated multidimensional array sizes.
+ size_t bad_count = 0;
+ for (vector<array_type_def::subrange_sptr>::const_iterator i =
+ subranges.begin();
+ i != subranges.end();
+ ++i)
+ bad_count += (*i)->get_length();
+ if (size_in_bits == bad_count * element_size)
+ {
+ static bool reported = false;
+ if (!reported)
+ {
+ std::cerr << "notice: Found incorrectly calculated array "
+ << "sizes in XML - this is benign.\nOlder versions "
+ << "of libabigail miscalculated multidimensional "
+ << "array sizes." << std::endl;
+ reported = true;
+ }
+ }
+ else
+ {
+ std::cerr << "error: Found incorrectly calculated array size in "
+ << "XML (id=\"" << id << "\")." << std::endl;
+ ABG_ASSERT_NOT_REACHED;
+ }
+ }
+ }
if (ctxt.push_and_key_type_decl(ar_type, id, add_to_current_scope))
{
</array-type-def>
<!-- REAL[40][4] -->
- <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='1408' id='type-id-156'>
+ <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='5120' id='type-id-156'>
<!-- <anonymous range>[40] -->
<subrange length='40' type-id='type-id-32' id='type-id-126'/>
</abi-instr>
<abi-instr version='1.0' address-size='64' path='libnurbs/internals/backend.cc' comp-dir-path='/tmp/legendre/spack-stage/spack-stage-T0fsxk/Mesa-8.0.5/src/glu/sgi' language='LANG_C_plus_plus'>
<!-- REAL[3][4] -->
- <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='224' id='type-id-292'>
+ <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='384' id='type-id-292'>
<!-- <anonymous range>[3] -->
<subrange length='3' type-id='type-id-32' id='type-id-35'/>
</array-type-def>
<!-- REAL[5][5] -->
- <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='320' id='type-id-321'>
+ <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='800' id='type-id-321'>
<!-- <anonymous range>[5] -->
<subrange length='5' type-id='type-id-32' id='type-id-320'/>
</array-type-def>
<!-- REAL[2][5] -->
- <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='224' id='type-id-379'>
+ <array-type-def dimensions='2' type-id='type-id-122' size-in-bits='320' id='type-id-379'>
<!-- <anonymous range>[2] -->
<subrange length='2' type-id='type-id-32' id='type-id-191'/>
</array-type-def>
<!-- hb_codepoint_t[2][5] -->
- <array-type-def dimensions='2' type-id='type-id-64' size-in-bits='224' id='type-id-65'>
+ <array-type-def dimensions='2' type-id='type-id-64' size-in-bits='320' id='type-id-65'>
<!-- <anonymous range>[2] -->
<subrange length='2' type-id='type-id-4' id='type-id-8'/>
</array-type-def>
<!-- void*[20][32] -->
- <array-type-def dimensions='2' type-id='type-id-17' size-in-bits='3328' id='type-id-434'>
+ <array-type-def dimensions='2' type-id='type-id-17' size-in-bits='40960' id='type-id-434'>
<!-- <anonymous range>[20] -->
<subrange length='20' type-id='type-id-3' id='type-id-10'/>
<!-- double -->
<type-decl name='double' size-in-bits='64' id='type-id-10'/>
<!-- double[5][3] -->
- <array-type-def dimensions='2' type-id='type-id-10' size-in-bits='512' id='type-id-11'>
+ <array-type-def dimensions='2' type-id='type-id-10' size-in-bits='960' id='type-id-11'>
<!-- <anonymous range>[5] -->
<subrange length='5' type-id='type-id-4' id='type-id-12'/>
2 data member changes:
type of 'int S::m0[5][3]' changed:
type name changed from 'int[5][3]' to 'int[5][4]'
- array type size changed from 256 to 288
+ array type size changed from 480 to 640
array type subrange 2 changed length from 3 to 4
type of 'int* S::m1[10]' changed:
array element type 'int*' changed:
2 data member changes:
type of 'int S::m0[5][3]' changed:
type name changed from 'int[5][3]' to 'int[6][3]'
- array type size changed from 256 to 288
+ array type size changed from 480 to 576
array type subrange 1 changed length from 5 to 6
type of 'int S::m1[6][4]' changed:
type name changed from 'int[6][4]' to 'int[6][5]'
- array type size changed from 320 to 352
+ array type size changed from 768 to 960
array type subrange 2 changed length from 4 to 5
and offset changed from 480 to 576 (in bits) (by +96 bits)
</data-member>
</class-decl>
<type-decl name='double' size-in-bits='64' alignment-in-bits='64' id='type-id-11'/>
- <array-type-def dimensions='2' type-id='type-id-11' size-in-bits='512' alignment-in-bits='64' id='type-id-9'>
+ <array-type-def dimensions='2' type-id='type-id-11' size-in-bits='960' alignment-in-bits='64' id='type-id-9'>
<subrange length='5' id='type-id-12'/>
<subrange length='3' id='type-id-13'/>