@@ -291,6 +291,8 @@ sub write_overview(*$$$$);
291
291
# External prototype (defined in genpng)
292
292
sub gen_png ($$$$$@);
293
293
294
+ sub simplify_function_name ($);
295
+
294
296
package SummaryInfo ;
295
297
296
298
our @selectCallbackScript ;
@@ -5471,7 +5473,7 @@ sub _computeAge
5471
5473
if ($then > $now ) {
5472
5474
if (lcovutil::warn_once($lcovutil::ERROR_INCONSISTENT_DATA , $path )) {
5473
5475
# issue annotation warning at most once per file
5474
- # also attempt to clarify where the date comes from
5476
+ # also attempt to clarify where the date comes from
5475
5477
my $data =
5476
5478
exists ($ENV {SOURCE_DATE_EPOCH }) ?
5477
5479
(
@@ -6853,10 +6855,14 @@ our @rate_png = ("ruby.png", "amber.png", "emerald.png");
6853
6855
our $rc_desc_html = 0; # lcovrc: genhtml_desc_html
6854
6856
our $deprecated_highlight ; # ignored former option
6855
6857
6856
- our $cwd = cwd(); # Current working directory
6858
+ # simplify/shorten names in 'function detail table'
6859
+ our @simplifyFunctionScript ; # the arg list
6860
+ our $simplifyFunctionCallback ; # the actual callback
6861
+
6862
+ our $cwd = cwd(); # Current working directory
6857
6863
6858
6864
# for debugging
6859
- our $verboseScopeRegexp ; # dump categorization processing if match
6865
+ our $verboseScopeRegexp ; # dump categorization processing if match
6860
6866
6861
6867
#
6862
6868
# Code entry point
@@ -6869,7 +6875,8 @@ STDERR->autoflush;
6869
6875
STDOUT -> autoflush;
6870
6876
6871
6877
my @datebins ;
6872
- my (@rc_date_bins , @rc_annotate_script , @rc_select_script , @rc_date_labels );
6878
+ my (@rc_date_bins , @rc_annotate_script , @rc_select_script , @rc_date_labels ,
6879
+ @rc_simplifyFunctionScript );
6873
6880
6874
6881
my %genhtml_rc_opts = (
6875
6882
" genhtml_css_file" => \$css_filename ,
@@ -6925,6 +6932,7 @@ my %genhtml_rc_opts = (
6925
6932
' genhtml_annotate_script' => \@rc_annotate_script ,
6926
6933
' genhtml_annotate_tooltip' => \$SourceFile::annotateTooltip ,
6927
6934
" select_script" => \@rc_select_script ,
6935
+ " simplify_function" => \@rc_simplifyFunctionScript ,
6928
6936
' num_context_lines' => \$InInterestingRegion::num_context_lines ,
6929
6937
' genhtml_date_bins' => \@rc_date_bins ,
6930
6938
' genhtml_date_labels' => \@rc_date_labels ,
@@ -6938,60 +6946,62 @@ my $save;
6938
6946
my $serialize ;
6939
6947
my $validateHTML = exists ($ENV {LCOV_VALIDATE });
6940
6948
6941
- my %genhtml_options = (" output-directory|o=s" => \$output_directory ,
6942
- " header-title=s" => \$header_title ,
6943
- " footer=s" => \$footer ,
6944
- " title|t=s" => \$test_title ,
6945
- " description-file|d=s" => \$desc_filename ,
6946
- " keep-descriptions|k" => \$keep_descriptions ,
6947
- " css-file|c=s" => \$css_filename ,
6948
- " baseline-file|b=s" => \@base_filenames ,
6949
- " baseline-title=s" => \$baseline_title ,
6950
- " baseline-date=s" => \$baseline_date ,
6951
- " current-date=s" => \$current_date ,
6952
- " diff-file=s" => \$diff_filename ,
6953
- " annotate-script=s" => \@SourceFile::annotateScript ,
6954
- " select-script=s" => \@selectCallbackScript ,
6955
- " new-file-as-baseline" => \$treatNewFileAsBaseline ,
6956
- ' elide-path-mismatch' => \$elide_path_mismatch ,
6957
- ' synthesize-missing' => \$synthesizeMissingFile ,
6958
- # if 'show-owners' is set: generate the owner table
6959
- # if it is passed a value: show all the owners,
6960
- # regardless of whether they have uncovered code or not
6961
- ' show-owners:s' => \$show_ownerBins ,
6962
- ' show-noncode' => \$show_nonCodeOwners ,
6963
- ' show-zero-columns' => \$show_zeroTlaColumns ,
6964
- ' simplified-colors' => \$show_simplifiedColors ,
6965
- " date-bins=s" => \@datebins ,
6966
- ' date-labels=s' => \@SummaryInfo::ageGroupHeader ,
6967
- " prefix|p=s" => \@opt_dir_prefix ,
6968
- " num-spaces=i" => \$tab_size ,
6969
- " no-prefix" => \$no_prefix ,
6970
- " no-sourceview" => \$no_sourceview ,
6971
- ' no-html' => \$no_html ,
6972
- " show-details|s" => \$show_details ,
6973
- " frames|f" => \$frames ,
6974
- " highlight" => \$deprecated_highlight ,
6975
- " legend" => \$legend ,
6976
- ' save' => \$save ,
6977
- ' serialize=s' => \$serialize ,
6978
- ' scheduler+' => \$debugScheduler ,
6979
- " html-prolog=s" => \$html_prolog_file ,
6980
- " html-epilog=s" => \$html_epilog_file ,
6981
- " html-extension=s" => \$html_ext ,
6982
- " html-gzip" => \$html_gzip ,
6983
- " hierarchical" => \$hierarchical ,
6984
- " flat" => \$flat ,
6985
- " sort-tables" => \$sort_tables ,
6986
- " no-sort" => \$no_sort ,
6987
- " precision=i" => \$lcovutil::default_precision ,
6988
- " missed" => \$opt_missed ,
6989
- " dark-mode" => \$dark_mode ,
6990
- " show-navigation" => \$show_tla ,
6991
- " show-proportion" => \$show_functionProportions ,
6992
- " merge-aliases" => \$merge_function_aliases ,
6993
- " suppress-aliases" => \$suppress_function_aliases ,
6994
- ' validate' => \$validateHTML ,);
6949
+ my %genhtml_options = (
6950
+ " output-directory|o=s" => \$output_directory ,
6951
+ " header-title=s" => \$header_title ,
6952
+ " footer=s" => \$footer ,
6953
+ " title|t=s" => \$test_title ,
6954
+ " description-file|d=s" => \$desc_filename ,
6955
+ " keep-descriptions|k" => \$keep_descriptions ,
6956
+ " css-file|c=s" => \$css_filename ,
6957
+ " baseline-file|b=s" => \@base_filenames ,
6958
+ " baseline-title=s" => \$baseline_title ,
6959
+ " baseline-date=s" => \$baseline_date ,
6960
+ " current-date=s" => \$current_date ,
6961
+ " diff-file=s" => \$diff_filename ,
6962
+ " annotate-script=s" => \@SourceFile::annotateScript ,
6963
+ " select-script=s" => \@SummaryInfo::selectCallbackScript ,
6964
+ " simplify-script=s" => \@simplifyFunctionScript ,
6965
+ " new-file-as-baseline" => \$treatNewFileAsBaseline ,
6966
+ ' elide-path-mismatch' => \$elide_path_mismatch ,
6967
+ ' synthesize-missing' => \$synthesizeMissingFile ,
6968
+ # if 'show-owners' is set: generate the owner table
6969
+ # if it is passed a value: show all the owners,
6970
+ # regardless of whether they have uncovered code or not
6971
+ ' show-owners:s' => \$show_ownerBins ,
6972
+ ' show-noncode' => \$show_nonCodeOwners ,
6973
+ ' show-zero-columns' => \$show_zeroTlaColumns ,
6974
+ ' simplified-colors' => \$show_simplifiedColors ,
6975
+ " date-bins=s" => \@datebins ,
6976
+ ' date-labels=s' => \@SummaryInfo::ageGroupHeader ,
6977
+ " prefix|p=s" => \@opt_dir_prefix ,
6978
+ " num-spaces=i" => \$tab_size ,
6979
+ " no-prefix" => \$no_prefix ,
6980
+ " no-sourceview" => \$no_sourceview ,
6981
+ ' no-html' => \$no_html ,
6982
+ " show-details|s" => \$show_details ,
6983
+ " frames|f" => \$frames ,
6984
+ " highlight" => \$deprecated_highlight ,
6985
+ " legend" => \$legend ,
6986
+ ' save' => \$save ,
6987
+ ' serialize=s' => \$serialize ,
6988
+ ' scheduler+' => \$debugScheduler ,
6989
+ " html-prolog=s" => \$html_prolog_file ,
6990
+ " html-epilog=s" => \$html_epilog_file ,
6991
+ " html-extension=s" => \$html_ext ,
6992
+ " html-gzip" => \$html_gzip ,
6993
+ " hierarchical" => \$hierarchical ,
6994
+ " flat" => \$flat ,
6995
+ " sort-tables" => \$sort_tables ,
6996
+ " no-sort" => \$no_sort ,
6997
+ " precision=i" => \$lcovutil::default_precision ,
6998
+ " missed" => \$opt_missed ,
6999
+ " dark-mode" => \$dark_mode ,
7000
+ " show-navigation" => \$show_tla ,
7001
+ " show-proportion" => \$show_functionProportions ,
7002
+ " merge-aliases" => \$merge_function_aliases ,
7003
+ " suppress-aliases" => \$suppress_function_aliases ,
7004
+ ' validate' => \$validateHTML ,);
6995
7005
6996
7006
# remove ambiguous entry from common table -
6997
7007
# (genhtml has '--sort-inputs' and '--sort-tables')
@@ -7041,18 +7051,28 @@ $frames = undef unless (defined($frames) && $frames);
7041
7051
foreach my $rc ([\@datebins , \@rc_date_bins ],
7042
7052
[\@SummaryInfo::ageGroupHeader , \@rc_date_labels ],
7043
7053
[\@SourceFile::annotateScript , \@rc_annotate_script ],
7044
- [\@selectCallbackScript , \@rc_select_script ]
7054
+ [\@SummaryInfo::selectCallbackScript , \@rc_select_script ],
7055
+ [\@simplifyFunctionScript , \@rc_simplifyFunctionScript ],
7045
7056
7046
7057
) {
7047
7058
@{$rc -> [0]} = @{$rc -> [1]} unless (@{$rc -> [0]});
7048
7059
}
7049
7060
7050
7061
foreach my $cb ([\$SourceFile::annotateCallback , \@SourceFile::annotateScript ],
7051
- [\$selectCallback , \@selectCallbackScript ]) {
7062
+ [\$SummaryInfo::selectCallback ,
7063
+ \@SummaryInfo::selectCallbackScript
7064
+ ],
7065
+ [\$simplifyFunctionCallback , \@simplifyFunctionScript ],
7066
+ ) {
7052
7067
lcovutil::configure_callback($cb -> [0], @{$cb -> [1]})
7053
7068
if scalar (@{$cb -> [1]});
7054
7069
}
7055
7070
7071
+ # we won't apply simplifications if we don't generate the table
7072
+ # (we still check that the callback is valid - even though we don't use it)
7073
+ $simplifyFunctionCallback = undef
7074
+ if $no_sourceview ;
7075
+
7056
7076
if (defined ($lcovutil::stop_on_error ) &&
7057
7077
!$lcovutil::stop_on_error ) {
7058
7078
# in the spirit of "don't stop" - don't worry about missing files.
@@ -8384,7 +8404,7 @@ sub read_testfile($)
8384
8404
local *TEST_HANDLE;
8385
8405
8386
8406
open (TEST_HANDLE, " <" , $file ) or
8387
- die (" cannot open $file ] : $! \n " );
8407
+ die (" cannot open description file ' $file ' : $! \n " );
8388
8408
8389
8409
while (<TEST_HANDLE>) {
8390
8410
chomp ($_ );
@@ -13322,7 +13342,7 @@ sub write_source($$$$$$$$)
13322
13342
my $cbdata = PrintCallback-> new($srcfile , $fileCovInfo );
13323
13343
13324
13344
my ($region , $empty );
13325
- if ($selectCallback ) {
13345
+ if ($SummaryInfo:: selectCallback ) {
13326
13346
$region = InInterestingRegion-> new($srcfile , $fileCovInfo -> lineMap());
13327
13347
$empty = ' ' ;
13328
13348
if ($srcfile -> isProjectFile()) {
@@ -13583,7 +13603,7 @@ END_OF_HTML
13583
13603
next
13584
13604
if grep (/ ^$tla $ / , (' DUB' , ' DCB' )); # don't display deleted functions
13585
13605
my $startline = $funcEntry -> line() - $func_offset ;
13586
- my $name = $func ;
13606
+ my $name = simplify_function_name( $func ) ;
13587
13607
my $countstyle ;
13588
13608
13589
13609
# Escape special characters
@@ -13701,7 +13721,7 @@ END_OF_HTML
13701
13721
}
13702
13722
13703
13723
# Escape special characters
13704
- $alias = escape_html($alias );
13724
+ $alias = escape_html(simplify_function_name( $alias ) );
13705
13725
13706
13726
write_html(*HTML_HANDLE, <<END_OF_HTML );
13707
13727
<tr>
@@ -13878,3 +13898,24 @@ sub parse_dir_prefix(@)
13878
13898
}
13879
13899
}
13880
13900
}
13901
+
13902
+ #
13903
+ # simplify_function_name($name)
13904
+ #
13905
+ # apply @function_simplify_patterns to $name and return
13906
+ # goal is to shorten really long demangled names/template expansions
13907
+ #
13908
+ sub simplify_function_name ($)
13909
+ {
13910
+ my $name = shift ;
13911
+ if ($simplifyFunctionCallback ) {
13912
+
13913
+ eval { $name = $simplifyFunctionCallback -> simplify($name ); };
13914
+ if ($@ ) {
13915
+ my $context = MessageContext::context();
13916
+ lcovutil::ignorable_error($lcovutil::ERROR_CALLBACK ,
13917
+ " simplify($name ) failed$context : $@ " );
13918
+ }
13919
+ }
13920
+ return $name ;
13921
+ }
0 commit comments