diff options
author | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-10-17 13:04:46 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2024-02-15 21:04:46 +0100 |
commit | 64bf05b11415d74d945841c73a281f1d635ce862 (patch) | |
tree | 2cc671cb370062ceae9d4630d435068d4eeb1790 /scripts | |
parent | 9a6c8fdfa98f3dcacd005b4bb76743c6989290ed (diff) |
scripts/code_cov_parse_info: better handle include regexes
When there are both exclude and include regexes, the include ones
may be overriding the more generic excluded ones. So, handle them
first.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/code_cov_parse_info | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/scripts/code_cov_parse_info b/scripts/code_cov_parse_info index d3739211b..ceea67a13 100755 --- a/scripts/code_cov_parse_info +++ b/scripts/code_cov_parse_info @@ -34,17 +34,24 @@ sub is_function_excluded($) my $func = shift; + # Handle includes first, as, when there are both include and exclude + # includes should take preference, as they can be overriding exclude + # rules + foreach my $r (@func_include_regexes) { + return 0 if ($func =~ m/$r/); + } + foreach my $r (@func_exclude_regexes) { return 1 if ($func =~ m/$r/); } - return 0 if (!@func_include_regexes); - - foreach my $r (@func_include_regexes) { - return 0 if ($func =~ m/$r/); + # If there are no exclude regexes, only include functions that are + # explicitly included. + if ($#func_exclude_regexes == 0) { + return 1; } - return 1; + return 0; } sub is_file_excluded($) @@ -1178,9 +1185,10 @@ Each line at B<[filter's file]> may contain a new regex: =back -When both include and exclude regexes are found, exclude regexes are -applied first and any functions that don't match the include regular -expressions from the B<[filter's file]> will be ignored. +Include regexes are handled first, as they can override an exclude regex. + +When just include regexes are used, any functions that don't match the +include regular expressions from the B<[filter's file]> will be ignored. Please notice that, when this filter is used, B<--ignore-unused> will be automaticaly enabled, as the final goal is to report per-function usage. @@ -1189,7 +1197,8 @@ automaticaly enabled, as the final goal is to report per-function usage. Include B<regex> to the function filter. Can be used multiple times. -When used together with B<--func-filters>, regexes here are handled first. +When used together with B<--func-filters> or B<--exclude-func>, regexes +here are handled first. Please notice that, when this filter is used, B<--ignore-unused> will be automaticaly enabled, as the final goal is to report per-function usage. @@ -1198,8 +1207,6 @@ automaticaly enabled, as the final goal is to report per-function usage. Include B<regex> to the function filter. Can be used multiple times. -When used together with B<--func-filters>, regexes here are handled first. - Please notice that, when this filter is used, B<--ignore-unused> will be automaticaly enabled, as the final goal is to report per-function usage. @@ -1229,22 +1236,19 @@ Each line at B<[filter's file]> may contain a new regex: =back -When both include and exclude regexes are found, exclude regexes are -applied first and any functions that don't match the include regular -expressions from the B<[filter's file]> will be ignored. +Include regexes are handled first, as they can override an exclude regex. =item B<--include-src> B<regex> Include B<regex> to the sources filter. Can be used multiple times. -When used together with B<--src-filters>, regexes here are handled first. +When used together with B<--src-filters> and B<--exclude-src>, regexes +here are handled first. =item B<--exclude-src> B<regex> Include B<regex> to the sources filter. Can be used multiple times. -When used together with B<--src-filters>, regexes here are handled first. - =item B<--ignore-unused> or B<--ignore_unused> Filters out unused C files and headers from the code coverage results. |