diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-08-29 13:37:00 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-01-31 14:16:50 +0100 |
commit | 7dc41901213d32ff9962f1d54cc6291c38d0e597 (patch) | |
tree | 3dbd53c6e69472064f60d32d4d9ddcfd858109e1 /gcc | |
parent | 252216dd0c5956dfb931031fd1f8dfa59c922160 (diff) | |
download | gcc-7dc41901213d32ff9962f1d54cc6291c38d0e597.zip gcc-7dc41901213d32ff9962f1d54cc6291c38d0e597.tar.gz gcc-7dc41901213d32ff9962f1d54cc6291c38d0e597.tar.bz2 |
gccrs: dump: Add AST debugging using the AST::Dump class
gcc/rust/ChangeLog:
* ast/rust-ast-dump.h: Add shorthand `AST::Dump::debug` function to
dump an AST node on `stderr`.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-ast-dump.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h index 4fa4db9..955dbc0 100644 --- a/gcc/rust/ast/rust-ast-dump.h +++ b/gcc/rust/ast/rust-ast-dump.h @@ -52,6 +52,22 @@ public: void go (AST::Crate &crate); void go (AST::Item &item); + /** + * Use the AST Dump as a debugging tool + */ + template <typename T> static void debug (T &instance) + { + auto dump = Dump (std::cerr); + + std::cerr << '\n'; + instance.accept_vis (dump); + std::cerr << '\n'; + } + template <typename T> static void debug (std::unique_ptr<T> &instance) + { + debug (*instance); + } + private: std::ostream &stream; Indent indentation; |