@@ -291,6 +291,8 @@ sub write_overview(*$$$$);
291291# External prototype (defined in genpng)
292292sub gen_png ($$$$$@);
293293
294+ sub simplify_function_name ($);
295+
294296package SummaryInfo ;
295297
296298our @selectCallbackScript ;
@@ -5471,7 +5473,7 @@ sub _computeAge
54715473 if ($then > $now ) {
54725474 if (lcovutil::warn_once($lcovutil::ERROR_INCONSISTENT_DATA , $path )) {
54735475 # 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
54755477 my $data =
54765478 exists ($ENV {SOURCE_DATE_EPOCH }) ?
54775479 (
@@ -6853,10 +6855,14 @@ our @rate_png = ("ruby.png", "amber.png", "emerald.png");
68536855our $rc_desc_html = 0; # lcovrc: genhtml_desc_html
68546856our $deprecated_highlight ; # ignored former option
68556857
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
68576863
68586864# for debugging
6859- our $verboseScopeRegexp ; # dump categorization processing if match
6865+ our $verboseScopeRegexp ; # dump categorization processing if match
68606866
68616867#
68626868# Code entry point
@@ -6869,7 +6875,8 @@ STDERR->autoflush;
68696875STDOUT -> autoflush;
68706876
68716877my @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 );
68736880
68746881my %genhtml_rc_opts = (
68756882 " genhtml_css_file" => \$css_filename ,
@@ -6925,6 +6932,7 @@ my %genhtml_rc_opts = (
69256932 ' genhtml_annotate_script' => \@rc_annotate_script ,
69266933 ' genhtml_annotate_tooltip' => \$SourceFile::annotateTooltip ,
69276934 " select_script" => \@rc_select_script ,
6935+ " simplify_function" => \@rc_simplifyFunctionScript ,
69286936 ' num_context_lines' => \$InInterestingRegion::num_context_lines ,
69296937 ' genhtml_date_bins' => \@rc_date_bins ,
69306938 ' genhtml_date_labels' => \@rc_date_labels ,
@@ -6938,60 +6946,62 @@ my $save;
69386946my $serialize ;
69396947my $validateHTML = exists ($ENV {LCOV_VALIDATE });
69406948
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 ,);
69957005
69967006# remove ambiguous entry from common table -
69977007# (genhtml has '--sort-inputs' and '--sort-tables')
@@ -7041,18 +7051,28 @@ $frames = undef unless (defined($frames) && $frames);
70417051foreach my $rc ([\@datebins , \@rc_date_bins ],
70427052 [\@SummaryInfo::ageGroupHeader , \@rc_date_labels ],
70437053 [\@SourceFile::annotateScript , \@rc_annotate_script ],
7044- [\@selectCallbackScript , \@rc_select_script ]
7054+ [\@SummaryInfo::selectCallbackScript , \@rc_select_script ],
7055+ [\@simplifyFunctionScript , \@rc_simplifyFunctionScript ],
70457056
70467057) {
70477058 @{$rc -> [0]} = @{$rc -> [1]} unless (@{$rc -> [0]});
70487059}
70497060
70507061foreach my $cb ([\$SourceFile::annotateCallback , \@SourceFile::annotateScript ],
7051- [\$selectCallback , \@selectCallbackScript ]) {
7062+ [\$SummaryInfo::selectCallback ,
7063+ \@SummaryInfo::selectCallbackScript
7064+ ],
7065+ [\$simplifyFunctionCallback , \@simplifyFunctionScript ],
7066+ ) {
70527067 lcovutil::configure_callback($cb -> [0], @{$cb -> [1]})
70537068 if scalar (@{$cb -> [1]});
70547069}
70557070
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+
70567076if (defined ($lcovutil::stop_on_error ) &&
70577077 !$lcovutil::stop_on_error ) {
70587078 # in the spirit of "don't stop" - don't worry about missing files.
@@ -8384,7 +8404,7 @@ sub read_testfile($)
83848404 local *TEST_HANDLE;
83858405
83868406 open (TEST_HANDLE, " <" , $file ) or
8387- die (" cannot open $file ] : $! \n " );
8407+ die (" cannot open description file ' $file ' : $! \n " );
83888408
83898409 while (<TEST_HANDLE>) {
83908410 chomp ($_ );
@@ -13322,7 +13342,7 @@ sub write_source($$$$$$$$)
1332213342 my $cbdata = PrintCallback-> new($srcfile , $fileCovInfo );
1332313343
1332413344 my ($region , $empty );
13325- if ($selectCallback ) {
13345+ if ($SummaryInfo:: selectCallback ) {
1332613346 $region = InInterestingRegion-> new($srcfile , $fileCovInfo -> lineMap());
1332713347 $empty = ' ' ;
1332813348 if ($srcfile -> isProjectFile()) {
@@ -13583,7 +13603,7 @@ END_OF_HTML
1358313603 next
1358413604 if grep (/ ^$tla $ / , (' DUB' , ' DCB' )); # don't display deleted functions
1358513605 my $startline = $funcEntry -> line() - $func_offset ;
13586- my $name = $func ;
13606+ my $name = simplify_function_name( $func ) ;
1358713607 my $countstyle ;
1358813608
1358913609 # Escape special characters
@@ -13701,7 +13721,7 @@ END_OF_HTML
1370113721 }
1370213722
1370313723 # Escape special characters
13704- $alias = escape_html($alias );
13724+ $alias = escape_html(simplify_function_name( $alias ) );
1370513725
1370613726 write_html(*HTML_HANDLE, <<END_OF_HTML );
1370713727 <tr>
@@ -13878,3 +13898,24 @@ sub parse_dir_prefix(@)
1387813898 }
1387913899 }
1388013900}
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