analyzer: consolidate duplicate code in region::calc_offset

gcc/analyzer/ChangeLog:
	* region.cc (region::calc_offset): Consolidate effectively
	identical cases.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2022-02-01 15:48:26 -05:00
parent 93e759fc18
commit ea3e191595

View File

@ -499,41 +499,16 @@ region::calc_offset () const
switch (iter_region->get_kind ())
{
case RK_FIELD:
{
const field_region *field_reg
= (const field_region *)iter_region;
iter_region = iter_region->get_parent_region ();
bit_offset_t rel_bit_offset;
if (!field_reg->get_relative_concrete_offset (&rel_bit_offset))
return region_offset::make_symbolic (iter_region);
accum_bit_offset += rel_bit_offset;
}
continue;
case RK_ELEMENT:
{
const element_region *element_reg
= (const element_region *)iter_region;
iter_region = iter_region->get_parent_region ();
bit_offset_t rel_bit_offset;
if (!element_reg->get_relative_concrete_offset (&rel_bit_offset))
return region_offset::make_symbolic (iter_region);
accum_bit_offset += rel_bit_offset;
}
continue;
case RK_OFFSET:
case RK_BIT_RANGE:
{
const offset_region *offset_reg
= (const offset_region *)iter_region;
iter_region = iter_region->get_parent_region ();
bit_offset_t rel_bit_offset;
if (!offset_reg->get_relative_concrete_offset (&rel_bit_offset))
return region_offset::make_symbolic (iter_region);
if (!iter_region->get_relative_concrete_offset (&rel_bit_offset))
return region_offset::make_symbolic
(iter_region->get_parent_region ());
accum_bit_offset += rel_bit_offset;
iter_region = iter_region->get_parent_region ();
}
continue;
@ -549,19 +524,6 @@ region::calc_offset () const
}
continue;
case RK_BIT_RANGE:
{
const bit_range_region *bit_range_reg
= (const bit_range_region *)iter_region;
iter_region = iter_region->get_parent_region ();
bit_offset_t rel_bit_offset;
if (!bit_range_reg->get_relative_concrete_offset (&rel_bit_offset))
return region_offset::make_symbolic (iter_region);
accum_bit_offset += rel_bit_offset;
}
continue;
default:
return region_offset::make_concrete (iter_region, accum_bit_offset);
}