From 5d31f83bbe990aeb070ce6c8d919d229d4eb5052 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 18 Aug 2008 18:38:29 +0000 Subject: [PATCH] scan-build/ccc-analyzer now also report clang parser failures. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54931 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/ccc-analyzer | 18 ++++++++++++------ utils/scan-build | 11 +++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/utils/ccc-analyzer b/utils/ccc-analyzer index fd24a8b2ad..ad7b412b0b 100755 --- a/utils/ccc-analyzer +++ b/utils/ccc-analyzer @@ -28,18 +28,19 @@ sub GetPPExt { return ".i"; } -sub ProcessClangCrash { - my ($Clang, $Lang, $file, $Args, $HtmlDir) = @_; +sub ProcessClangFailure { + my ($Lang, $file, $Args, $HtmlDir, $ErrorType) = @_; my $Dir = "$HtmlDir/crashes"; mkpath $Dir; my ($PPH, $PPFile) = tempfile("clang_crash_XXXXXX", SUFFIX => GetPPExt($Lang), DIR => $Dir); - system $Clang, @$Args, "-E", "-o", $PPFile; + system "gcc", @$Args, "-E", "-o", $PPFile; close ($PPH); open (OUT, ">", "$PPFile.info") or die "Cannot open $PPFile.info\n"; - print OUT "$file"; + print OUT "$file\n"; + print OUT "$ErrorType\n"; close OUT; } @@ -52,7 +53,7 @@ sub Analyze { # Skip anything related to C++. return if ($Lang =~ /c[+][+]/); - + my $RunAnalyzer = 0; my $Cmd; my @CmdArgs; @@ -105,7 +106,12 @@ sub Analyze { # Did the command die because of a signal? if ($? & 127 and $Cmd eq $Clang and defined $HtmlDir) { - ProcessClangCrash($Clang, $Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir); + ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir, + "Crash"); + } + elsif ($?) { + ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir, + "Parser Rejects"); } } diff --git a/utils/scan-build b/utils/scan-build index 9004b354f0..44c2db3f0d 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -567,12 +567,12 @@ ENDTEXT if (scalar(@files)) { print OUT <Analyzer Crashes +

Analyzer Failures

-

The analyzer crashed while processing the following files:

+

The analyzer had problems processing the following files:

- + ENDTEXT foreach my $file (sort @files) { @@ -583,9 +583,12 @@ ENDTEXT open (INFO, "$Dir/crashes/$file") or die "Cannot open $Dir/crashes/$file\n"; my $srcfile = ; + chomp $srcfile; + my $problem = ; + chomp $problem; close (INFO); # Print the information in the table. - print OUT "\n"; + print OUT "\n"; } print OUT <
Source FilePreprocessed File
ProblemSource FilePreprocessed File
$srcfileView
$problem$srcfileView