From patchwork Tue Feb 6 17:24:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85371 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 43BCD385841D for ; Tue, 6 Feb 2024 17:25:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id C9EDF3858D33 for ; Tue, 6 Feb 2024 17:24:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9EDF3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C9EDF3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707240294; cv=none; b=q1UFoZp2/MYHfNQ02FwkQKdMYiJyAMIeosuyg1culkgeyh21fsGn8D+DQY5XAEywc99xXK4l3k0ioHVeqQRGTN/Js7yy5I4u4e9L69p5w+52+3U23sOWwIXpauOOV5fw7Sw8SgZ4kvpX9pc1kaerMvit5Lhq1iLSYk9KFPgFHnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707240294; c=relaxed/simple; bh=2zxxwILsidxCiZiEy+0kd2BZBZTRW89n0TyB5elQ4D0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=w0Mh7HaJzWbn/DFb+x5NFLnASjCYGGXJYCtQ4nxxU1gCHadZA5AUdPCv2ZIgc0aN6tTrq8RD6cKEVXPecasA74+PEvClkL+d/i3u/bf62cED0sSuZ427AIb5WsHOccu1kMF/+DxWmkpY2rlyPN+qpg1vpeXuyTcdFop25ENtWAU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7c3e01a7fd2so90657539f.1 for ; Tue, 06 Feb 2024 09:24:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1707240291; x=1707845091; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0XqK/n0d0+rDhjppezUpNh7Rii/FRDnyGjwCKdpDWCY=; b=NJ2p4YHzKF+Cqv/fatuLDAoMNHd1Cx6qrYAhbMLBvNkLYISzC/c8yA6W5HrGu4X708 hpCMNd8yu2iSR6Ep7rwFa2QT0MNWmKSqF2oVda2NaDH7MoPRvDVtKLQ9mEe/wzCLB8xI w/Mv+Qbk5SjXGTK1lxZObIYs1CSQMKcZAtP63dZw3lH+j2jIq0CPr0o4UtvPKuKA91+d sls1YYGFePT6/MzOJzE44DR/viaCZBzijoctvQpuDybkOUjp/2r1PhnadcQ6DUM7ehIc fEWD8lBilDWav0axah5g7xW+eCg7a/TSXKPvhG2C17NRXpwkcF0iA+wa7aGWDLWjTwPw i8yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240291; x=1707845091; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0XqK/n0d0+rDhjppezUpNh7Rii/FRDnyGjwCKdpDWCY=; b=bEUHZDBPlTCznxejFg33sIulkTi2PhEb/GlMmKGbBOcJPlJzdS062RBXxsZhGlU65n kL/KJXiBwB5ULx9y9QYJVWRGhLnki0toSoWUzmUcrXe9XiT2NnZgvSbG14m5Qsig0P9F wxUCyGJhE1l8ZSYES3ucQR5IqzTetO8oODTAKRysx/cqCYbUScRGl+VzUbJ3Pe9OQoCG F770aYgIJZXMFjUIlpUCeGHvQd8q64fv1HbwxlQjS+ZRT446+JCok3izZP0SeBH3M0w8 AWfbhNfKjQRUy/n+iNb8vS1LHjeSQeu2AB0QjwCS1H9M83ICYlaHSHTHPXGqc+0FLsOP LKOA== X-Gm-Message-State: AOJu0YzlwI3dJ414ANxas/hz3gYfKnzYc6tP/xsBoGaJh7rro3dzVufm 4n2ngM3ETNNGECxc0GrLF7fizgSHn/Ua9Ie8tbU8xmBO1rQuFSdpHPhnkAI/OED/I9h5jFBmPr0 = X-Google-Smtp-Source: AGHT+IEkbfbC8CoPzus7d/jAHDuF7T+VmASlSb1muahFkWR/lfSN+rv46xMDum9DP+X7P8hM5ZaMhA== X-Received: by 2002:a5e:d507:0:b0:7c0:2ea2:4d9c with SMTP id e7-20020a5ed507000000b007c02ea24d9cmr2952260iom.21.1707240290999; Tue, 06 Feb 2024 09:24:50 -0800 (PST) Received: from localhost.localdomain (97-122-68-157.hlrn.qwest.net. [97.122.68.157]) by smtp.gmail.com with ESMTPSA id k2-20020a02c762000000b0046ecafac861sm625369jao.153.2024.02.06.09.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:24:50 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use bool in dynamic type code Date: Tue, 6 Feb 2024 10:24:41 -0700 Message-ID: <20240206172441.3439889-1-tromey@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This changes some of the dynamic-type-related code to use bool rather than int. Regression tested on x86-64 Fedora 38. --- gdb/gdbtypes.c | 52 +++++++++++++++++++++++++------------------------- gdb/gdbtypes.h | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index dcd7321d979..f1e9d7077d8 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2038,8 +2038,8 @@ array_type_has_dynamic_stride (struct type *type) /* Worker for is_dynamic_type. */ -static int -is_dynamic_type_internal (struct type *type, int top_level) +static bool +is_dynamic_type_internal (struct type *type, bool top_level) { type = check_typedef (type); @@ -2057,20 +2057,20 @@ is_dynamic_type_internal (struct type *type, int top_level) if (TYPE_DATA_LOCATION (type) != NULL && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST)) - return 1; + return true; if (TYPE_ASSOCIATED_PROP (type)) - return 1; + return true; if (TYPE_ALLOCATED_PROP (type)) - return 1; + return true; struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS); if (prop != nullptr && prop->kind () != PROP_TYPE) - return 1; + return true; if (TYPE_HAS_DYNAMIC_LENGTH (type)) - return 1; + return true; switch (type->code ()) { @@ -2082,7 +2082,7 @@ is_dynamic_type_internal (struct type *type, int top_level) of the range type are static. It allows us to assume that the subtype of a static range type is also static. */ return (!has_static_range (type->bounds ()) - || is_dynamic_type_internal (type->target_type (), 0)); + || is_dynamic_type_internal (type->target_type (), false)); } case TYPE_CODE_STRING: @@ -2093,15 +2093,15 @@ is_dynamic_type_internal (struct type *type, int top_level) gdb_assert (type->num_fields () == 1); /* The array is dynamic if either the bounds are dynamic... */ - if (is_dynamic_type_internal (type->index_type (), 0)) - return 1; + if (is_dynamic_type_internal (type->index_type (), false)) + return true; /* ... or the elements it contains have a dynamic contents... */ - if (is_dynamic_type_internal (type->target_type (), 0)) - return 1; + if (is_dynamic_type_internal (type->target_type (), false)) + return true; /* ... or if it has a dynamic stride... */ if (array_type_has_dynamic_stride (type)) - return 1; - return 0; + return true; + return false; } case TYPE_CODE_STRUCT: @@ -2117,8 +2117,8 @@ is_dynamic_type_internal (struct type *type, int top_level) if (type->field (i).is_static ()) continue; /* If the field has dynamic type, then so does TYPE. */ - if (is_dynamic_type_internal (type->field (i).type (), 0)) - return 1; + if (is_dynamic_type_internal (type->field (i).type (), false)) + return true; /* If the field is at a fixed offset, then it is not dynamic. */ if (type->field (i).loc_kind () != FIELD_LOC_KIND_DWARF_BLOCK) @@ -2128,26 +2128,26 @@ is_dynamic_type_internal (struct type *type, int top_level) handled via other means. */ if (is_cplus && BASETYPE_VIA_VIRTUAL (type, i)) continue; - return 1; + return true; } } break; } - return 0; + return false; } /* See gdbtypes.h. */ -int +bool is_dynamic_type (struct type *type) { - return is_dynamic_type_internal (type, 1); + return is_dynamic_type_internal (type, true); } static struct type *resolve_dynamic_type_internal (struct type *type, struct property_addr_info *addr_stack, - const frame_info_ptr &frame, int top_level); + const frame_info_ptr &frame, bool top_level); /* Given a dynamic range type (dyn_range_type) and a stack of struct property_addr_info elements, return a static version @@ -2237,7 +2237,7 @@ resolve_dynamic_range (struct type *dyn_range_type, static_target_type = resolve_dynamic_type_internal (dyn_range_type->target_type (), - addr_stack, frame, 0); + addr_stack, frame, false); LONGEST bias = dyn_range_type->bounds ()->bias; type_allocator alloc (dyn_range_type); static_range_type = create_range_type_with_stride @@ -2474,7 +2474,7 @@ resolve_dynamic_union (struct type *type, continue; t = resolve_dynamic_type_internal (resolved_type->field (i).type (), - addr_stack, frame, 0); + addr_stack, frame, false); resolved_type->field (i).set_type (t); struct type *real_type = check_typedef (t); @@ -2718,7 +2718,7 @@ resolve_dynamic_struct (struct type *type, resolved_type->field (i).set_type (resolve_dynamic_type_internal (resolved_type->field (i).type (), - &pinfo, frame, 0)); + &pinfo, frame, false)); gdb_assert (resolved_type->field (i).loc_kind () == FIELD_LOC_KIND_BITPOS); @@ -2764,7 +2764,7 @@ static struct type * resolve_dynamic_type_internal (struct type *type, struct property_addr_info *addr_stack, const frame_info_ptr &frame, - int top_level) + bool top_level) { struct type *real_type = check_typedef (type); struct type *resolved_type = nullptr; @@ -2885,7 +2885,7 @@ resolve_dynamic_type (struct type *type, if (in_frame != nullptr) frame = *in_frame; - return resolve_dynamic_type_internal (type, &pinfo, frame, 1); + return resolve_dynamic_type_internal (type, &pinfo, frame, true); } /* See gdbtypes.h */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 20f68885d6a..435a040544a 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2633,7 +2633,7 @@ extern struct type *resolve_dynamic_type See the caveat in 'resolve_dynamic_type' to understand a scenario where an apparently-resolved type may still be considered "dynamic". */ -extern int is_dynamic_type (struct type *type); +extern bool is_dynamic_type (struct type *type); extern struct type *check_typedef (struct type *);