From patchwork Fri Dec 4 11:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41298 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 013D63857C71; Fri, 4 Dec 2020 11:05:20 +0000 (GMT) X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by sourceware.org (Postfix) with ESMTPS id 89C983857C61 for ; Fri, 4 Dec 2020 11:05:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 89C983857C61 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dodji@seketeli.org X-Originating-IP: 91.166.131.65 Received: from localhost (91-166-131-65.subs.proxad.net [91.166.131.65]) (Authenticated sender: dodj@seketeli.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id B948B1BF215; Fri, 4 Dec 2020 11:05:15 +0000 (UTC) Received: by localhost (Postfix, from userid 1001) id 921B81A2631; Fri, 4 Dec 2020 12:05:14 +0100 (CET) From: Dodji Seketeli To: Giuliano Procida Subject: [PATCH 1/2] ir: Add better comments to types_have_similar_structure Organization: Me, myself and I References: <20201203150916.3540551-1-gprocida@google.com> <865z5hq1eo.fsf@seketeli.org> X-Operating-System: Red Hat Enterprise Linux Server 7.8 X-URL: http://www.seketeli.net/~dodji Date: Fri, 04 Dec 2020 12:05:14 +0100 In-Reply-To: <865z5hq1eo.fsf@seketeli.org> (Dodji Seketeli's message of "Fri, 04 Dec 2020 12:02:55 +0100") Message-ID: <861rg5q1at.fsf_-_@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , Cc: kernel-team@android.com, libabigail@sourceware.org, maennich@google.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" * src/abg-ir.cc (types_have_similar_structure): Arrays are also indirect types, just like pointers and references, for the purpose of the concept of "type similarity". Add that to the introductory comment of the function. Add some more misc comments throughout the code base. Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index c6f7c13..7354ae3 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -23474,10 +23474,10 @@ types_have_similar_structure(const type_base_sptr& first, /// /// typedef are resolved to their definitions; their names are ignored. /// -/// Two indirect types (pointers or references) have similar structure -/// if their underlying types are of the same kind and have the same -/// name. In the indirect types case, the size of the underlying type -/// does not matter. +/// Two indirect types (pointers, references or arrays) have similar +/// structure if their underlying types are of the same kind and have +/// the same name. In the indirect types case, the size of the +/// underlying type does not matter. /// /// Two direct types (i.e, non indirect) have a similar structure if /// they have the same kind, name and size. Two class types have @@ -23488,7 +23488,9 @@ types_have_similar_structure(const type_base_sptr& first, /// /// @param second the second type to consider. /// -/// @param indirect_type whether to do an indirect comparison +/// @param indirect_type if true, then consider @p first and @p +/// second as being underlying types of indirect types. Meaning that +/// their size does'nt matter. /// /// @return true iff @p first and @p second have similar structures. bool @@ -23517,7 +23519,7 @@ types_have_similar_structure(const type_base* first, const pointer_type_def* ty2 = is_pointer_type(second); return types_have_similar_structure(ty1->get_pointed_to_type(), ty2->get_pointed_to_type(), - true); + /*indirect_type=*/true); } // Peel off matching references. @@ -23528,7 +23530,7 @@ types_have_similar_structure(const type_base* first, return false; return types_have_similar_structure(ty1->get_pointed_to_type(), ty2->get_pointed_to_type(), - true); + /*indirect_type=*/true); } if (const type_decl* ty1 = is_type_decl(first))