From patchwork Tue Feb 21 12:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 60031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1839321wrn; Tue, 21 Feb 2023 04:42:53 -0800 (PST) X-Google-Smtp-Source: AK7set9wljGmoe4hJ5IxNkGlgc5eUC4yEK8/sye1pkdqR/lkPuuGWCIiEkIgvC3ljWWCM6kuR/9y X-Received: by 2002:a50:ec94:0:b0:4ab:2504:c7ff with SMTP id e20-20020a50ec94000000b004ab2504c7ffmr5563501edr.23.1676983373746; Tue, 21 Feb 2023 04:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676983373; cv=none; d=google.com; s=arc-20160816; b=sVv0fZ3HOgWGxSNovKI5p9JQlii8QN7kltPnlI8QwCwkTjQCVhVMXTiTB6vcShk0bm IGDFPIhmSqKokdNgG1KCSfyV4Vd+ggayAalGcjHRIyYn2Nemkdg2fKfdzMz/rnJg0olY o234DnwgdnTpnmblW98nZCaMwXbo/K41LQrKzAuaz9RzvC69BgdOjTm5CBlDzOen1gok UkzjRMXUuedo8fXyNs78lGLRlK28LhxLxx6O9MphLOExHUr+QYjhEvRcfL0QGTN0ADRo ba1AZTKlwoCE32Blu/5PyZs2tU3kPZbzm3zVXPoWJ3YyPxlkfqzWvvYJAaIoqdgGh5tE 1TNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dmarc-filter :delivered-to; bh=b4l4lMg+R/elc2tKtPjjaADgQ8YpFK0wm0cOTUenBgw=; b=E2iIeHyKSuRcQNDEH6qTTsTOgTMtn6kNjAUTKCzbOh0TFzDlPZ/hZ4aSGHl8DKW7J/ xOt0F4/u7oIWJ9geL2IRPs/Okvm+tDWGMNZdKzqtG6jElL/ajzOBjyHMV4VDdJEJcJDF QTLmChFhM5ag1ExAxYiaOXTo+TWHgftTKojT3UUBKLY5Y1wDVAQwbZ6DSDh5l2r+JO0h +n+h8MwVbnLl+dX+BT5yg3TjT5KVHcRzD5kbJEGmWEW8C+NgZjf1JYjFn8ruBZ10vKo+ 0sRp+/Mxk7tIZYCwZL3RUp35gGC8uoKyDAgDEx5fMeJPNKnnrC9pb2wncmi4l3HRcqrL t7PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=a1dKDhPm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o11-20020aa7d3cb000000b004acc4ee372bsi3189799edr.475.2023.02.21.04.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:42:53 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=a1dKDhPm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2403F39E7B53 for ; Tue, 21 Feb 2023 12:14:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id AE3C63846934 for ; Tue, 21 Feb 2023 12:04:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE3C63846934 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42c.google.com with SMTP id bo30so3604029wrb.0 for ; Tue, 21 Feb 2023 04:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=b4l4lMg+R/elc2tKtPjjaADgQ8YpFK0wm0cOTUenBgw=; b=a1dKDhPmQ76T4qe9Rt7MkoCH1VVIJvsbDkn5jFr46GDjLdfH2lnfkr+zNtYYvfnGAU fuwRiHK9eCK29vs7FwEpK5vKYIwyjOFB/k9FuwY4P3h9uS4U8SMfpj0W3OKcU9YK6u9C BkvyU3lsWwCy5+7k43/e7o92aC3yD1cP4E8hL0U/7+M7HeB4NkaJMF4jsgXPpA9e9iSV i7rTG/konDWRKuOzbO/MFckgUJvPkA1WES5bYhhrfjHo481KUCoM/sN5xfte/pbvv/Mm +aQ8UznwKuZfxOkQkxuVHQjnpzRHGcskajCNyAK6/JlurG5iIjBgaVg7LxOtoOyoEqUW Y5EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to: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=b4l4lMg+R/elc2tKtPjjaADgQ8YpFK0wm0cOTUenBgw=; b=3pr4IJ+1E5ab3Ph0TWS0uDNMbU7HVjlg9smK5nrM39eJkO8BaCbFF01qrwKDDZJ5VU z3r8UB3BCFKL05SKVDiZivZKjQY8v2N/vVsE6A5pCHDIB9Yf++o7br+RQxUnFpzn0iwU hESTVt73ReMvt0AzIWP4io544eFg2NRJxNTNkglqJKu+cTo7mFfeCnrtpeUWk2LftSYf F4efMo3xDxNsV3MCunux+F5kaxSfyaLqiHBkjmvt0voDHMjCzAqfycGijYJ6WepeAOwO 8nGXnyF3vy7BiqDMi5TAE1zDaUQ1ZEvHJp2HgN9V6eagEpDwn6Z225mpCVp/nm6Xtt95 OQeA== X-Gm-Message-State: AO0yUKVfygi0dq1RRXDQydHPLr5yAXNtND3aJ9sPGAuvLucwK9nVh978 If0fm38MCOmr+ZdzPBab87qaoDSljpfpmw0EXw== X-Received: by 2002:a5d:6089:0:b0:2c5:5936:16db with SMTP id w9-20020a5d6089000000b002c5593616dbmr3922014wrt.42.1676981066064; Tue, 21 Feb 2023 04:04:26 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:25 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak Subject: [committed 076/103] gccrs: ast: Dump raw pointer type Date: Tue, 21 Feb 2023 13:02:06 +0100 Message-Id: <20230221120230.596966-77-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.7 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758444518064098745?= X-GMAIL-MSGID: =?utf-8?q?1758444518064098745?= From: Jakub Dupak gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add missing RawPointer visitor. Signed-off-by: Jakub Dupak --- gcc/rust/ast/rust-ast-dump.cc | 200 +++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 88 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 9f73d0565ac..e6d6e070709 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -269,7 +269,7 @@ Dump::visit (DelimTokenTree &delim_tok_tree) } void -Dump::visit (AttrInputMetaItemContainer &input) +Dump::visit (AttrInputMetaItemContainer &) {} void @@ -311,7 +311,7 @@ Dump::visit (LifetimeParam &lifetime_param) } void -Dump::visit (ConstGenericParam &lifetime_param) +Dump::visit (ConstGenericParam &) {} // rust-path.h @@ -322,15 +322,15 @@ Dump::visit (PathInExpression &path) } void -Dump::visit (TypePathSegment &segment) +Dump::visit (TypePathSegment &) {} void -Dump::visit (TypePathSegmentGeneric &segment) +Dump::visit (TypePathSegmentGeneric &) {} void -Dump::visit (TypePathSegmentFunction &segment) +Dump::visit (TypePathSegmentFunction &) {} void @@ -346,7 +346,7 @@ Dump::visit (QualifiedPathInExpression &path) } void -Dump::visit (QualifiedPathInType &path) +Dump::visit (QualifiedPathInType &) {} // rust-expr.h @@ -357,15 +357,15 @@ Dump::visit (LiteralExpr &expr) } void -Dump::visit (AttrInputLiteral &attr_input) +Dump::visit (AttrInputLiteral &) {} void -Dump::visit (MetaItemLitExpr &meta_item) +Dump::visit (MetaItemLitExpr &) {} void -Dump::visit (MetaItemPathLit &meta_item) +Dump::visit (MetaItemPathLit &) {} void @@ -623,35 +623,35 @@ Dump::visit (ArrayIndexExpr &expr) } void -Dump::visit (TupleExpr &expr) +Dump::visit (TupleExpr &) {} void -Dump::visit (TupleIndexExpr &expr) +Dump::visit (TupleIndexExpr &) {} void -Dump::visit (StructExprStruct &expr) +Dump::visit (StructExprStruct &) {} void -Dump::visit (StructExprFieldIdentifier &field) +Dump::visit (StructExprFieldIdentifier &) {} void -Dump::visit (StructExprFieldIdentifierValue &field) +Dump::visit (StructExprFieldIdentifierValue &) {} void -Dump::visit (StructExprFieldIndexValue &field) +Dump::visit (StructExprFieldIndexValue &) {} void -Dump::visit (StructExprStructFields &expr) +Dump::visit (StructExprStructFields &) {} void -Dump::visit (StructExprStructBase &expr) +Dump::visit (StructExprStructBase &) {} void @@ -669,15 +669,15 @@ Dump::visit (CallExpr &expr) } void -Dump::visit (MethodCallExpr &expr) +Dump::visit (MethodCallExpr &) {} void -Dump::visit (FieldAccessExpr &expr) +Dump::visit (FieldAccessExpr &) {} void -Dump::visit (ClosureExprInner &expr) +Dump::visit (ClosureExprInner &) {} void @@ -696,15 +696,15 @@ Dump::visit (BlockExpr &expr) } void -Dump::visit (ClosureExprInnerTyped &expr) +Dump::visit (ClosureExprInnerTyped &) {} void -Dump::visit (ContinueExpr &expr) +Dump::visit (ContinueExpr &) {} void -Dump::visit (BreakExpr &expr) +Dump::visit (BreakExpr &) {} void @@ -730,7 +730,7 @@ Dump::visit (RangeToExpr &expr) } void -Dump::visit (RangeFullExpr &expr) +Dump::visit (RangeFullExpr &) { stream << ".."; } @@ -751,27 +751,27 @@ Dump::visit (RangeToInclExpr &expr) } void -Dump::visit (ReturnExpr &expr) +Dump::visit (ReturnExpr &) {} void -Dump::visit (UnsafeBlockExpr &expr) +Dump::visit (UnsafeBlockExpr &) {} void -Dump::visit (LoopExpr &expr) +Dump::visit (LoopExpr &) {} void -Dump::visit (WhileLoopExpr &expr) +Dump::visit (WhileLoopExpr &) {} void -Dump::visit (WhileLetLoopExpr &expr) +Dump::visit (WhileLetLoopExpr &) {} void -Dump::visit (ForLoopExpr &expr) +Dump::visit (ForLoopExpr &) {} void @@ -807,35 +807,35 @@ Dump::visit (IfExprConseqIf &expr) } void -Dump::visit (IfExprConseqIfLet &expr) +Dump::visit (IfExprConseqIfLet &) {} void -Dump::visit (IfLetExpr &expr) +Dump::visit (IfLetExpr &) {} void -Dump::visit (IfLetExprConseqElse &expr) +Dump::visit (IfLetExprConseqElse &) {} void -Dump::visit (IfLetExprConseqIf &expr) +Dump::visit (IfLetExprConseqIf &) {} void -Dump::visit (IfLetExprConseqIfLet &expr) +Dump::visit (IfLetExprConseqIfLet &) {} void -Dump::visit (MatchExpr &expr) +Dump::visit (MatchExpr &) {} void -Dump::visit (AwaitExpr &expr) +Dump::visit (AwaitExpr &) {} void -Dump::visit (AsyncBlockExpr &expr) +Dump::visit (AsyncBlockExpr &) {} // rust-item.h @@ -959,23 +959,23 @@ Dump::visit (Module &module) } void -Dump::visit (ExternCrate &crate) +Dump::visit (ExternCrate &) {} void -Dump::visit (UseTreeGlob &use_tree) +Dump::visit (UseTreeGlob &) {} void -Dump::visit (UseTreeList &use_tree) +Dump::visit (UseTreeList &) {} void -Dump::visit (UseTreeRebind &use_tree) +Dump::visit (UseTreeRebind &) {} void -Dump::visit (UseDeclaration &use_decl) +Dump::visit (UseDeclaration &) {} void @@ -1117,11 +1117,11 @@ Dump::visit (Union &union_item) } void -Dump::visit (ConstantItem &const_item) +Dump::visit (ConstantItem &) {} void -Dump::visit (StaticItem &static_item) +Dump::visit (StaticItem &) {} void @@ -1259,7 +1259,7 @@ Dump::visit (TraitImpl &impl) } void -Dump::visit (ExternalStaticItem &item) +Dump::visit (ExternalStaticItem &) {} void @@ -1386,36 +1386,36 @@ Dump::visit (MacroRulesDefinition &rules_def) } void -Dump::visit (MacroInvocation ¯o_invoc) +Dump::visit (MacroInvocation &) {} void -Dump::visit (MetaItemPath &meta_item) +Dump::visit (MetaItemPath &) {} void -Dump::visit (MetaItemSeq &meta_item) +Dump::visit (MetaItemSeq &) {} void -Dump::visit (MetaWord &meta_item) +Dump::visit (MetaWord &) {} void -Dump::visit (MetaNameValueStr &meta_item) +Dump::visit (MetaNameValueStr &) {} void -Dump::visit (MetaListPaths &meta_item) +Dump::visit (MetaListPaths &) {} void -Dump::visit (MetaListNameValueStr &meta_item) +Dump::visit (MetaListNameValueStr &) {} // rust-pattern.h void -Dump::visit (LiteralPattern &pattern) +Dump::visit (LiteralPattern &) {} void @@ -1425,88 +1425,88 @@ Dump::visit (IdentifierPattern &pattern) } void -Dump::visit (WildcardPattern &pattern) +Dump::visit (WildcardPattern &) {} -// void Dump::visit(RangePatternBound& bound){} +// void Dump::visit(RangePatternBound& ){} void -Dump::visit (RangePatternBoundLiteral &bound) +Dump::visit (RangePatternBoundLiteral &) {} void -Dump::visit (RangePatternBoundPath &bound) +Dump::visit (RangePatternBoundPath &) {} void -Dump::visit (RangePatternBoundQualPath &bound) +Dump::visit (RangePatternBoundQualPath &) {} void -Dump::visit (RangePattern &pattern) +Dump::visit (RangePattern &) {} void -Dump::visit (ReferencePattern &pattern) +Dump::visit (ReferencePattern &) {} -// void Dump::visit(StructPatternField& field){} +// void Dump::visit(StructPatternField& ){} void -Dump::visit (StructPatternFieldTuplePat &field) +Dump::visit (StructPatternFieldTuplePat &) {} void -Dump::visit (StructPatternFieldIdentPat &field) +Dump::visit (StructPatternFieldIdentPat &) {} void -Dump::visit (StructPatternFieldIdent &field) +Dump::visit (StructPatternFieldIdent &) {} void -Dump::visit (StructPattern &pattern) +Dump::visit (StructPattern &) {} -// void Dump::visit(TupleStructItems& tuple_items){} +// void Dump::visit(TupleStructItems& ){} void -Dump::visit (TupleStructItemsNoRange &tuple_items) +Dump::visit (TupleStructItemsNoRange &) {} void -Dump::visit (TupleStructItemsRange &tuple_items) +Dump::visit (TupleStructItemsRange &) {} void -Dump::visit (TupleStructPattern &pattern) +Dump::visit (TupleStructPattern &) {} -// void Dump::visit(TuplePatternItems& tuple_items){} +// void Dump::visit(TuplePatternItems& ){} void -Dump::visit (TuplePatternItemsMultiple &tuple_items) +Dump::visit (TuplePatternItemsMultiple &) {} void -Dump::visit (TuplePatternItemsRanged &tuple_items) +Dump::visit (TuplePatternItemsRanged &) {} void -Dump::visit (TuplePattern &pattern) +Dump::visit (TuplePattern &) {} void -Dump::visit (GroupedPattern &pattern) +Dump::visit (GroupedPattern &) {} void -Dump::visit (SlicePattern &pattern) +Dump::visit (SlicePattern &) {} // rust-stmt.h void -Dump::visit (EmptyStmt &stmt) +Dump::visit (EmptyStmt &) {} void @@ -1560,40 +1560,64 @@ Dump::visit (TraitBound &bound) } void -Dump::visit (ImplTraitType &type) +Dump::visit (ImplTraitType &) {} void -Dump::visit (TraitObjectType &type) +Dump::visit (TraitObjectType &) {} void -Dump::visit (ParenthesisedType &type) +Dump::visit (ParenthesisedType &) {} void -Dump::visit (ImplTraitTypeOneBound &type) +Dump::visit (ImplTraitTypeOneBound &) {} void -Dump::visit (TraitObjectTypeOneBound &type) +Dump::visit (TraitObjectTypeOneBound &) {} void -Dump::visit (TupleType &type) +Dump::visit (TupleType &) {} void -Dump::visit (NeverType &type) +Dump::visit (NeverType &) {} void Dump::visit (RawPointerType &type) -{} +{ + // Syntax: + // * ( mut | const ) TypeNoBounds + + if (type.get_pointer_type () == RawPointerType::MUT) + stream << "*mut "; + else /* RawPointerType::CONST */ + stream << "*const "; + + visit (type.get_type_pointed_to ()); +} void Dump::visit (ReferenceType &type) { + // Syntax: + // & Lifetime? mut? TypeNoBounds + + stream << '&'; + + if (type.has_lifetime ()) + { + visit (type.get_lifetime ()); + stream << ' '; + } + + if (type.get_has_mut ()) + stream << "mut "; + visit (type.get_type_referenced ()); } @@ -1606,7 +1630,7 @@ Dump::visit (ArrayType &type) stream << '['; visit (type.get_elem_type ()); stream << "; "; - visit(type.get_size_expr()); + visit (type.get_size_expr ()); stream << ']'; } @@ -1622,13 +1646,13 @@ Dump::visit (SliceType &type) } void -Dump::visit (InferredType &type) +Dump::visit (InferredType &) { stream << "_"; } void -Dump::visit (BareFunctionType &type) +Dump::visit (BareFunctionType &) {} } // namespace AST