callgrind_annotate, cg_annotate: don't truncate function names at '#'

C++ function names can contain substrings like "{lambda()#1}".  But
callgrind_annotate and cg_annotate interpret the '#'-character as a
comment marker anywhere on each input line, and thus truncate such names
there.

On the other hand, the documentation in docs/cl-format.xml, states:

  Everywhere, comments on own lines starting with '#' are allowed.

This seems to imply that a comment line must start with '#' in the first
column.  Thus skip exactly such lines in the input file and don't handle
'#' as a comment marker anywhere else.

Signed-off-by: Philippe Waroquiers <philippe.waroquiers@skynet.be>
This commit is contained in:
Andreas Arnez 2019-10-23 20:35:50 +02:00 committed by Philippe Waroquiers
parent 46cdf576a0
commit 7f63a88426
2 changed files with 8 additions and 12 deletions

View File

@ -398,7 +398,9 @@ sub read_input_file()
# Read body of input file.
while (<INPUTFILE>) {
s/#.*$//; # remove comments
# Skip comments and empty lines.
next if /^\s*$/ || /^\#/;
if (s/^(-?\d+)\s+//) {
my $lineNum = $1;
my $CC = line_to_CC($_);
@ -436,9 +438,6 @@ sub read_input_file()
# Assume that a "fn=" line is followed by a "fl=" line.
$currFileFuncName = undef;
} elsif (s/^\s*$//) {
# blank, do nothing
} elsif (s/^summary:\s+//) {
$summary_CC = line_to_CC($_);
(scalar(@$summary_CC) == @events)

View File

@ -420,10 +420,8 @@ sub read_input_file()
# Read header
while(<INPUTFILE>) {
# remove comments
s/#.*$//;
if (/^$/) { ; }
# Skip comments and empty lines.
if (/^\s*$/ || /^\#/) { ; }
elsif (/^version:\s*(\d+)/) {
# Can't read format with major version > 1
@ -540,9 +538,11 @@ sub read_input_file()
# Read body of input file.
while (<INPUTFILE>) {
# Skip comments and empty lines.
next if /^\s*$/ || /^\#/;
$prev_line_num = $curr_line_num;
s/#.*$//; # remove comments
s/^\+(\d+)/$prev_line_num+$1/e;
s/^\-(\d+)/$prev_line_num-$1/e;
s/^\*/$prev_line_num/e;
@ -646,9 +646,6 @@ sub read_input_file()
$curr_fn_CC = $fn_totals{$curr_name};
$curr_fn_CC = [] unless (defined $curr_fn_CC);
} elsif (s/^\s*$//) {
# blank, do nothing
} elsif (s/^cob=(.*)$//) {
$curr_cobj = uncompressed_name("ob",$1);