From 84f0e2b44eecc30026cbbeb1dc8df098f11fcf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9otime=20DONNENFELD?= <theotime.donnenfeld@ensiie.fr> Date: Mon, 22 Oct 2018 10:02:18 +0200 Subject: [PATCH] FINI LES PRAGMAS AHA --- TODOLIST | 2 +- functions/pragma.c | 16 +++++++++++++--- plugin.cpp | 11 ++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/TODOLIST b/TODOLIST index 2234957..d899bc8 100644 --- a/TODOLIST +++ b/TODOLIST @@ -14,5 +14,5 @@ Ne pas mettre deux fois la meme fonction via les pragmas : Oui Pas de pragma dans les fonctions : Oui -Warning envoyé si l'utilisateur a donné une fonction qui n'existe pas dans le source : Non +Warning envoyé si l'utilisateur a donné une fonction qui n'existe pas dans le source : Oui diff --git a/functions/pragma.c b/functions/pragma.c index 078fc96..5ddb90f 100644 --- a/functions/pragma.c +++ b/functions/pragma.c @@ -100,16 +100,26 @@ static void register_my_pragma(void *event_data, void *data) void compare_pragma_funcs_analyzed_funcs(){ const char *pragma_elt; const char *analyzed_elt; + bool pragma_func_is_in; + + //printf("\nEntering COMPARE FUNCS:\n\n"); + for(int ix = 0; pragma_func_names.iterate (ix, &pragma_elt); ix++){ + pragma_func_is_in = false; for(int jx = 0; analyzed_functions.iterate (jx, &analyzed_elt); jx++){ - if(strcmp(pragma_elt, analyzed_elt)!=0) - printf("WARNING :Pragma indicates unexisting function %s\n ",pragma_elt ); + //printf("\nComparing : %s and %s", pragma_elt, analyzed_elt); + if(strcmp(pragma_elt, analyzed_elt)==0) + pragma_func_is_in = true; } + if(!pragma_func_is_in) + printf("\nWARNING - pragma func : %s is not declared in source code", pragma_elt); } } - +void add_function_to_analyzed_funcs(function * fun){ + analyzed_functions.safe_push(function_name(fun)); +} diff --git a/plugin.cpp b/plugin.cpp index 687fd70..5678e83 100755 --- a/plugin.cpp +++ b/plugin.cpp @@ -74,7 +74,8 @@ class split_count_pass : public gimple_opt_pass bool gate (function * fun) { bool func_to_be_analyzed = true; - + + add_function_to_analyzed_funcs(fun); printf("=> plugin: split_count_pass... \n"); printf("=> plugin: gate... \n"); @@ -131,8 +132,7 @@ class cleanup_pass : public gimple_opt_pass /* Gate function (shall we apply this pass?) */ bool gate (function * fun) { - bool func_to_be_analyzed = true; - printf("=> plugin: cleanup_pass... \n"); + printf("=> plugin: cleanup_pass... \n"); printf("=> plugin: gate... \n"); return true; } @@ -142,10 +142,15 @@ class cleanup_pass : public gimple_opt_pass /* Execute function */ unsigned int execute (function *fun) { + const char *elt; printf("=> plugin: cleanup_pass... \n"); printf("=> plugin: execute...\n"); printf("... in function %s\n\n", function_name(fun)); + printf("State of vec analyzed :\n"); + for (int ix = 0; analyzed_functions.iterate (ix, &elt); ix++){ + printf("- %s\n", elt); + } compare_pragma_funcs_analyzed_funcs(); edit_all_aux_value(fun,(int*)NULL); return 0; -- GitLab