]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Deleted the as_string ASR and HIR dumps
authorM V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
Fri, 14 Apr 2023 12:59:48 +0000 (18:29 +0530)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:11 +0000 (18:34 +0100)
Fixes #2021, #2022
Deleted Parser::debug_dump_ast_output, removed any functions that called
it i.e Session::dump_ast and Session::dump_ast_expanded, and any
associated items.

Made it so that when you use the dump option "expanded" it dumps the
pretty ast only.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::debug_dump_ast_output): Removed this funtion.
* rust-session-manager.cc (Session::enable_dump): Removed else if (arg == "parse").
(Session::compile_crate): Removed calls of dump_ast and dump_ast_expanded.
(Session::dump_ast): Removed this function.
(Session::dump_ast_expanded): Removed this function.
* rust-session-manager.h (struct CompileOptions): Removed the PARSER_AST_DUMP option.

Signed-off-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
gcc/rust/parse/rust-parse-impl.h
gcc/rust/rust-session-manager.cc
gcc/rust/rust-session-manager.h

index c3aeda2e7c0b01a2c2aa11380515509213a75793..0fb96dcfb516d3992ac2a8c84ccbcef39d39dae5 100644 (file)
@@ -15189,13 +15189,4 @@ Parser<ManagedTokenSource>::done_end ()
   const_TokenPtr t = lexer.peek_token ();
   return (t->get_id () == RIGHT_CURLY || t->get_id () == END_OF_FILE);
 }
-
-// Parses crate and dumps AST to stderr, recursively.
-template <typename ManagedTokenSource>
-void
-Parser<ManagedTokenSource>::debug_dump_ast_output (AST::Crate &crate,
-                                                  std::ostream &out)
-{
-  out << crate.as_string ();
-}
 } // namespace Rust
index b1e14fab8c26c39f5c3aef5503d59657c9cc063a..25b56b726c390ccc9e4a9c900b297b7f385ef049 100644 (file)
@@ -283,7 +283,7 @@ Session::enable_dump (std::string arg)
     {
       rust_error_at (
        Location (),
-       "dump option was not given a name. choose %<lex%>, %<parse%>, "
+       "dump option was not given a name. choose %<lex%>, "
        "%<register_plugins%>, %<injection%>, %<expansion%>, %<resolution%>,"
        " %<target_options%>, %<hir%>, or %<all%>");
       return false;
@@ -297,10 +297,6 @@ Session::enable_dump (std::string arg)
     {
       options.enable_dump_option (CompileOptions::LEXER_DUMP);
     }
-  else if (arg == "parse")
-    {
-      options.enable_dump_option (CompileOptions::PARSER_AST_DUMP);
-    }
   else if (arg == "ast-pretty")
     {
       options.enable_dump_option (CompileOptions::AST_DUMP_PRETTY);
@@ -495,10 +491,6 @@ Session::compile_crate (const char *filename)
   handle_crate_name (*ast_crate.get ());
 
   // dump options except lexer dump
-  if (options.dump_option_enabled (CompileOptions::PARSER_AST_DUMP))
-    {
-      dump_ast (parser, *ast_crate.get ());
-    }
   if (options.dump_option_enabled (CompileOptions::AST_DUMP_TOKENSTREAM))
     {
       dump_tokenstream (*ast_crate.get ());
@@ -572,7 +564,6 @@ Session::compile_crate (const char *filename)
     {
       // dump AST with expanded stuff
       rust_debug ("BEGIN POST-EXPANSION AST DUMP");
-      dump_ast_expanded (parser, parsed_crate);
       dump_ast_pretty (parsed_crate, true);
       rust_debug ("END POST-EXPANSION AST DUMP");
     }
@@ -894,22 +885,6 @@ Session::expansion (AST::Crate &crate)
   rust_debug ("finished expansion");
 }
 
-void
-Session::dump_ast (Parser<Lexer> &parser, AST::Crate &crate) const
-{
-  std::ofstream out;
-  out.open (kASTDumpFile);
-  if (out.fail ())
-    {
-      rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
-                    kASTDumpFile);
-      return;
-    }
-
-  parser.debug_dump_ast_output (crate, out);
-  out.close ();
-}
-
 void
 Session::dump_ast_pretty (AST::Crate &crate, bool expanded) const
 {
@@ -950,22 +925,6 @@ Session::dump_tokenstream (AST::Crate &crate) const
   out.close ();
 }
 
-void
-Session::dump_ast_expanded (Parser<Lexer> &parser, AST::Crate &crate) const
-{
-  std::ofstream out;
-  out.open (kASTExpandedDumpFile);
-  if (out.fail ())
-    {
-      rust_error_at (Linemap::unknown_location (), "cannot open %s:%m; ignored",
-                    kASTExpandedDumpFile);
-      return;
-    }
-
-  parser.debug_dump_ast_output (crate, out);
-  out.close ();
-}
-
 void
 Session::dump_hir (HIR::Crate &crate) const
 {
index a4e6400ea30faa72231214e6292244bdf3fdde43..910f097e0be4499020653c83ca20f093244a8cdc 100644 (file)
@@ -166,7 +166,6 @@ struct CompileOptions
   enum DumpOption
   {
     LEXER_DUMP,
-    PARSER_AST_DUMP,
     AST_DUMP_PRETTY,
     AST_DUMP_TOKENSTREAM,
     REGISTER_PLUGINS_DUMP,
@@ -226,7 +225,6 @@ struct CompileOptions
   void enable_all_dump_options ()
   {
     enable_dump_option (DumpOption::LEXER_DUMP);
-    enable_dump_option (DumpOption::PARSER_AST_DUMP);
     enable_dump_option (DumpOption::AST_DUMP_PRETTY);
     enable_dump_option (DumpOption::AST_DUMP_TOKENSTREAM);
     enable_dump_option (DumpOption::REGISTER_PLUGINS_DUMP);
@@ -343,10 +341,8 @@ private:
   bool enable_dump (std::string arg);
 
   void dump_lex (Parser<Lexer> &parser) const;
-  void dump_ast (Parser<Lexer> &parser, AST::Crate &crate) const;
   void dump_ast_pretty (AST::Crate &crate, bool expanded = false) const;
   void dump_tokenstream (AST::Crate &crate) const;
-  void dump_ast_expanded (Parser<Lexer> &parser, AST::Crate &crate) const;
   void dump_hir (HIR::Crate &crate) const;
   void dump_hir_pretty (HIR::Crate &crate) const;
   void dump_type_resolution (HIR::Crate &crate) const;