From: Jordan Rose Date: Fri, 14 Sep 2012 18:59:03 +0000 (+0000) Subject: scan-build: Determine the location of the clang binary before printing help. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a778d710e2c62d62e0b78d120254764142801196;p=clang scan-build: Determine the location of the clang binary before printing help. We need the clang executable to print the list of available checkers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163925 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build index 0b7025b965..a13b235aa9 100755 --- a/tools/scan-build/scan-build +++ b/tools/scan-build/scan-build @@ -1135,73 +1135,74 @@ foreach my $lang ("c", "objective-c", "objective-c++", "c++") { } # Query clang for complete list of checkers. -pipe(FROM_CHILD, TO_PARENT); -my $pid = fork(); -if ($pid == 0) { - close FROM_CHILD; - open(STDOUT,">&", \*TO_PARENT); - open(STDERR,">&", \*TO_PARENT); - exec $Clang, ('-cc1', @PluginsToLoad , '-analyzer-checker-help'); -} -close(TO_PARENT); -my $foundCheckers = 0; -while() { - if (/CHECKERS:/) { - $foundCheckers = 1; - last; +if (defined $Clang && -x $Clang) { + pipe(FROM_CHILD, TO_PARENT); + my $pid = fork(); + if ($pid == 0) { + close FROM_CHILD; + open(STDOUT,">&", \*TO_PARENT); + open(STDERR,">&", \*TO_PARENT); + exec $Clang, ('-cc1', @PluginsToLoad , '-analyzer-checker-help'); } -} -if (!$foundCheckers) { - print " *** Could not query Clang for the list of available checkers."; -} -else { - print("\nAVAILABLE CHECKERS:\n\n"); - my $skip = 0; + close(TO_PARENT); + my $foundCheckers = 0; while() { - if (/experimental/) { - $skip = 1; - next; - } - if ($skip) { - next if (!/^\s\s[^\s]/); - $skip = 0; + if (/CHECKERS:/) { + $foundCheckers = 1; + last; } - s/^\s\s//; - if (/^([^\s]+)/) { - # Is the checker enabled? - my $checker = $1; - my $enabled = 0; - my $aggregate = ""; - foreach my $domain (split /\./, $checker) { - $aggregate .= $domain; - if ($EnabledCheckers{$aggregate}) { - $enabled =1; - last; - } - # append a dot, if an additional domain is added in the next iteration - $aggregate .= "."; + } + if (!$foundCheckers) { + print " *** Could not query Clang for the list of available checkers."; + } + else { + print("\nAVAILABLE CHECKERS:\n\n"); + my $skip = 0; + while() { + if (/experimental/) { + $skip = 1; + next; + } + if ($skip) { + next if (!/^\s\s[^\s]/); + $skip = 0; } + s/^\s\s//; + if (/^([^\s]+)/) { + # Is the checker enabled? + my $checker = $1; + my $enabled = 0; + my $aggregate = ""; + foreach my $domain (split /\./, $checker) { + $aggregate .= $domain; + if ($EnabledCheckers{$aggregate}) { + $enabled =1; + last; + } + # append a dot, if an additional domain is added in the next iteration + $aggregate .= "."; + } - if ($enabled) { - print " + "; + if ($enabled) { + print " + "; + } + else { + print " "; + } } else { print " "; } + print $_; } - else { - print " "; - } - print $_; - } + print "\nNOTE: \"+\" indicates that an analysis is enabled by default.\n" + } + waitpid($pid,0); + close(FROM_CHILD); } -waitpid($pid,0); -close(FROM_CHILD); print <