aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-06-01 10:44:16 +0000
committerGitHub <noreply@github.com>2022-06-01 10:44:16 +0000
commit0866a4fbc6e7f70cd3708467419c60af8c6104f2 (patch)
treec590b511d30ca79d4babda5575614aa1d67a49ec /gcc/rust/backend/rust-compile-expr.h
parent998f1f73c2626f7ffa9655058e306b7f4e07c584 (diff)
parent573b6298596fae8708982c65db0b66b989299805 (diff)
downloadgcc-0866a4fbc6e7f70cd3708467419c60af8c6104f2.zip
gcc-0866a4fbc6e7f70cd3708467419c60af8c6104f2.tar.gz
gcc-0866a4fbc6e7f70cd3708467419c60af8c6104f2.tar.bz2
Merge #1287
1287: Add AST dump visitor r=CohenArthur a=CohenArthur This adds a base for pretty printing our AST through a new visitor (Addresses #1261). This adds enough code to pretty print "functions" without types in the parameters or return type. Looking for feedback on the implementation before we keep going with more code :) Here's a tiny patch if you want to see the output whenever you're running `-frust-dump-all`: ```diff diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 0b0e5af915f..3e39c6a6e17 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc `@@` -31,6 +31,7 `@@` #include "rust-cfg-parser.h" #include "rust-lint-scan-deadcode.h" #include "rust-lint-unused-var.h" +#include "rust-ast-dump.h" #include "diagnostic.h" #include "input.h" `@@` -1023,6 +1024,8 `@@` Session::dump_ast (Parser<Lexer> &parser, AST::Crate &crate) const parser.debug_dump_ast_output (crate, out); out.close (); + + AST::Dump (std::cerr).go (crate); } void ``` output: ```rust arthur@platypus ~/G/r/gccrs (add-ast-dump-visitor) [1]> cat test.rs fn foo0(a: i32) { let a = 15; let b: i32 = 15; } fn foo1(a: &i32) {} struct S; fn foo2(a: S) {} fn foo3(a: S) -> i32 {} arthur@platypus ~/G/r/gccrs (add-ast-dump-visitor)> build/gcc/rust1 test.rs -frust-dump-all fn foo0(a: ) { let a = ; let b: = ; } fn foo1(a: ) { } fn foo2(a: ) { } fn foo3(a: ) -> { } test.rs:11:1: error: expected [i32] got [()] 11 | fn foo3(a: S) -> i32 {} | ^ ~ Analyzing compilation unit Time variable usr sys wall GGC phase setup : 0.00 ( 0%) 0.00 ( 0%) 0.01 (100%) 129k ( 94%) TOTAL : 0.00 0.00 0.01 137k Extra diagnostic checks enabled; compiler may run slowly. Configure with --enable-checking=release to disable checks. ``` Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
0 files changed, 0 insertions, 0 deletions