Skip to content

Commit 5c81e26

Browse files
Friedemann KleintFriedemann Kleint
Friedemann Kleint
authored and
Friedemann Kleint
committed
msvc2tasks.pl: Add support for clang-cl.exe and match errors, too.
Move regexp filtering into subroutine for clarity. Task-number: QTCREATORBUG-15641 Task-number: QTBUG-50804 Change-Id: I2b78e82f41b83c64053b350b241f3c14246eb417 Reviewed-by: Tobias Hunger <[email protected]>
1 parent bb8270b commit 5c81e26

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

scripts/msvc2tasks.pl

+32-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
=head1 NAME
2929
30-
msvc2tasks.pl - Convert MSVC warnings into Qt Creator task files.
30+
msvc2tasks.pl - Convert MSVC/Clang-cl warnings and errors into Qt Creator task files.
3131
3232
=head1 SYNOPSIS
3333
@@ -37,16 +37,39 @@ =head1 SYNOPSIS
3737

3838
use strict;
3939

40-
while (my $line = <STDIN> ) {
41-
chomp($line);
42-
# --- extract file name based matching:
40+
sub filterLine
41+
{
42+
my ($line) = @_;
43+
44+
my ($fileName, $lineNumber, $category, $text);
45+
46+
# --- MSVC:
4347
# c:\foo.cpp(395) : warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
44-
if ($line =~ /^([^(]+)\((\d+)\) ?: warning (C\d+:.*)$/) {
45-
my $fileName = $1;
46-
my $lineNumber = $2;
47-
my $text = $3;
48+
if ($line =~ /^([^(]+)\((\d+)\) ?: (warning|error) (C\d+:.*)$/) {
49+
$fileName = $1;
50+
$lineNumber = $2;
51+
$category = $3;
52+
$text = $4;
53+
# --- Clang-cl:
54+
# ..\gui\text\qfontengine_ft.cpp(1743,5) : warning: variable 'bytesPerLine' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
55+
} elsif ($line =~ /^([^(]+)\((\d+),\d+\) ?: +(warning|error):\s+(.*)$/) {
56+
$fileName = $1;
57+
$lineNumber = $2;
58+
$category = $3;
59+
$text = $4;
60+
}
61+
62+
if (defined $fileName) {
4863
$fileName =~ s|\\|/|g;
4964
$text =~ s|\\|/|g; # Fix file names mentioned in text since tasks file have backslash-escaping.
50-
print $fileName, "\t", $lineNumber, "\twarn\t", $text,"\n";
65+
$category = $category eq 'warning' ? 'warn' : 'err';
5166
}
67+
68+
return ($fileName, $lineNumber, $category, $text);
69+
}
70+
71+
while (my $line = <STDIN> ) {
72+
chomp($line);
73+
my ($fileName, $lineNumber, $category, $text) = filterLine($line);
74+
print $fileName, "\t", $lineNumber, "\t", $category, "\t", $text,"\n" if defined $text;
5275
}

0 commit comments

Comments
 (0)