mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-30 21:52:34 +08:00
[analyzer] update to checker-276
http://clang-analyzer.llvm.org/release_notes.html
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -29,6 +29,7 @@ my $Compiler;
|
||||
my $Clang;
|
||||
my $DefaultCCompiler;
|
||||
my $DefaultCXXCompiler;
|
||||
my $IsCXX;
|
||||
|
||||
if (`uname -a` =~ m/Darwin/) {
|
||||
$DefaultCCompiler = 'clang';
|
||||
@@ -40,17 +41,21 @@ if (`uname -a` =~ m/Darwin/) {
|
||||
|
||||
if ($FindBin::Script =~ /c\+\+-analyzer/) {
|
||||
$Compiler = $ENV{'CCC_CXX'};
|
||||
if (!defined $Compiler) { $Compiler = $DefaultCXXCompiler; }
|
||||
if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCXXCompiler; }
|
||||
|
||||
$Clang = $ENV{'CLANG_CXX'};
|
||||
if (!defined $Clang) { $Clang = 'clang++'; }
|
||||
if (!defined $Clang || ! -x $Clang) { $Clang = 'clang++'; }
|
||||
|
||||
$IsCXX = 1
|
||||
}
|
||||
else {
|
||||
$Compiler = $ENV{'CCC_CC'};
|
||||
if (!defined $Compiler) { $Compiler = $DefaultCCompiler; }
|
||||
if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCCompiler; }
|
||||
|
||||
$Clang = $ENV{'CLANG'};
|
||||
if (!defined $Clang) { $Clang = 'clang'; }
|
||||
if (!defined $Clang || ! -x $Clang) { $Clang = 'clang'; }
|
||||
|
||||
$IsCXX = 0
|
||||
}
|
||||
|
||||
##===----------------------------------------------------------------------===##
|
||||
@@ -153,9 +158,8 @@ sub GetCCArgs {
|
||||
close(FROM_CHILD);
|
||||
|
||||
die "could not find clang line\n" if (!defined $line);
|
||||
# Strip the newline and initial whitspace
|
||||
chomp $line;
|
||||
$line =~ s/^\s+//;
|
||||
# Strip leading and trailing whitespace characters.
|
||||
$line =~ s/^\s+|\s+$//g;
|
||||
my @items = quotewords('\s+', 0, $line);
|
||||
my $cmd = shift @items;
|
||||
die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/));
|
||||
@@ -325,11 +329,6 @@ sub Analyze {
|
||||
|
||||
my %CompileOptionMap = (
|
||||
'-nostdinc' => 0,
|
||||
'-fblocks' => 0,
|
||||
'-fno-builtin' => 0,
|
||||
'-fobjc-gc-only' => 0,
|
||||
'-fobjc-gc' => 0,
|
||||
'-ffreestanding' => 0,
|
||||
'-include' => 1,
|
||||
'-idirafter' => 1,
|
||||
'-imacros' => 1,
|
||||
@@ -346,18 +345,16 @@ my %LinkerOptionMap = (
|
||||
);
|
||||
|
||||
my %CompilerLinkerOptionMap = (
|
||||
'-fobjc-arc' => 0,
|
||||
'-fno-objc-arc' => 0,
|
||||
'-fobjc-abi-version' => 0, # This is really a 1 argument, but always has '='
|
||||
'-fobjc-legacy-dispatch' => 0,
|
||||
'-Wwrite-strings' => 0,
|
||||
'-ftrapv-handler' => 1, # specifically call out separated -f flag
|
||||
'-mios-simulator-version-min' => 0, # This really has 1 argument, but always has '='
|
||||
'-isysroot' => 1,
|
||||
'-arch' => 1,
|
||||
'-m32' => 0,
|
||||
'-m64' => 0,
|
||||
'-stdlib' => 0, # This is really a 1 argument, but always has '='
|
||||
'-target' => 1,
|
||||
'-v' => 0,
|
||||
'-fpascal-strings' => 0,
|
||||
'-mmacosx-version-min' => 0, # This is really a 1 argument, but always has '='
|
||||
'-miphoneos-version-min' => 0 # This is really a 1 argument, but always has '='
|
||||
);
|
||||
@@ -384,18 +381,19 @@ my %IgnoredOptionMap = (
|
||||
);
|
||||
|
||||
my %LangMap = (
|
||||
'c' => 'c',
|
||||
'c' => $IsCXX ? 'c++' : 'c',
|
||||
'cp' => 'c++',
|
||||
'cpp' => 'c++',
|
||||
'cxx' => 'c++',
|
||||
'txx' => 'c++',
|
||||
'cc' => 'c++',
|
||||
'C' => 'c++',
|
||||
'ii' => 'c++',
|
||||
'i' => 'c-cpp-output',
|
||||
'ii' => 'c++-cpp-output',
|
||||
'i' => $IsCXX ? 'c++-cpp-output' : 'c-cpp-output',
|
||||
'm' => 'objective-c',
|
||||
'mi' => 'objective-c-cpp-output',
|
||||
'mm' => 'objective-c++'
|
||||
'mm' => 'objective-c++',
|
||||
'mii' => 'objective-c++-cpp-output',
|
||||
);
|
||||
|
||||
my %UniqueOptions = (
|
||||
@@ -427,8 +425,8 @@ my %Uniqued;
|
||||
|
||||
# Forward arguments to gcc.
|
||||
my $Status = system($Compiler,@ARGV);
|
||||
if (defined $ENV{'CCC_ANALYZER_LOG'}) {
|
||||
print "$Compiler @ARGV\n";
|
||||
if (defined $ENV{'CCC_ANALYZER_LOG'}) {
|
||||
print STDERR "$Compiler @ARGV\n";
|
||||
}
|
||||
if ($Status) { exit($Status >> 8); }
|
||||
|
||||
@@ -451,10 +449,13 @@ my $InternalStats = $ENV{'CCC_ANALYZER_INTERNAL_STATS'};
|
||||
my $OutputFormat = $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'};
|
||||
if (!defined $OutputFormat) { $OutputFormat = "html"; }
|
||||
|
||||
# Get the config options.
|
||||
my $ConfigOptions = $ENV{'CCC_ANALYZER_CONFIG'};
|
||||
|
||||
# Determine the level of verbosity.
|
||||
my $Verbose = 0;
|
||||
if (defined $ENV{CCC_ANALYZER_VERBOSE}) { $Verbose = 1; }
|
||||
if (defined $ENV{CCC_ANALYZER_LOG}) { $Verbose = 2; }
|
||||
if (defined $ENV{'CCC_ANALYZER_VERBOSE'}) { $Verbose = 1; }
|
||||
if (defined $ENV{'CCC_ANALYZER_LOG'}) { $Verbose = 2; }
|
||||
|
||||
# Get the HTML output directory.
|
||||
my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'};
|
||||
@@ -491,10 +492,6 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
while ($Cnt > 0) { ++$i; --$Cnt; push @CompileOpts, $ARGV[$i]; }
|
||||
next;
|
||||
}
|
||||
if ($Arg =~ /-m.*/) {
|
||||
push @CompileOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
# Handle the case where there isn't a space after -iquote
|
||||
if ($Arg =~ /-iquote.*/) {
|
||||
push @CompileOpts,$Arg;
|
||||
@@ -556,6 +553,11 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($Arg =~ /-m.*/) {
|
||||
push @CompileOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
|
||||
# Language.
|
||||
if ($Arg eq '-x') {
|
||||
$Lang = $ARGV[$i+1];
|
||||
@@ -574,6 +576,9 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
if ($Arg eq '-O') { push @LinkOpts,'-O1'; }
|
||||
elsif ($Arg eq '-Os') { push @LinkOpts,'-O2'; }
|
||||
else { push @LinkOpts,$Arg; }
|
||||
|
||||
# Must pass this along for the __OPTIMIZE__ macro
|
||||
if ($Arg =~ /^-O/) { push @CompileOpts,$Arg; }
|
||||
next;
|
||||
}
|
||||
|
||||
@@ -582,12 +587,6 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
next;
|
||||
}
|
||||
|
||||
# if ($Arg =~ /^-f/) {
|
||||
# # FIXME: Not sure if the remaining -fxxxx options have no arguments.
|
||||
# push @CompileOpts,$Arg;
|
||||
# push @LinkOpts,$Arg; # FIXME: Not sure if these are link opts.
|
||||
# }
|
||||
|
||||
# Get the compiler/link mode.
|
||||
if ($Arg =~ /^-F(.+)$/) {
|
||||
my $Tmp = $Arg;
|
||||
@@ -611,6 +610,12 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($Arg =~ /^-f/) {
|
||||
push @CompileOpts,$Arg;
|
||||
push @LinkOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
|
||||
# Handle -Wno-. We don't care about extra warnings, but
|
||||
# we should suppress ones that we don't want to see.
|
||||
if ($Arg =~ /^-Wno-/) {
|
||||
@@ -680,12 +685,15 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
my ($h, $f) = tempfile("report-XXXXXX", SUFFIX => ".plist",
|
||||
DIR => $HtmlDir);
|
||||
$ResultFile = $f;
|
||||
# If the HtmlDir is not set, we sould clean up the plist files.
|
||||
# If the HtmlDir is not set, we should clean up the plist files.
|
||||
if (!defined $HtmlDir || -z $HtmlDir) {
|
||||
$CleanupFile = $f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defined $ConfigOptions) {
|
||||
push @AnalyzeArgs, split '\s+', $ConfigOptions;
|
||||
}
|
||||
|
||||
push @CmdArgs, @CompileOpts;
|
||||
push @CmdArgs, $file;
|
||||
@@ -707,4 +715,3 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
}
|
||||
|
||||
exit($Status >> 8);
|
||||
|
||||
|
||||
@@ -25,14 +25,16 @@ use Sys::Hostname;
|
||||
|
||||
my $Verbose = 0; # Verbose output from this script.
|
||||
my $Prog = "scan-build";
|
||||
my $BuildName = "checker-275";
|
||||
my $BuildDate = "2013-05-23 17:38:31";
|
||||
my $BuildName = "checker-276";
|
||||
my $BuildDate = "2014-02-18 22:53:01";
|
||||
|
||||
my $TERM = $ENV{'TERM'};
|
||||
my $UseColor = (defined $TERM and $TERM =~ 'xterm-.*color' and -t STDOUT
|
||||
and defined $ENV{'SCAN_BUILD_COLOR'});
|
||||
|
||||
my $UserName = HtmlEscape(getpwuid($<) || 'unknown');
|
||||
# Portability: getpwuid is not implemented for Win32 (see Perl language
|
||||
# reference, perlport), use getlogin instead.
|
||||
my $UserName = HtmlEscape(getlogin() || getpwuid($<) || 'unknown');
|
||||
my $HostName = HtmlEscape(hostname() || 'unknown');
|
||||
my $CurrentDir = HtmlEscape(getcwd());
|
||||
my $CurrentDirSuffix = basename($CurrentDir);
|
||||
@@ -121,8 +123,7 @@ sub GetHTMLRunDir {
|
||||
my $Dir = shift @_;
|
||||
my $TmpMode = 0;
|
||||
if (!defined $Dir) {
|
||||
$Dir = $ENV{'TMPDIR'};
|
||||
if (!defined $Dir) { $Dir = "/tmp"; }
|
||||
$Dir = $ENV{'TMPDIR'} || $ENV{'TEMP'} || $ENV{'TMP'} || "/tmp";
|
||||
$TmpMode = 1;
|
||||
}
|
||||
|
||||
@@ -134,7 +135,13 @@ sub GetHTMLRunDir {
|
||||
my $year = $CurrentTime[5] + 1900;
|
||||
my $day = $CurrentTime[3];
|
||||
my $month = $CurrentTime[4] + 1;
|
||||
my $DateString = sprintf("%d-%02d-%02d", $year, $month, $day);
|
||||
my $hour = $CurrentTime[2];
|
||||
my $min = $CurrentTime[1];
|
||||
my $sec = $CurrentTime[0];
|
||||
|
||||
my $TimeString = sprintf("%02d%02d%02d", $hour, $min, $sec);
|
||||
my $DateString = sprintf("%d-%02d-%02d-%s-$$",
|
||||
$year, $month, $day, $TimeString);
|
||||
|
||||
# Determine the run number.
|
||||
my $RunNumber;
|
||||
@@ -161,9 +168,11 @@ sub GetHTMLRunDir {
|
||||
next if ($x[0] != $year);
|
||||
next if ($x[1] != $month);
|
||||
next if ($x[2] != $day);
|
||||
next if ($x[3] != $TimeString);
|
||||
next if ($x[4] != $$);
|
||||
|
||||
if ($x[3] > $max) {
|
||||
$max = $x[3];
|
||||
if ($x[5] > $max) {
|
||||
$max = $x[5];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +885,8 @@ sub AddIfNotPresent {
|
||||
sub SetEnv {
|
||||
my $Options = shift @_;
|
||||
foreach my $opt ('CC', 'CXX', 'CLANG', 'CLANG_CXX',
|
||||
'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS') {
|
||||
'CCC_ANALYZER_ANALYSIS', 'CCC_ANALYZER_PLUGINS',
|
||||
'CCC_ANALYZER_CONFIG') {
|
||||
die "$opt is undefined\n" if (!defined $opt);
|
||||
$ENV{$opt} = $Options->{$opt};
|
||||
}
|
||||
@@ -896,6 +906,9 @@ sub SetEnv {
|
||||
}
|
||||
}
|
||||
|
||||
# The flag corresponding to the --override-compiler command line option.
|
||||
my $OverrideCompiler = 0;
|
||||
|
||||
sub RunXcodebuild {
|
||||
my $Args = shift;
|
||||
my $IgnoreErrors = shift;
|
||||
@@ -928,6 +941,12 @@ sub RunXcodebuild {
|
||||
}
|
||||
close(DETECT_XCODE);
|
||||
|
||||
# If --override-compiler is explicitely requested, resort to the old
|
||||
# behavior regardless of Xcode version.
|
||||
if ($OverrideCompiler) {
|
||||
$oldBehavior = 1;
|
||||
}
|
||||
|
||||
if ($oldBehavior == 0) {
|
||||
my $OutputDir = $Options->{"OUTPUT_DIR"};
|
||||
my $CLANG = $Options->{"CLANG"};
|
||||
@@ -1008,10 +1027,10 @@ sub RunBuildCommand {
|
||||
shift @$Args;
|
||||
unshift @$Args, $CXXAnalyzer;
|
||||
}
|
||||
elsif ($IgnoreErrors) {
|
||||
if ($Cmd eq "make" or $Cmd eq "gmake") {
|
||||
AddIfNotPresent($Args, "CC=$CCAnalyzer");
|
||||
AddIfNotPresent($Args, "CXX=$CXXAnalyzer");
|
||||
elsif ($Cmd eq "make" or $Cmd eq "gmake") {
|
||||
AddIfNotPresent($Args, "CC=$CCAnalyzer");
|
||||
AddIfNotPresent($Args, "CXX=$CXXAnalyzer");
|
||||
if ($IgnoreErrors) {
|
||||
AddIfNotPresent($Args,"-k");
|
||||
AddIfNotPresent($Args,"-i");
|
||||
}
|
||||
@@ -1143,6 +1162,14 @@ ADVANCED OPTIONS:
|
||||
|
||||
Don't remove the build results directory even if no issues were reported.
|
||||
|
||||
--override-compiler
|
||||
Always resort to the ccc-analyzer even when better interposition methods
|
||||
are available.
|
||||
|
||||
-analyzer-config <options>
|
||||
|
||||
Provide options to pass through to the analyzer's -analyzer-config flag.
|
||||
|
||||
CONTROLLING CHECKERS:
|
||||
|
||||
A default group of checkers are always run unless explicitly disabled.
|
||||
@@ -1314,6 +1341,7 @@ my @AnalysesToRun;
|
||||
my $StoreModel;
|
||||
my $ConstraintsModel;
|
||||
my $InternalStats;
|
||||
my @ConfigOptions;
|
||||
my $OutputFormat = "html";
|
||||
my $AnalyzerStats = 0;
|
||||
my $MaxLoop = 0;
|
||||
@@ -1462,6 +1490,12 @@ while (@ARGV) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg eq "-analyzer-config") {
|
||||
shift @ARGV;
|
||||
push @ConfigOptions, "-analyzer-config", shift @ARGV;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg eq "-no-failure-reports") {
|
||||
$ENV{"CCC_REPORT_FAILURES"} = 0;
|
||||
next;
|
||||
@@ -1507,6 +1541,12 @@ while (@ARGV) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg eq "--override-compiler") {
|
||||
shift @ARGV;
|
||||
$OverrideCompiler = 1;
|
||||
next;
|
||||
}
|
||||
|
||||
DieDiag("unrecognized option '$arg'\n") if ($arg =~ /^-/);
|
||||
|
||||
last;
|
||||
@@ -1584,13 +1624,17 @@ my $AbsRealBin = Cwd::realpath($RealBin);
|
||||
my $Cmd = "$AbsRealBin/libexec/ccc-analyzer";
|
||||
my $CmdCXX = "$AbsRealBin/libexec/c++-analyzer";
|
||||
|
||||
if (!defined $Cmd || ! -x $Cmd) {
|
||||
# Portability: use less strict but portable check -e (file exists) instead of
|
||||
# non-portable -x (file is executable). On some windows ports -x just checks
|
||||
# file extension to determine if a file is executable (see Perl language
|
||||
# reference, perlport)
|
||||
if (!defined $Cmd || ! -e $Cmd) {
|
||||
$Cmd = "$AbsRealBin/ccc-analyzer";
|
||||
DieDiag("Executable 'ccc-analyzer' does not exist at '$Cmd'\n") if(! -x $Cmd);
|
||||
DieDiag("'ccc-analyzer' does not exist at '$Cmd'\n") if(! -e $Cmd);
|
||||
}
|
||||
if (!defined $CmdCXX || ! -x $CmdCXX) {
|
||||
if (!defined $CmdCXX || ! -e $CmdCXX) {
|
||||
$CmdCXX = "$AbsRealBin/c++-analyzer";
|
||||
DieDiag("Executable 'c++-analyzer' does not exist at '$CmdCXX'\n") if(! -x $CmdCXX);
|
||||
DieDiag("'c++-analyzer' does not exist at '$CmdCXX'\n") if(! -e $CmdCXX);
|
||||
}
|
||||
|
||||
Diag("Using '$Clang' for static analysis\n");
|
||||
@@ -1604,6 +1648,7 @@ if ($MaxLoop > 0) { push @AnalysesToRun, "-analyzer-max-loop $MaxLoop"; }
|
||||
# interposition.
|
||||
my $CCC_ANALYZER_ANALYSIS = join ' ',@AnalysesToRun;
|
||||
my $CCC_ANALYZER_PLUGINS = join ' ',@PluginsToLoad;
|
||||
my $CCC_ANALYZER_CONFIG = join ' ',@ConfigOptions;
|
||||
my %Options = (
|
||||
'CC' => $Cmd,
|
||||
'CXX' => $CmdCXX,
|
||||
@@ -1612,6 +1657,7 @@ my %Options = (
|
||||
'VERBOSE' => $Verbose,
|
||||
'CCC_ANALYZER_ANALYSIS' => $CCC_ANALYZER_ANALYSIS,
|
||||
'CCC_ANALYZER_PLUGINS' => $CCC_ANALYZER_PLUGINS,
|
||||
'CCC_ANALYZER_CONFIG' => $CCC_ANALYZER_CONFIG,
|
||||
'OUTPUT_DIR' => $HtmlDir
|
||||
);
|
||||
|
||||
@@ -1657,4 +1703,3 @@ if (defined $OutputFormat) {
|
||||
}
|
||||
|
||||
exit $ExitStatus;
|
||||
|
||||
|
||||
@@ -112,4 +112,3 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -490,4 +490,3 @@ var forEach = function(object, block, context) {
|
||||
resolve.forEach(object, block, context);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user