2336a3cb |
diff -Naurp gcc-7.3.0-orig/gcc/c/c-typeck.c gcc-7.3.0/gcc/c/c-typeck.c
--- gcc-7.3.0-orig/gcc/c/c-typeck.c 2017-06-08 12:12:38.381833000 -0700
+++ gcc-7.3.0/gcc/c/c-typeck.c 2018-04-24 14:44:50.222592671 -0700
@@ -48,6 +48,8 @@ along with GCC; see the file COPYING3. |
0d7cac48 |
#include "c-family/c-ubsan.h" |
d1e05467 |
#include "cilk.h"
#include "gomp-constants.h"
+#include "plugin-api.h"
+#include "plugin.h" |
2336a3cb |
#include "spellcheck-tree.h" |
0d7cac48 |
#include "gcc-rich-location.h" |
d1e05467 |
|
2336a3cb |
@@ -5452,6 +5454,12 @@ build_c_cast (location_t loc, tree type, |
d1e05467 |
return error_mark_node;
}
+ {
+ tree cast_info[] {type, TREE_TYPE(value)};
+ invoke_plugin_callbacks (PLUGIN_TYPE_CAST, cast_info);
+ } |
2336a3cb |
+ |
d1e05467 |
+
if (type == TYPE_MAIN_VARIANT (TREE_TYPE (value)))
{ |
0d7cac48 |
if (RECORD_OR_UNION_TYPE_P (type)) |
2336a3cb |
diff -Naurp gcc-7.3.0-orig/gcc/plugin.c gcc-7.3.0/gcc/plugin.c
--- gcc-7.3.0-orig/gcc/plugin.c 2017-03-21 04:50:18.693898000 -0700
+++ gcc-7.3.0/gcc/plugin.c 2018-04-24 14:46:13.956372418 -0700
@@ -471,6 +471,7 @@ register_callback (const char *plugin_na |
d1e05467 |
case PLUGIN_EARLY_GIMPLE_PASSES_END:
case PLUGIN_NEW_PASS:
case PLUGIN_INCLUDE_FILE:
+ case PLUGIN_TYPE_CAST:
{
struct callback_info *new_callback;
if (!callback) |
2336a3cb |
@@ -551,6 +552,7 @@ invoke_plugin_callbacks_full (int event, |
d1e05467 |
case PLUGIN_EARLY_GIMPLE_PASSES_END:
case PLUGIN_NEW_PASS:
case PLUGIN_INCLUDE_FILE:
+ case PLUGIN_TYPE_CAST:
{
/* Iterate over every callback registered with this event and
call it. */ |
2336a3cb |
diff -Naurp gcc-7.3.0-orig/gcc/plugin.def gcc-7.3.0/gcc/plugin.def
--- gcc-7.3.0-orig/gcc/plugin.def 2017-01-01 04:07:43.905435000 -0800
+++ gcc-7.3.0/gcc/plugin.def 2018-04-24 14:47:02.209408557 -0700
@@ -99,6 +99,9 @@ DEFEVENT (PLUGIN_NEW_PASS) |
d1e05467 |
as a const char* pointer. */
DEFEVENT (PLUGIN_INCLUDE_FILE)
+/* Called when expression is casted to some type. */
+DEFEVENT (PLUGIN_TYPE_CAST)
+
/* When adding a new hard-coded plugin event, don't forget to edit in
file plugin.c the functions register_callback and
invoke_plugin_callbacks_full accordingly! */ |