From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id 6BD1538654A1 for ; Thu, 1 Aug 2024 15:00:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BD1538654A1 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 6BD1538654A1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::236 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524491; cv=none; b=kUPXZmChqgmX1kRwFivdHQzyg1IZObGG8/Ug2C7e3HcXmCB0Gpt5HeM9qxdhfGXIO5C7riLG56isnymSVlNpmBYDUow9tr0TYqS0Tyfs2ZlTzQT6M9P04kJh2qw1ZGyEuY8wMeKbehdmyUUNPOrhMynpLOmZgwfhEY7XuuYR8XQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524491; c=relaxed/simple; bh=dJIGMjqFHdKBQf+xn/mYTbH4R5pjSbOZrOydC78SsEA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iRCgFZOZaPZh8sXIL1zVWLCUPLszJ26cuiNwmtkxzFu1JC1qaPEmSs3w09iiDX6sqo/shjNIxPwgk8NNdZuYA4A7XzbEXEapuIgIwf323ZbQKpY7ma1hgPgNnYl/X/MFmNNidnY8MPVFfAhU9mvG5GD2MmhcnVRZAWoUxoMjp4o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2f0dfdc9e16so88644081fa.2 for ; Thu, 01 Aug 2024 08:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524438; x=1723129238; 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=Os6qBEgd6+KM1kTef8vPWVsEd33/xFanDU9D5Fjh7Yw=; b=QW4JlvA0b1I8enesFFxsIr1+rcJugLa+FbtaiRcKP9jEsytK/XhiAdXWAhk1UnV0rI Fvm7G2+amZjvyid/Q7enumj+nta5mJdEODgM9sMIqYhjPrRtgb3DFuzTUkfSdpNM2EEV GrTZjOYKXLzowguy0JCO95uNNL920GF8E/BLQTOIn19gO38HoKGoqnF4/0H/ZBCVLciC pt+HflsqsTzJ7X/28WlA37O0FJeDF5dAj6AxSWcSW+6LeCxPcfmBkRdPio6GdUuimDKw Rje8EeRqj6B26ZqBQVptnxl+99vde4oNQn6iPVM9kRbT1k+JbVp5RvfDegTZeYpdpfQj nnQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524438; x=1723129238; 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=Os6qBEgd6+KM1kTef8vPWVsEd33/xFanDU9D5Fjh7Yw=; b=l9fzOXJnTP+YiE/bbtyJ2QVrvtfT+yaA0+2QkCtrY8mDl0wr6jkkzalzq5LgXHpAQS OBkMfYHgUwhrLTC6SZK3y7YNU9Qb2FtDEICBBbE1viEA0ZvRv56hemuqWoV+cZMB1XVr AsXSncxyV/Hth3ztyALI5CbcogxnXMOCFLMl+x8JffhGF7YcfPaCjvkcoRLSZODlVxUc EJt2nVVnyzrApfCn9gAqxmawH5HyQR7bQuHmb93KOC736+/cHYV/vh89+Gpo9C3UGbO7 dvZvv032O85DrPdcAkb+ogbdHsr4lSs37kB9dhTEiUQFZ4RxPkkMDPKeKPFhVLruD00T pkUA== X-Gm-Message-State: AOJu0YxrTB8mjlu5PBNDRYcPxkNUVlxshIg/5Oww0H5tplyRRuclQtkf 7ellQ4V4th6PXFGkOVhKDx7GMQ/NycIjMGsrq/x8Tw2zWw10YAwhmaWauwBGlDKhuR4fNQgSRou SnOLX X-Google-Smtp-Source: AGHT+IFpPg9hI+bJPT/j2yYcv2ihEZO8g/LwH6g1Wp9MT+ccGV8MbBTnEu6C1HMY4O9bjzNgpVSyhg== X-Received: by 2002:a05:6512:3e15:b0:52e:be2c:4b05 with SMTP id 2adb3069b0e04-530bb391d97mr118826e87.21.1722524438232; Thu, 01 Aug 2024 08:00:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:00:38 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak Subject: [PATCH 116/125] gccrs: borrowck: BIR: make BIR visitor const Date: Thu, 1 Aug 2024 16:57:52 +0200 Message-ID: <20240801145809.366388-118-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 Content-Transfer-Encoding: 8bit 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 List-Id: From: Jakub Dupak gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): const visitor * checks/errors/borrowck/rust-bir-dump.h: const visitor * checks/errors/borrowck/rust-bir-visitor.h: const visitor * checks/errors/borrowck/rust-bir.h: const getter Signed-off-by: Jakub Dupak --- gcc/rust/checks/errors/borrowck/rust-bir-dump.cc | 14 +++++++------- gcc/rust/checks/errors/borrowck/rust-bir-dump.h | 14 +++++++------- gcc/rust/checks/errors/borrowck/rust-bir-visitor.h | 14 +++++++------- gcc/rust/checks/errors/borrowck/rust-bir.h | 6 +++++- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc index 320b653f830..6f1579df1d9 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc +++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc @@ -155,7 +155,7 @@ Dump::go (bool enable_simplify_cfg) stream << "}\n"; } void -Dump::visit (Statement &stmt) +Dump::visit (const Statement &stmt) { statement_place = stmt.get_place (); switch (stmt.get_kind ()) @@ -247,7 +247,7 @@ Dump::visit_move_place (PlaceId place_id) } void -Dump::visit (BorrowExpr &expr) +Dump::visit (const BorrowExpr &expr) { stream << "&"; visit_lifetime (statement_place); @@ -268,7 +268,7 @@ Dump::visit_lifetime (PlaceId place_id) } void -Dump::visit (InitializerExpr &expr) +Dump::visit (const InitializerExpr &expr) { stream << "{"; print_comma_separated (stream, expr.get_values (), [this] (PlaceId place_id) { @@ -278,7 +278,7 @@ Dump::visit (InitializerExpr &expr) } void -Dump::visit (CallExpr &expr) +Dump::visit (const CallExpr &expr) { stream << "Call("; if (auto fn_type @@ -305,7 +305,7 @@ Dump::visit (CallExpr &expr) } void -Dump::visit (Operator<1> &expr) +Dump::visit (const Operator<1> &expr) { stream << "Operator("; visit_move_place (expr.get_operand<0> ()); @@ -313,7 +313,7 @@ Dump::visit (Operator<1> &expr) } void -Dump::visit (Operator<2> &expr) +Dump::visit (const Operator<2> &expr) { stream << "Operator("; visit_move_place (expr.get_operand<0> ()); @@ -323,7 +323,7 @@ Dump::visit (Operator<2> &expr) } void -Dump::visit (Assignment &expr) +Dump::visit (const Assignment &expr) { if (func.place_db[expr.get_rhs ()].is_rvalue ()) { diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.h b/gcc/rust/checks/errors/borrowck/rust-bir-dump.h index cc3f9cdc738..9d6babd0053 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.h @@ -49,16 +49,16 @@ public: void go (bool enable_simplify_cfg = false); protected: - void visit (Statement &stmt) override; + void visit (const Statement &stmt) override; void visit_place (PlaceId place_id); void visit_move_place (PlaceId place_id); - void visit (BorrowExpr &expr) override; + void visit (const BorrowExpr &expr) override; void visit_lifetime (PlaceId place_id); - void visit (InitializerExpr &expr) override; - void visit (CallExpr &expr) override; - void visit (Operator<1> &expr) override; - void visit (Operator<2> &expr) override; - void visit (Assignment &expr) override; + void visit (const InitializerExpr &expr) override; + void visit (const CallExpr &expr) override; + void visit (const Operator<1> &expr) override; + void visit (const Operator<2> &expr) override; + void visit (const Assignment &expr) override; void visit_scope (ScopeId id, size_t depth = 1); std::ostream &indent (size_t depth); diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h b/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h index 7ad62f700db..2371b8bb5ce 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h @@ -32,13 +32,13 @@ class CallExpr; class Visitor { public: - virtual void visit (Statement &stmt) = 0; - virtual void visit (InitializerExpr &expr) = 0; - virtual void visit (Operator<1> &expr) = 0; - virtual void visit (Operator<2> &expr) = 0; - virtual void visit (BorrowExpr &expr) = 0; - virtual void visit (Assignment &expr) = 0; - virtual void visit (CallExpr &expr) = 0; + virtual void visit (const Statement &stmt) = 0; + virtual void visit (const InitializerExpr &expr) = 0; + virtual void visit (const Operator<1> &expr) = 0; + virtual void visit (const Operator<2> &expr) = 0; + virtual void visit (const BorrowExpr &expr) = 0; + virtual void visit (const Assignment &expr) = 0; + virtual void visit (const CallExpr &expr) = 0; }; class Visitable diff --git a/gcc/rust/checks/errors/borrowck/rust-bir.h b/gcc/rust/checks/errors/borrowck/rust-bir.h index f8a2151aaf8..d21cb90abf5 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir.h @@ -137,6 +137,10 @@ public: public: std::vector &get_values () { return values; } + WARN_UNUSED_RESULT const std::vector &get_values () const + { + return values; + } }; template @@ -199,7 +203,7 @@ public: {} public: - const std::vector &get_arguments () { return arguments; } + const std::vector &get_arguments () const { return arguments; } WARN_UNUSED_RESULT PlaceId get_callable () const { return callable; } }; -- 2.45.2