From patchwork Thu Aug 1 14:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 95045 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 86E2B386102B for ; Thu, 1 Aug 2024 15:31:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 7F2563861034 for ; Thu, 1 Aug 2024 15:00:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F2563861034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F2563861034 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524487; cv=none; b=HLmrCVRudyQ92vB7Rm6Il47344uFLG3AjARmVWpVjVcrkYJSYjZ0kskYgxLAvNygV2UK1UDcXJzcv72yieC9VkQ/D9do+JjJdbZr9sSM+7X0x/AFGGbekoU6+StPvXS4NRqTBVwL8j3XWlUQJsDHOJHZcVBGr0vM1+wxBf/Sawo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524487; c=relaxed/simple; bh=tU/s4meqMUkf+FeLedpG1M3IthyXqlO8JRvm86CzERk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tpRzsXHpA5Mj0UojMe9uK+mdzgyqBrkbuJSAr1IaUUPFYSN1AWBPJxDMcSDmt8XUzEYP7VBvQ05uLJJfZiFQB1/FAGU8TfWiiZL6jtKwpgu/1zjPaigdFZJWkwtX/Ag6tr+euwHbxgWWm9181NjxotE5DZuInSer/gFnto+VXAg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5b391c8abd7so6075531a12.2 for ; Thu, 01 Aug 2024 08:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524435; x=1723129235; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1CTgh+H66ymPTG5vdh5B70nJDN54cnVWKqIP1Q64Kxo=; b=GqP0DeuDBlyGlUCg+p8ukbzGOO1jv5ywon3aH2o5pmjQAa9ZVZTHLuz/wPO7qmiewk EyyohJ9ZQWw0mKiLz3JgjCrx2WMobIxmAtVzap/RphsCkKhkDKSYpTuT3UugTAFvhubY FW14teOiysIDqET6lrnoB6/O2th+qxAy9rQVz2C0ywNKYtfSla1elaATBzNUgfcTPbzY UnVcUmCNq8Qpl5ZvWxyLBy5Tq3ACd2cxoYkv3+6GbrBpmoYDUGyUAt7Ly83waJT3p511 h2ZVnsQXV/xpd/5L/6DhD9ZTSN6ObVcxlszgv051W7Y2T0EmwulHo0CZb23FYv3i8zI9 MMdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524435; x=1723129235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1CTgh+H66ymPTG5vdh5B70nJDN54cnVWKqIP1Q64Kxo=; b=s7MYRtRX7U3uIqBj48DSZHJG3SaK7enAHya2GpH1OhwD6h6k3pGxPLuegIbjNbeIpW kzT0Y6fnWwC1NfvvKn/d6ayTC9exs8xK8MClMlF0klUZe1PowlJ1C0RyGVaclPoSUrfh LFaE6hOtOdTfTN0xMGjWJjzm9YzQN8N9aHqZnA42DZBKi+1MToVSGJSmiRC5nXujNvuU T/McBUeCTEc4aaqU8mGll/6dBzjfGJP5sKS8DyQyUS4GO/N6dsI8UZ4jJIIEWzyOB9Vj FnnHlC5R6o8KWNY8v6Q+J7z1QPfDbHlsrdLSJnSCoTg/0uQQupwsDN2AnrO+Yiq4e7GE OcbQ== X-Gm-Message-State: AOJu0Yz9LEcuq9TayXnGndsTedtqp1hrN0wNmlEsh7tZRLPOAzJ+8Qgx y2KyzcQgCgyCHvCoSDkX/M/pGYAW8gjnsB7oqhCbp0PnOS/Qmh2AxGIMb3zRQyrGSgRwDUSrnBd 7WYme X-Google-Smtp-Source: AGHT+IE79XnbtAgmVN2qZ0rc1LXxqwbD6JEy7lmmYWmWotKPJS9BPugaeglop3ifJVSjWIumqUYVuw== X-Received: by 2002:a05:6402:389:b0:5a1:ef24:e9dc with SMTP id 4fb4d7f45d1cf-5b7f0dcfeebmr488758a12.0.1722524435340; Thu, 01 Aug 2024 08:00:35 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.08.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:00:35 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak Subject: [PATCH 113/125] gccrs: borrowck: BIR: Place tree traverse API Date: Thu, 1 Aug 2024 16:57:49 +0200 Message-ID: <20240801145809.366388-115-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801145809.366388-2-arthur.cohen@embecosm.com> References: <20240801145809.366388-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.2 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 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-place.h: Create place tree traverse API. Signed-off-by: Jakub Dupak --- .../checks/errors/borrowck/rust-bir-place.h | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h index ccc820121cc..e62ec3557ad 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h @@ -229,6 +229,29 @@ public: places[place].tyty}); } + template void for_each_path_from_root (PlaceId var, FN fn) const + { + PlaceId current = var; + current = places[current].path.first_child; + while (current != INVALID_PLACE) + { + fn (current); + for_each_path_from_root (current, fn); + current = places[current].path.next_sibling; + } + } + + template + void for_each_path_segment (PlaceId place_id, FN fn) const + { + PlaceId current = place_id; + while (current != INVALID_PLACE) + { + fn (current); + current = places[current].path.parent; + } + } + private: static bool is_type_copy (TyTy::BaseType *ty) {