From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 00100384B0C1 for ; Tue, 21 Apr 2020 12:28:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00100384B0C1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mark@klomp.org Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id AC871300D947; Tue, 21 Apr 2020 14:28:41 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 9F19240422D5; Tue, 21 Apr 2020 14:28:41 +0200 (CEST) From: "Mark J. Wielaard" To: libabigail@sourceware.org Cc: Dodji Seketeli , Mark Wielaard Subject: [PATCH 2/4] Add no-parameter-names to drop function parameter names. Date: Tue, 21 Apr 2020 14:28:19 +0200 Message-Id: <20200421122821.13769-3-mark@klomp.org> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200421122821.13769-1-mark@klomp.org> References: <20200421122821.13769-1-mark@klomp.org> X-Spam-Status: No, score=-23.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libabigail mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Apr 2020 12:28:44 -0000 From: Mark Wielaard The function parameter names are not relevant for the (exported) ABI. So provide an option to simply drop them from the corpus. * doc/manuals/abidw.rst: Add documentation for --no-parameter-names. * include/abg-writer.h (set_write_parameter_names): New function. (set_write_parameter_names): Call it. * src/abg-writer.cc (write_context): Add m_write_parameter_names bool, get_write_parameter_names and set_write_parameter_names functions. (write_context::write_function_decl): Check write_parameter_names. * tools/abidw.cc (options): Add write_parameter_names. (display_usage): Describe --no-parameter-names. (parse_command_line): Parse --no-parameter-names. Signed-off-by: Mark Wielaard --- doc/manuals/abidw.rst | 5 +++++ include/abg-writer.h | 4 ++++ src/abg-writer.cc | 30 +++++++++++++++++++++++++++++- tools/abidw.cc | 5 +++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/doc/manuals/abidw.rst b/doc/manuals/abidw.rst index 1e427d32..dd72d149 100644 --- a/doc/manuals/abidw.rst +++ b/doc/manuals/abidw.rst @@ -178,6 +178,11 @@ Options In the emitted ABI representation, do not show file, line or column where ABI artifacts are defined. + * ``--no-parameter-names`` + + In the emitted ABI representation, do not show names of function + parameters, just the types. + * ``--named-type-ids`` Without this option ids used to reference types in the XML file diff --git a/include/abg-writer.h b/include/abg-writer.h index f1598a15..71b7efe6 100644 --- a/include/abg-writer.h +++ b/include/abg-writer.h @@ -68,6 +68,9 @@ set_short_locs(write_context& ctxt, bool flag); void set_named_type_ids(write_context& ctxt, bool flag); +void +set_write_parameter_names(write_context& ctxt, bool flag); + /// A convenience generic function to set common options (usually used /// by Libabigail tools) from a generic options carrying-object, into /// a given @ref write_context. @@ -86,6 +89,7 @@ set_common_options(write_context& ctxt, const OPTS& opts) set_write_architecture(ctxt, opts.write_architecture); set_write_corpus_path(ctxt, opts.write_corpus_path); set_write_comp_dir(ctxt, opts.write_comp_dir); + set_write_parameter_names(ctxt, opts.write_parameter_names); set_short_locs(ctxt, opts.short_locs); set_named_type_ids(ctxt, opts.named_type_ids); } diff --git a/src/abg-writer.cc b/src/abg-writer.cc index c240443c..6c57166f 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -221,6 +221,7 @@ class write_context bool m_write_architecture; bool m_write_corpus_path; bool m_write_comp_dir; + bool m_write_parameter_names; bool m_short_locs; bool m_named_type_ids; mutable type_ptr_map m_type_id_map; @@ -257,6 +258,7 @@ public: m_write_architecture(true), m_write_corpus_path(true), m_write_comp_dir(true), + m_write_parameter_names(true), m_short_locs(false), m_named_type_ids(false) {} @@ -370,6 +372,20 @@ public: set_named_type_ids(bool f) {m_named_type_ids = f;} + /// Getter of the parameter-names option. + /// + /// @return true iff parameter names shall be emitted + bool + get_write_parameter_names() const + {return m_write_parameter_names;} + + /// Setter of the parameter-names option + /// + /// @param f the new value of the flag. + void + set_write_parameter_names(bool f) + {m_write_parameter_names = f;} + /// Getter of the "show-locs" option. /// /// When this option is true then the XML writer emits location @@ -2112,6 +2128,18 @@ void set_named_type_ids(write_context& ctxt, bool flag) {ctxt.set_named_type_ids(flag);} +/// Set the 'parameter-names' flag. +/// +/// When this flag is set then the XML writer will emit the names of +/// function parameters. +/// +/// @param ctxt the context to set this flag on to. +/// +/// @param flag the new value of the 'parameter-names' flag. +void +set_write_parameter_names(write_context& ctxt, bool flag) +{ctxt.set_write_parameter_names(flag);} + /// Serialize the canonical types of a given scope. /// /// @param scope the scope to consider. @@ -3225,7 +3253,7 @@ write_function_decl(const function_decl_sptr& decl, write_context& ctxt, << "'"; ctxt.record_type_as_referenced(parm_type); - if (!(*pi)->get_name().empty()) + if (ctxt.get_write_parameter_names() && !(*pi)->get_name().empty()) o << " name='" << (*pi)->get_name() << "'"; } write_is_artificial(*pi, o); diff --git a/tools/abidw.cc b/tools/abidw.cc index 7251c98d..510a0707 100644 --- a/tools/abidw.cc +++ b/tools/abidw.cc @@ -99,6 +99,7 @@ struct options bool write_architecture; bool write_corpus_path; bool write_comp_dir; + bool write_parameter_names; bool short_locs; bool load_all_types; bool linux_kernel_mode; @@ -120,6 +121,7 @@ struct options write_architecture(true), write_corpus_path(true), write_comp_dir(true), + write_parameter_names(true), short_locs(false), load_all_types(), linux_kernel_mode(true), @@ -168,6 +170,7 @@ display_usage(const string& prog_name, ostream& out) << " --drop-undefined-syms drop undefined symbols from representation\n" << " --named_type-ids use id attributes based on type names in XML file\n" << " --no-comp-dir-path do not show compilation path information\n" + << " --no-parameter-names do not show names of function parameters\n" << " --check-alternate-debug-info check alternate debug info " "of \n" << " --check-alternate-debug-info-base-name check alternate " @@ -288,6 +291,8 @@ parse_command_line(int argc, char* argv[], options& opts) opts.short_locs = true; else if (!strcmp(argv[i], "--no-comp-dir-path")) opts.write_comp_dir = false; + else if (!strcmp(argv[i], "--no-parameter-names")) + opts.write_parameter_names = false; else if (!strcmp(argv[i], "--check-alternate-debug-info") || !strcmp(argv[i], "--check-alternate-debug-info-base-name")) { -- 2.18.2