From 08272b175a32928fc917debb8deead76b9ae3d66 Mon Sep 17 00:00:00 2001 From: York Jasper Niebuhr Date: Fri, 17 Oct 2025 22:09:17 +0200 Subject: [PATCH] Updated playground --- playground/commands.txt | 4 ++++ playground/plugin.cpp | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/playground/commands.txt b/playground/commands.txt index b181cef..0f3812f 100644 --- a/playground/commands.txt +++ b/playground/commands.txt @@ -6,3 +6,7 @@ make all-target-libstdc++-v3 -j8 ./gcc/xg++ -B./gcc/ -shared -fPIC -fno-rtti -I ../gcc/include -I ../gcc/gcc plugin.cpp -I ./gcc -I ./x86_64-pc-linux-gnu/libstdc++-v3/include -I ./x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I ../gcc/libstdc++-v3/include -I ../gcc/libstdc++-v3/libsupc++ -I ../gcc/libcpp/include -L ./x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -o myplugin.so ./gcc/xgcc -B./gcc -fplugin=./myplugin.so -fdump-tree-original test.c -o test + +git log +git format-patch -1 +python3 contrib/check_GNU_style.py gcc_component_ref.patch diff --git a/playground/plugin.cpp b/playground/plugin.cpp index c7763de..99e14ec 100644 --- a/playground/plugin.cpp +++ b/playground/plugin.cpp @@ -19,9 +19,6 @@ #include #include -typedef tree (*c_component_ref_hook_fn) (tree ref); -extern "C" void c_register_component_ref_hook (c_component_ref_hook_fn hook); - int plugin_is_GPL_compatible; struct MemberOffset { @@ -264,15 +261,23 @@ static tree my_component_ref_cb (tree ref) return new_ref; // ALWAYS an INDIRECT_REF, directly to the member (same type as COMPONENT_REF!) } +static void build_component_ref_cb(void* event_data, void* user_data) { + tree* component_ref_node = (tree*)event_data; + if (!component_ref_node) + return; + + tree repl = my_component_ref_cb(*component_ref_node); + if (repl) + *component_ref_node = repl; +} + int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { if (!plugin_default_version_check(version, &gcc_version)) { std::cerr << "GCC version mismatch!" << std::endl; return 1; } - c_register_component_ref_hook(my_component_ref_cb); - - // register_callback(plugin_info->base_name, PLUGIN_ATTRIBUTES, register_attributes, NULL); + register_callback(plugin_info->base_name, PLUGIN_BUILD_COMPONENT_REF, build_component_ref_cb, NULL); struct register_pass_info access_discover_pass_info; access_discover_pass_info.pass = new access_discover_pass(nullptr);