From: Ted Kremenek Date: Tue, 15 Jul 2008 17:06:13 +0000 (+0000) Subject: scan-build now interrogates clang for a list of available analyses, and presents X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7770c0b4970606b53cca14ae3ca0588a0bfcb30;p=clang scan-build now interrogates clang for a list of available analyses, and presents these as options to the user of scan-build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53618 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/utils/scan-build b/utils/scan-build index f2d66c60e6..575bf25cc5 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -29,6 +29,10 @@ my $BuildDate; my $UseColor = ((($ENV{'TERM'} eq 'xterm-color') and -t STDOUT) and defined($ENV{'SCAN_BUILD_COLOR'})); +##----------------------------------------------------------------------------## +# Diagnostics +##----------------------------------------------------------------------------## + sub Diag { if ($UseColor) { print BOLD, MAGENTA "$Prog: @_"; @@ -51,6 +55,53 @@ sub DieDiag { exit(0); } +##----------------------------------------------------------------------------## +# Some initial preprocessing of Clang options. +##----------------------------------------------------------------------------## + +my $ClangSB = "$RealBin/clang"; +my $Clang = $ClangSB; + +if (! -x $ClangSB) { + $Clang = "clang"; +} + +my %AvailableAnalyses; + +# Query clang for analysis options. +open(PIPE, "$Clang --help |") or + DieDiag("Cannot execute '$Clang'"); + +my $FoundAnalysis = 0; + +while() { + if ($FoundAnalysis == 0) { + if (/Available Source Code Analyses/) { + $FoundAnalysis = 1; + } + + next; + } + + if (/^\s\s\s\s([^\s]+)\s(.+)$/) { + next if ($1 =~ /-dump/ or $1 =~ /-view/ + or $1 =~ /-checker-simple/ or $1 =~ /-warn-uninit/); + + $AvailableAnalyses{$1} = $2; + next; + } + + last; +} + +close (PIPE); + +my %AnalysesDefaultEnabled = ( + '-warn-dead-stores' => 1, + '-checker-cfref' => 1, + '-warn-objc-methodsigs' => 1 +); + ##----------------------------------------------------------------------------## # GetHTMLRunDir - Construct an HTML directory name for the current run. ##----------------------------------------------------------------------------## @@ -592,9 +643,6 @@ ENDTEXT print <= 3) { $ENV{'CCC_ANALYZER_LOG'} = 1; } -if (defined($Analysis)) { - $ENV{'CCC_ANALYZER_ANALYSIS'} = $Analysis; +if (scalar(@AnalysesToRun)) { + $ENV{'CCC_ANALYZER_ANALYSIS'} = join ' ',@AnalysesToRun; } # Run the build.