]> sourceware.org Git - libabigail.git/commitdiff
Cleanup void and variadic parameter type interfaces
authorDodji Seketeli <dodji@redhat.com>
Mon, 31 Oct 2016 12:52:53 +0000 (13:52 +0100)
committerDodji Seketeli <dodji@redhat.com>
Thu, 3 Nov 2016 14:12:46 +0000 (15:12 +0100)
While working on something else, it appeared that renaming
abigail::environment::get_void_type_decl() to
abigail::environment::get_void_type() and
abigail::environment::get_variadic_parameter_type_decl() to
abigail::environment::get_variadic_parameter_type() would be an
improvement.

This patch implements that.

* include/abg-ir.h (environment::{get_void_type,
get_variadic_parameter_type}): Renamed get_void_type_decl and
get_variadic_parameter_type_decl to these.
(environment::is_void_type): Remove the overload that takes a bare
pointer.
(environment::is_variadic_parameter_type): Declare new member
function.
* src/abg-ir.cc (environment::void_type_): Renamed the data member
void_type_decl_ into this.
(environment::variadic_marker_type_): Renamed the data member
variadic_marker_type_decl_ into this.
(environment::{get_void_type, get_variadic_parameter_type}):
Renamed get_void_type_decl and get_variadic_parameter_type_decl to
these.
(environment::is_void_type): Take a smart pointer now.
(environment::is_variadic_parameter_type): Define new member
function.
(synthesize_function_type_from_translation_unit): Adjust.
(function_decl::parameter::get_pretty_representation): Likewise.
* src/abg-comparison.cc (is_diff_of_variadic_parameter_type):
Adjust.
* src/abg-dwarf-reader.cc (build_function_type)
(build_ir_node_for_void_type): Likewise.
* src/abg-reader.cc (build_function_parameter)
(build_function_decl, build_function_type): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-ir.h
src/abg-comparison.cc
src/abg-dwarf-reader.cc
src/abg-ir.cc
src/abg-reader.cc

index 945c2fac80500b4da8d9921bfde56d7c91a8202f..fd32029c1e0166874ce804f8a548a797fdc410ba 100644 (file)
@@ -160,11 +160,11 @@ public:
   canonical_types_map_type&
   get_canonical_types_map();
 
-  const type_decl_sptr&
-  get_void_type_decl() const;
+  const type_base_sptr&
+  get_void_type() const;
 
-  const type_decl_sptr&
-  get_variadic_parameter_type_decl() const;
+  const type_base_sptr&
+  get_variadic_parameter_type() const;
 
   bool
   canonicalization_is_done() const;
@@ -173,13 +173,13 @@ public:
   canonicalization_is_done(bool);
 
   bool
-  is_void_type(const type_decl*) const;
+  is_void_type(const type_base_sptr&) const;
 
   bool
-  is_void_type(const type_decl_sptr&) const;
+  is_variadic_parameter_type(const type_base*) const;
 
   bool
-  is_void_type(const type_base_sptr&) const;
+  is_variadic_parameter_type(const type_base_sptr&) const;
 
   interned_string
   intern(const string&) const;
index 94d830c1ddc6a6ae7b225aa260cda899f88aa154..f2acb25d25fdb1c09391341a601e74836fd3c453 100644 (file)
@@ -13067,15 +13067,11 @@ is_diff_of_variadic_parameter_type(const diff* d)
     return false;
 
   type_base_sptr t = is_type(d->first_subject());
-  if (t
-      && (t.get()
-         == t->get_environment()->get_variadic_parameter_type_decl().get()))
+  if (t && t->get_environment()->is_variadic_parameter_type(t))
     return true;
 
   t = is_type(d->second_subject());
-  if (t
-      && (t.get()
-         == t->get_environment()->get_variadic_parameter_type_decl().get()))
+  if (t && t->get_environment()->is_variadic_parameter_type(t))
     return true;
 
   return false;
index c2f08cd24c08538a31ff23f3de9fca6e880f4f51..a7a32a7074ff0642af5df0421d89ce868f82da92 100644 (file)
@@ -8506,7 +8506,7 @@ build_function_type(read_context& ctxt,
            bool is_artificial = die_is_artificial(&child);
            ir::environment* env = ctxt.env();
            assert(env);
-           type_decl_sptr parm_type = env->get_variadic_parameter_type_decl();
+           type_base_sptr parm_type = env->get_variadic_parameter_type();
            function_decl::parameter_sptr p
              (new function_decl::parameter(parm_type,
                                            /*name=*/"",
@@ -9762,11 +9762,13 @@ build_ir_node_for_void_type(read_context& ctxt)
 {
   ir::environment* env = ctxt.env();
   assert(env);
-  decl_base_sptr t = env->get_void_type_decl();
-  if (!has_scope(t))
-    add_decl_to_scope(t, ctxt.cur_transl_unit()->get_global_scope());
-  canonicalize(is_type(t));
-  return t;
+  type_base_sptr t = env->get_void_type();
+  decl_base_sptr type_declaration = get_type_declaration(t);
+  if (!has_scope(type_declaration))
+    add_decl_to_scope(type_declaration,
+                     ctxt.cur_transl_unit()->get_global_scope());
+  canonicalize(t);
+  return type_declaration;
 }
 
 /// Build an IR node from a given DIE and add the node to the current
index 1df57cdae12299129b9b5950cc6779a8092a0e34..489fffd29238d35ced04a36ec676921651eedb82 100644 (file)
@@ -2049,8 +2049,8 @@ struct environment::priv
 {
   bool                         canonicalization_is_done_;
   canonical_types_map_type     canonical_types_;
-  type_decl_sptr               void_type_decl_;
-  type_decl_sptr               variadic_marker_type_decl_;
+  type_base_sptr               void_type_;
+  type_base_sptr               variadic_marker_type_;
   interned_string_set_type     classes_being_compared_;
   interned_string_set_type     fn_types_being_compared_;
   vector<type_base_sptr>       extra_live_types_;
@@ -2082,14 +2082,14 @@ environment::get_canonical_types_map()
 /// environment.
 ///
 /// @return the @ref type_decl that represents a "void" type.
-const type_decl_sptr&
-environment::get_void_type_decl() const
+const type_base_sptr&
+environment::get_void_type() const
 {
-  if (!priv_->void_type_decl_)
-    priv_->void_type_decl_.reset(new type_decl(const_cast<environment*>(this),
+  if (!priv_->void_type_)
+    priv_->void_type_.reset(new type_decl(const_cast<environment*>(this),
                                               intern("void"),
                                               0, 0, location()));
-  return priv_->void_type_decl_;
+  return priv_->void_type_;
 }
 
 /// Get a @ref type_decl instance that represents a the type of a
@@ -2097,15 +2097,15 @@ environment::get_void_type_decl() const
 ///
 /// @return the Get a @ref type_decl instance that represents a the
 /// type of a variadic function parameter.
-const type_decl_sptr&
-environment::get_variadic_parameter_type_decl() const
+const type_base_sptr&
+environment::get_variadic_parameter_type() const
 {
-  if (!priv_->variadic_marker_type_decl_)
-    priv_->variadic_marker_type_decl_.
+  if (!priv_->variadic_marker_type_)
+    priv_->variadic_marker_type_.
       reset(new type_decl(const_cast<environment*>(this),
                          intern("variadic parameter type"),
                          0, 0, location()));
-  return priv_->variadic_marker_type_decl_;
+  return priv_->variadic_marker_type_;
 }
 
 /// Test if the canonicalization of types created out of the current
@@ -2131,43 +2131,47 @@ void
 environment::canonicalization_is_done(bool f)
 {priv_->canonicalization_is_done_ = f;}
 
-/// Test if a given basic type is a void type as defined in the
-/// current environment.
+
+/// Test if a given type is a void type as defined in the current
+/// environment.
 ///
-/// @param d the basic type to consider.
+/// @param t the type to consider.
 ///
-/// @return true iff @p d is a void type as defined in the current
+/// @return true iff @p t is a void type as defined in the current
 /// environment.
 bool
-environment::is_void_type(const type_decl* d) const
-{return (get_void_type_decl().get() == d);}
+environment::is_void_type(const type_base_sptr& t) const
+{
+  if (!t)
+    return false;
+  return t.get() == get_void_type().get();
+}
 
-/// Test if a given basic type is a void type as defined in the
+/// Test if a type is a variadic parameter type as defined in the
 /// current environment.
 ///
-/// @param d the basic type to consider.
+/// @param t the type to consider.
 ///
-/// @return true iff @p d is a void type as defined in the current
-/// environment.
+/// @return true iff @p t is a variadic parameter type as defined in
+/// the current environment.
 bool
-environment::is_void_type(const type_base_sptr& t) const
+environment::is_variadic_parameter_type(const type_base* t) const
 {
-  type_decl_sptr d = is_type_decl(t);
-  if (!d)
+  if (!t)
     return false;
-  return is_void_type(d);
+  return t == get_variadic_parameter_type().get();
 }
 
-/// Test if a given basic type is a void type as defined in the
+/// Test if a type is a variadic parameter type as defined in the
 /// current environment.
 ///
-/// @param d the basic type to consider.
+/// @param t the type to consider.
 ///
-/// @return true iff @p d is a void type as defined in the current
-/// environment.
+/// @return true iff @p t is a variadic parameter type as defined in
+/// the current environment.
 bool
-environment::is_void_type(const type_decl_sptr& d) const
-{return is_void_type(d.get());}
+environment::is_variadic_parameter_type(const type_base_sptr& t) const
+{return is_variadic_parameter_type(t.get());}
 
 /// Do intern a string.
 ///
@@ -6475,9 +6479,8 @@ synthesize_function_type_from_translation_unit(const function_type& fn_type,
 
   type_base_sptr return_type = fn_type.get_return_type();
   type_base_sptr result_return_type;
-  if (!return_type
-      || return_type.get() == env->get_void_type_decl().get())
-    result_return_type = type_base_sptr(env->get_void_type_decl());
+  if (!return_type || env->is_void_type(return_type))
+    result_return_type = env->get_void_type();
   else
     result_return_type = synthesize_type_from_translation_unit(return_type, tu);
   if (!result_return_type)
@@ -6915,7 +6918,7 @@ type_or_void(const type_base_sptr t, const environment* env)
   else
     {
       assert(env);
-      r = type_base_sptr(env->get_void_type_decl());
+      r = type_base_sptr(env->get_void_type());
     }
 
   return r;
@@ -12195,7 +12198,7 @@ function_decl::parameter::get_pretty_representation(bool internal) const
   type_base_sptr t = get_type();
   if (!t)
     type_repr = "void";
-  else if (env->get_variadic_parameter_type_decl())
+  else if (env->is_variadic_parameter_type(t))
     type_repr = "...";
   else
     type_repr = ir::get_pretty_representation(t, internal);
index d406300affef7376602ebc0e06b66ebdfa386488..df1501cd708e31b2f2ff52cd4d79e9c27f9f241f 100644 (file)
@@ -2604,7 +2604,7 @@ build_function_parameter(read_context& ctxt, const xmlNodePtr node)
 
   type_base_sptr type;
   if (is_variadic)
-    type = ctxt.get_environment()->get_variadic_parameter_type_decl();
+    type = ctxt.get_environment()->get_variadic_parameter_type();
   else
     {
       assert(!type_id.empty());
@@ -2684,7 +2684,7 @@ build_function_decl(read_context& ctxt,
   environment* env = ctxt.get_environment();
   assert(env);
   std::vector<function_decl::parameter_sptr> parms;
-  type_base_sptr return_type = env->get_void_type_decl();
+  type_base_sptr return_type = env->get_void_type();
 
   for (xmlNodePtr n = node->children; n ; n = n->next)
     {
@@ -3353,7 +3353,7 @@ build_function_type(read_context& ctxt,
   environment* env = ctxt.get_environment();
   assert(env);
   std::vector<shared_ptr<function_decl::parameter> > parms;
-  type_base_sptr return_type = env->get_void_type_decl();;
+  type_base_sptr return_type = env->get_void_type();;
 
  function_type_sptr fn_type(new function_type(return_type,
                                              parms, size, align));
This page took 0.078671 seconds and 5 git commands to generate.