From 1b94d60780801002806101b0bea6391e754dae08 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Nov 29 2016 15:16:31 +0000 Subject: Allow pretty printing function decls for internal purposes It appears that function_decl::get_pretty_representation doesn't make the difference between internal and non-internal purposes. This patch fixes that by making the helper get_pretty_representation_of_declarator() take an "internal" flag and calls that. * include/abg-ir.h (function_decl::get_pretty_representation_of_declarator): Take an "internal" flag. * src/abg-ir.cc (function_decl::get_pretty_representation_of_declarator): Take an "internal" flag. (function_decl::get_pretty_representation): Pass the "internal" flag to the function function_decl::get_pretty_representation_of_declarator. (function_decl::parameter::get_type_name): Better handle variadic parameter type. (function_decl::parameter::get_type_pretty_representation): Likewise. Signed-off-by: Dodji Seketeli --- diff --git a/include/abg-ir.h b/include/abg-ir.h index be9783c..fd59da7 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -2359,7 +2359,7 @@ public: get_pretty_representation(bool internal = false) const; string - get_pretty_representation_of_declarator () const; + get_pretty_representation_of_declarator (bool internal = false) const; const std::vector& get_parameters() const; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 3156038..a6a846f 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -11414,7 +11414,7 @@ function_decl::get_pretty_representation(bool internal) const if (type) result += type->get_qualified_name(internal) + " "; - result += get_pretty_representation_of_declarator(); + result += get_pretty_representation_of_declarator(internal); return result; } @@ -11424,10 +11424,15 @@ function_decl::get_pretty_representation(bool internal) const /// return type and the other specifiers of the beginning of the /// function's declaration ar omitted. /// +/// @param internal set to true if the call is intended for an +/// internal use (for technical use inside the library itself), false +/// otherwise. If you don't know what this is for, then set it to +/// false. +/// /// @return the pretty representation for the part of the function /// declaration that starts at the declarator. string -function_decl::get_pretty_representation_of_declarator () const +function_decl::get_pretty_representation_of_declarator (bool internal) const { const method_decl* mem_fn = dynamic_cast(this); @@ -11459,12 +11464,13 @@ function_decl::get_pretty_representation_of_declarator () const parm = *i; if (parm.get() != first_parm.get()) result += ", "; - if (parm->get_variadic_marker()) + if (parm->get_variadic_marker() + || get_environment()->is_variadic_parameter_type(parm->get_type())) result += "..."; else { decl_base_sptr type_decl = get_type_declaration(parm->get_type()); - result += type_decl->get_qualified_name(); + result += type_decl->get_qualified_name(internal); } } result += ")"; @@ -11979,12 +11985,12 @@ function_decl::parameter::get_type_name() const const environment* env = get_environment(); assert(env); + type_base_sptr t = get_type(); string str; - if (get_variadic_marker()) + if (get_variadic_marker() || env->is_variadic_parameter_type(t)) str = "..."; else { - type_base_sptr t = get_type(); assert(t); str = abigail::ir::get_type_name(t); } @@ -11996,12 +12002,13 @@ function_decl::parameter::get_type_name() const const string function_decl::parameter::get_type_pretty_representation() const { + type_base_sptr t = get_type(); string str; - if (get_variadic_marker()) + if (get_variadic_marker() + || get_environment()->is_variadic_parameter_type(t)) str = "..."; else { - type_base_sptr t = get_type(); assert(t); str += get_type_declaration(t)->get_pretty_representation(); }