[04/11] Tidy build_enum_type state variables.

Message ID 20200610115940.26035-5-gprocida@google.com
State Committed
Headers
Series Add incomplete enum support. |

Commit Message

Giuliano Procida June 10, 2020, 11:59 a.m. UTC
  This patch brings the enum code closer to the class/union code, in the
hope that this will ease future code maintenance.

There are no behavioural changes.

	* src/abg-dwarf-reader.cc (build_enum_type): Rename local
	variable enum_is_anonymous to is_anonymous. Move initilisation
	of local variable is_artificial to location corresponding to
	that in add_or_update_class_type and add_or_update_union_type
	functions.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-dwarf-reader.cc | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
  

Comments

Dodji Seketeli June 29, 2020, 9:08 a.m. UTC | #1
Giuliano Procida <gprocida@google.com> a écrit:

> This patch brings the enum code closer to the class/union code, in the
> hope that this will ease future code maintenance.
>
> There are no behavioural changes.
>
> 	* src/abg-dwarf-reader.cc (build_enum_type): Rename local
> 	variable enum_is_anonymous to is_anonymous. Move initilisation
> 	of local variable is_artificial to location corresponding to
> 	that in add_or_update_class_type and add_or_update_union_type
> 	functions.
>
> Signed-off-by: Giuliano Procida <gprocida@google.com>

Applied to master, thanks!

Cheers,
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 1218f8c7..9b3e6371 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -13284,14 +13284,14 @@  build_enum_type(read_context&	ctxt,
   location loc;
   die_loc_and_name(ctxt, die, loc, name, linkage_name);
 
-  bool enum_is_anonymous = false;
+  bool is_anonymous = false;
   // If the enum is anonymous, let's give it a name.
   if (name.empty())
     {
       name = get_internal_anonymous_die_prefix_name(die);
       ABG_ASSERT(!name.empty());
       // But we remember that the type is anonymous.
-      enum_is_anonymous = true;
+      is_anonymous = true;
 
       if (size_t s = scope->get_num_anonymous_member_enums())
 	name = build_internal_anonymous_die_name(name, s);
@@ -13303,7 +13303,7 @@  build_enum_type(read_context&	ctxt,
   // representation (name) and location can be later detected as being
   // for the same type.
 
-  if (!enum_is_anonymous)
+  if (!is_anonymous)
     {
       if (use_odr)
 	{
@@ -13336,6 +13336,7 @@  build_enum_type(read_context&	ctxt,
   uint64_t size = 0;
   if (die_unsigned_constant_attribute(die, DW_AT_byte_size, size))
     size *= 8;
+  bool is_artificial = die_is_artificial(die);
 
   // for now we consider that underlying types of enums are all anonymous
   bool enum_underlying_type_is_anonymous= true;
@@ -13368,8 +13369,6 @@  build_enum_type(read_context&	ctxt,
       while (dwarf_siblingof(&child, &child) == 0);
     }
 
-  bool is_artificial = die_is_artificial(die);
-
   // DWARF up to version 4 (at least) doesn't seem to carry the
   // underlying type, so let's create an artificial one here, which
   // sole purpose is to be passed to the constructor of the
@@ -13385,7 +13384,7 @@  build_enum_type(read_context&	ctxt,
   t = dynamic_pointer_cast<type_decl>(d);
   ABG_ASSERT(t);
   result.reset(new enum_type_decl(name, loc, t, enms, linkage_name));
-  result->set_is_anonymous(enum_is_anonymous);
+  result->set_is_anonymous(is_anonymous);
   result->set_is_artificial(is_artificial);
   ctxt.associate_die_to_type(die, result, where_offset);
   return result;