aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-06-13 17:24:45 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-06-13 17:24:45 +0000
commitde001ec7773be17f0fc44e3d7a6e64b8fee40581 (patch)
treed34012e01ff8cb2aa66f6d24404f42d5f4e4c6c7 /gcc/go
parent1cc56f079e60fc60df904e443784ad6e7081300c (diff)
downloadgcc-de001ec7773be17f0fc44e3d7a6e64b8fee40581.zip
gcc-de001ec7773be17f0fc44e3d7a6e64b8fee40581.tar.gz
gcc-de001ec7773be17f0fc44e3d7a6e64b8fee40581.tar.bz2
compiler: include global variable preinit blocks in ast dumps
Dump out the blocks corresponding to variable pre-inits when -fgo-dump-ast is in effect. Each preinit block is prefixed with a comment indicating the variable it is initializing. Reviewed-on: https://go-review.googlesource.com/118636 From-SVN: r261555
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/ast-dump.cc26
2 files changed, 26 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e904f7c..f656fa3 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-6743db0ed81e313acf66c00a4ed0e2dcaaca2c9f
+1f07926263b6d14edb6abd6a00e6385190d30d0e
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/ast-dump.cc b/gcc/go/gofrontend/ast-dump.cc
index 94bf5ef..1fbc890 100644
--- a/gcc/go/gofrontend/ast-dump.cc
+++ b/gcc/go/gofrontend/ast-dump.cc
@@ -29,7 +29,7 @@ class Ast_dump_traverse_blocks_and_functions : public Traverse
{
public:
Ast_dump_traverse_blocks_and_functions(Ast_dump_context* ast_dump_context)
- : Traverse(traverse_blocks | traverse_functions),
+ : Traverse(traverse_blocks | traverse_functions | traverse_variables),
ast_dump_context_(ast_dump_context)
{ }
@@ -40,6 +40,9 @@ class Ast_dump_traverse_blocks_and_functions : public Traverse
int
function(Named_object*);
+ int
+ variable(Named_object*);
+
private:
Ast_dump_context* ast_dump_context_;
};
@@ -150,6 +153,27 @@ Ast_dump_traverse_blocks_and_functions::function(Named_object* no)
return TRAVERSE_CONTINUE;
}
+// Dump variable preinits
+
+int
+Ast_dump_traverse_blocks_and_functions::variable(Named_object* no)
+{
+ if (!no->is_variable())
+ return TRAVERSE_CONTINUE;
+
+ Variable* var = no->var_value();
+ if (var->has_pre_init())
+ {
+ this->ast_dump_context_->ostream() << "// preinit block for var "
+ << no->message_name() << "\n";
+ var->preinit()->traverse(this);
+ }
+
+ return TRAVERSE_CONTINUE;
+}
+
+
+
// Class Ast_dump_context.
Ast_dump_context::Ast_dump_context(std::ostream* out /* = NULL */,