diff --git a/functions/pragma.c b/functions/pragma.c index 95085db619142e40d6bfcd2f300f0e3c1f4500ff..a98fc77296017de060036e714e957413aad379ab 100644 --- a/functions/pragma.c +++ b/functions/pragma.c @@ -1,5 +1,8 @@ #include "pragma.h" +vec<const char*> pragma_func_names; +vec<const char*> pragma_func_names_temp; + static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) { printf("****** Pragam detected: ******\n"); @@ -8,11 +11,11 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) const char* elt; token = pragma_lex (&x); bool close_paren_needed_p = false; - bool correct_pragma_names = true; - bool is_in_array=false; + + if (cfun){ printf("!!Pragma placed inside function!!\n"); - correct_pragma_names = false; + return; } @@ -31,14 +34,8 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) args = tree_cons (NULL_TREE, x, args); printf("Arg found : %s\n", IDENTIFIER_POINTER(x)); - is_in_array = false; - for (int ix = 0; pragma_func_names.iterate (ix, &elt); ix++){ - if(strcmp(elt,IDENTIFIER_POINTER(x))){ - is_in_array = true; - } - } - if(is_in_array) - pragma_func_names_temp.safe_push(IDENTIFIER_POINTER(x)); + + pragma_func_names_temp.safe_push(IDENTIFIER_POINTER(x)); token = pragma_lex (&x); //Cleans COMAS while (token == CPP_COMMA){ @@ -56,7 +53,7 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) } else{ printf("Missing closed parenthesis\n"); - correct_pragma_names = false; + return; } } @@ -70,11 +67,11 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) if (token != CPP_EOF) { printf("Error : arg read but EOL not reached"); - correct_pragma_names = false; + return; } - while(pragma_func_names_temp.length() != 0 && correct_pragma_names){ + while(pragma_func_names_temp.length() != 0){ pragma_func_names.safe_push(pragma_func_names_temp.pop()); } @@ -84,7 +81,7 @@ static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)) static void register_my_pragma(void *event_data, void *data) { - c_register_pragma ("instrumente", "function", my_pragma_action); + c_register_pragma ("ProjetCA", "mpicoll_check", my_pragma_action); } diff --git a/functions/pragma.h b/functions/pragma.h index 625efe58a30c224763a46c8f8fdb9e6b6a423c9d..5fdc1607969e18c94f6a40a3fff3437e38431daa 100644 --- a/functions/pragma.h +++ b/functions/pragma.h @@ -1,8 +1,6 @@ #ifndef __PRAGMADD__H #define __PRAGMADD__H -vec<const char*> pragma_func_names; -vec<const char*> pragma_func_names_temp; static void register_my_pragma(void *event_data, void *data); static void my_pragma_action(cpp_reader *ARG_UNUSED(dummy)); diff --git a/plugin.cpp b/plugin.cpp index 566b6b359e4ed807cc5d12955b3a113b2a2310ed..ff70c3541ead07c469b92ea13936691a42323d35 100755 --- a/plugin.cpp +++ b/plugin.cpp @@ -121,6 +121,12 @@ class cleanup_pass : public gimple_opt_pass { printf("=> plugin: cleanup_pass... \n"); printf("=> plugin: gate... \n"); + printf("List of functions to be checked :\n"); + while(pragma_func_names.length() != 0){ + printf("- %s\n",pragma_func_names.pop()); + } + + return true; } @@ -131,6 +137,7 @@ class cleanup_pass : public gimple_opt_pass { printf("=> plugin: cleanup_pass... \n"); printf("=> plugin: execute...\n"); + printf("... in function %s\n\n", function_name(fun)); edit_all_aux_value(fun,(int*)NULL); return 0; diff --git a/tests/pragma_test.c b/tests/pragma_test.c index dbbfd9d5e07f7ffbb01979f220c094933946d35c..0589c902b3d0952dc1be6cbcc1d72dd88bbe899a 100755 --- a/tests/pragma_test.c +++ b/tests/pragma_test.c @@ -5,17 +5,17 @@ #include <stdio.h> #include "pragma_test.h" -#pragma instrumente function mock1 -#pragma instrumente function mock2 -#pragma instrumente function mock3,mock5 -#pragma instrumente function (mock4,mock6) -#pragma instrumente function CANARD -#pragma instrumente function mock1 -#pragma instrumente function (coincoin +#pragma ProjetCA mpicoll_check mock1 +#pragma ProjetCA mpicoll_check mock2 +#pragma ProjetCA mpicoll_check mock3,mock5 +#pragma ProjetCA mpicoll_check (mock4,mock6) +#pragma ProjetCA mpicoll_check CANARD +#pragma ProjetCA mpicoll_check mock1 +#pragma ProjetCA mpicoll_check (coincoin void mock1() { printf("mock1\n"); - #pragma instrumente function MOCK1 + #pragma ProjetCA mpicoll_check MOCK1 } void mock2() {