Dear GCC developers,

I tried to use plugin frameworks
 svn://gcc.gnu.org/svn/gcc/branches/plugin (old?) and
 svn://gcc.gnu.org/svn/gcc/branches/plugins (current).

'plugin' has transform_ctrees() API. - callback on every fndecl
'plugins' has PLUGIN_CXX_CP_PRE_GENERICIZE. - only supported in C++

This patch (for the plugins branch) allows to see AST in C.

Thanks,

Kenji Koyanagi


Index: c-decl.c
===================================================================
--- c-decl.c    (revision 144675)
+++ c-decl.c    (working copy)
@@ -63,6 +63,7 @@
 #include "langhooks-def.h"
 #include "pointer-set.h"
 #include "gimple.h"
+#include "plugin.h"

/* In grokdeclarator, distinguish syntactic contexts of declarators. */
 enum decl_context
@@ -6791,6 +6792,8 @@
     {
       if (!decl_function_context (fndecl))
        {
+         /* Invoke registered plugin callbacks if any.  */
+         invoke_plugin_callbacks (PLUGIN_C_PRE_GENERICIZE, fndecl);
          c_genericize (fndecl);
          c_gimple_diagnostics_recursively (fndecl);

Index: gcc-plugin.h
===================================================================
--- gcc-plugin.h        (revision 144675)
+++ gcc-plugin.h        (working copy)
@@ -25,6 +25,7 @@
   PLUGIN_PASS_MANAGER_SETUP,    /* To hook into pass manager.  */
PLUGIN_FINISH_STRUCT, /* After finishing parsing a struct/ class. */
   PLUGIN_FINISH_UNIT,           /* Useful for summary processing.  */
+ PLUGIN_C_PRE_GENERICIZE, /* Allows to see low level AST in C FE. */ PLUGIN_CXX_CP_PRE_GENERICIZE, /* Allows to see low level AST in C+ + FE. */
   PLUGIN_FINISH,                /* Called before GCC exits.  */
PLUGIN_EVENT_LAST /* Dummy event used for indexing callback
Index: plugin.c
===================================================================
--- plugin.c    (revision 144675)
+++ plugin.c    (working copy)
@@ -435,6 +435,7 @@
         break;
       case PLUGIN_FINISH_STRUCT:
       case PLUGIN_FINISH_UNIT:
+      case PLUGIN_C_PRE_GENERICIZE:
       case PLUGIN_CXX_CP_PRE_GENERICIZE:
       case PLUGIN_FINISH:
         {
@@ -473,6 +474,7 @@
     {
       case PLUGIN_FINISH_STRUCT:
       case PLUGIN_FINISH_UNIT:
+      case PLUGIN_C_PRE_GENERICIZE:
       case PLUGIN_CXX_CP_PRE_GENERICIZE:
       case PLUGIN_FINISH:
         {

Reply via email to