* doc/plugins.texi (enum plugin_event): New event.
* plugin.c (register_callback): Handle PLUGIN_START_PARSE_FUNCTION
and PLUGIN_FINISH_FUNCTION.
* plugin.def (PLUGIN_START_PARSE_FUNCTION): Add plugin event
(PLUGIN_FINISH_PARSE_FUNCTION): Likewise.
cp/
* decl.c (start_function): Call plugin before parsing.
(finish_function): Call plugin after parsing.
c/
* c-decl.c (start_function): Call plugin before parsing.
(finish_function): Call plugin after parsing.
testsuite/
* g++.dg/plugin/plugin.exp: Add def-plugin-test.C.
* g++.dg/plugin/def_plugin.c: New file.
* g++.dg/plugin/def-plugin-test.C: New file.
From-SVN: r224078
+2015-06-02 Andres Tiraboschi <andres.tiraboschi@tallertechnologies.com>
+
+ * doc/plugins.texi (enum plugin_event): New event.
+ * plugin.c (register_callback): Handle PLUGIN_START_PARSE_FUNCTION
+ and PLUGIN_FINISH_FUNCTION.
+ * plugin.def (PLUGIN_START_PARSE_FUNCTION): Add plugin event
+ (PLUGIN_FINISH_PARSE_FUNCTION): Likewise.
+
2015-06-03 Richard Biener <rguenther@suse.de>
* tree-vect-data-refs.c (vect_analyze_group_access): Properly
+2015-06-02 Andres Tiraboschi <andres.tiraboschi@tallertechnologies.com>
+
+ * c-decl.c (start_function): Call plugin before parsing.
+ (finish_function): Call plugin after parsing.
+
2015-06-02 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR c/49551
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, true, NULL,
&attributes, NULL, NULL, DEPRECATED_NORMAL);
+ invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1);
/* If the declarator is not suitable for a function definition,
cause a syntax error. */
It's still in DECL_STRUCT_FUNCTION, and we'll restore it in
tree_rest_of_compilation. */
set_cfun (NULL);
+ invoke_plugin_callbacks (PLUGIN_FINISH_PARSE_FUNCTION, current_function_decl);
current_function_decl = NULL;
}
\f
+2015-06-02 Andres Tiraboschi <andres.tiraboschi@tallertechnologies.com>
+
+ * decl.c (start_function): Call plugin before parsing.
+ (finish_function): Call plugin after parsing.
+
2015-06-02 Patrick Palka <patrick@parcs.ath.cx>
* cp-tree.h (init_error): Remove declaration.
tree decl1;
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
+ invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1);
if (decl1 == error_mark_node)
return false;
/* If the declarator is not suitable for a function definition,
vec_free (deferred_mark_used_calls);
}
+ invoke_plugin_callbacks (PLUGIN_FINISH_PARSE_FUNCTION, fndecl);
return fndecl;
}
\f
@smallexample
enum plugin_event
@{
+ PLUGIN_START_PARSE_FUNCTION, /* Called before parsing the body of a function. */
+ PLUGIN_FINISH_PARSE_FUNCTION, /* After finishing parsing a function. */
PLUGIN_PASS_MANAGER_SETUP, /* To hook into pass manager. */
PLUGIN_FINISH_TYPE, /* After finishing parsing a type. */
PLUGIN_FINISH_DECL, /* After finishing parsing a declaration. */
return;
}
/* Fall through. */
+ case PLUGIN_START_PARSE_FUNCTION:
+ case PLUGIN_FINISH_PARSE_FUNCTION:
case PLUGIN_FINISH_TYPE:
case PLUGIN_FINISH_DECL:
case PLUGIN_START_UNIT:
gcc_assert (event >= PLUGIN_EVENT_FIRST_DYNAMIC);
gcc_assert (event < event_last);
/* Fall through. */
+ case PLUGIN_START_PARSE_FUNCTION:
+ case PLUGIN_FINISH_PARSE_FUNCTION:
case PLUGIN_FINISH_TYPE:
case PLUGIN_FINISH_DECL:
case PLUGIN_START_UNIT:
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
+/* Called before parsing the body of a function. */
+DEFEVENT (PLUGIN_START_PARSE_FUNCTION)
+
+/* After finishing parsing a function. */
+DEFEVENT (PLUGIN_FINISH_PARSE_FUNCTION)
/* To hook into pass manager. */
DEFEVENT (PLUGIN_PASS_MANAGER_SETUP)
+2015-06-02 Andres Tiraboschi <andres.tiraboschi@tallertechnologies.com>
+
+ * g++.dg/plugin/plugin.exp: Add def-plugin-test.C.
+ * g++.dg/plugin/def_plugin.c: New file.
+ * g++.dg/plugin/def-plugin-test.C: New file.
+
2015-06-03 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/bb-slp-36.c: New testcase.
--- /dev/null
+int global = 12;
+
+int function1(void);
+
+int function2(int a) // { dg-warning "Start fndef function2" }
+{
+ return function1() + a;
+} // { dg-warning "Finish fndef function2" }
+
+int function1(void) // { dg-warning "Start fndef function1" }
+{
+ return global + 1;
+} // { dg-warning "Finish fndef function1" }
--- /dev/null
+/* A plugin example that shows which function definitions are caught by PLUGIN_START_FUNCTION and PLUGIN_FINISH_FUNCTION */
+
+#include "gcc-plugin.h"
+#include <stdlib.h>
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "tree-pass.h"
+#include "intl.h"
+#include "diagnostic.h"
+
+int plugin_is_GPL_compatible;
+
+/* Callback function to invoke when GCC starts a function definition*/
+
+void plugin_start_parse_function (void *event_data, void *data)
+{
+ tree fndef = (tree) event_data;
+ warning (0, G_("Start fndef %s"),
+ IDENTIFIER_POINTER (DECL_NAME (fndef)));
+}
+
+/* Callback function to invoke after GCC finishes a function definition. */
+
+void plugin_finish_parse_function (void *event_data, void *data)
+{
+ tree fndef = (tree) event_data;
+ warning (0, G_("Finish fndef %s"),
+ IDENTIFIER_POINTER (DECL_NAME (fndef)));
+}
+
+int
+plugin_init (struct plugin_name_args *plugin_info,
+ struct plugin_gcc_version *version)
+{
+ const char *plugin_name = plugin_info->base_name;
+
+ register_callback (plugin_name, PLUGIN_START_PARSE_FUNCTION,
+ plugin_start_parse_function, NULL);
+
+ register_callback (plugin_name, PLUGIN_FINISH_PARSE_FUNCTION,
+ plugin_finish_parse_function, NULL);
+ return 0;
+}
{ selfassign.c self-assign-test-1.C self-assign-test-2.C self-assign-test-3.C } \
{ dumb_plugin.c dumb-plugin-test-1.C } \
{ header_plugin.c header-plugin-test.C } \
- { decl_plugin.c decl-plugin-test.C } ]
+ { decl_plugin.c decl-plugin-test.C } \
+ { def_plugin.c def-plugin-test.C } ]
foreach plugin_test $plugin_test_list {
# Replace each source file with its full-path name