Index: tools/scan-build/ccc-analyzer =================================================================== --- tools/scan-build/ccc-analyzer +++ tools/scan-build/ccc-analyzer @@ -68,6 +68,7 @@ my $DefaultCCompiler; my $DefaultCXXCompiler; my $IsCXX; +my $Triple; # If on OSX, use xcrun to determine the SDK root. my $UseXCRUN = 0; @@ -104,6 +105,8 @@ $IsCXX = 0 } +$Triple = $ENV{'CLANG_TRIPLE'}; + ##===----------------------------------------------------------------------===## # Cleanup. ##===----------------------------------------------------------------------===## @@ -245,6 +248,10 @@ push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph"; } + if (defined $Triple) { + push @Args, "-target", $Triple; + } + my $AnalysisArgs = GetCCArgs($HtmlDir, "--analyze", \@Args); @CmdArgs = @$AnalysisArgs; } Index: tools/scan-build/scan-build =================================================================== --- tools/scan-build/scan-build +++ tools/scan-build/scan-build @@ -1150,6 +1150,11 @@ This is the same as "-use-cc" but for C++ code. + --triple [target triple name] + --triple=[target triple name] + + This provides target triple information to clang. + -v Enable verbose output from scan-build. A second and third '-v' increases @@ -1462,6 +1467,24 @@ next; } + if ($arg =~ /^--triple(=(.+))?$/) { + shift @ARGV; + my $triple; + + if (!defined $2 || $2 eq "") { + if (!@ARGV) { + DieDiag("'--triple' option requires a triple name.\n"); + } + $triple = shift @ARGV; + } + else { + $triple = $2; + } + + $ENV{"CLANG_TRIPLE"} = $triple; + next; + } + if ($arg eq "-v") { shift @ARGV; $Verbose++;