Currently scan-build cannot pass any triple information to clang. This makes analysis failure when the build script has target specific compiler flags. This patch adds --triple option to support analysis for other targets.
--triple [target triple name] --triple=[target triple name] This provides target triple information to clang. Signed-off-by: Honggyu Kim <[email protected]> --- tools/scan-build/ccc-analyzer | 10 ++++++++++ tools/scan-build/scan-build | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer index 4549b29..5d9eac0 100755 --- a/tools/scan-build/ccc-analyzer +++ b/tools/scan-build/ccc-analyzer @@ -41,6 +41,7 @@ my $Clang; my $DefaultCCompiler; my $DefaultCXXCompiler; my $IsCXX; +my $Triple; # If on OSX, use xcrun to determine the SDK root. my $UseXCRUN = 0; @@ -77,6 +78,9 @@ else { $IsCXX = 0 } +$Triple = $ENV{'CLANG_TRIPLE'}; +#if (!defined $Triple || ! -x $Triple) { $Triple = ''; } + ##===----------------------------------------------------------------------===## # Cleanup. ##===----------------------------------------------------------------------===## @@ -237,6 +241,12 @@ sub Analyze { my @PrintArgs; my $dir; + if (!defined $Triple || ! -x $Triple) { + else + push @CmdArgs, "-triple"; + push @CmdArgs, $Triple; + } + if ($Verbose) { $dir = getcwd(); print STDERR "\n[LOCATION]: $dir\n"; diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build index d52d8f5..ea18536 100755 --- a/tools/scan-build/scan-build +++ b/tools/scan-build/scan-build @@ -1150,6 +1150,11 @@ OPTIONS: 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 @@ -1479,6 +1484,24 @@ while (@ARGV) { 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++; -- 1.7.9.5 _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
