summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2014-12-31 07:44:51 +0000
committerTed Kremenek <kremenek@apple.com>2014-12-31 07:44:51 +0000
commita0e39bc4445db7907381ebb1f0ced7b8f2bc0f2e (patch)
treec06bd5d428534ce2dd368f7cbcfcc653a50c70af /tools
parente3c2978e2d7df1e4494156b95f7bd35acbc15d12 (diff)
[analyzer] Change ccc-analyzer to mimick behavior on OSX Mavericks/Yosemite to automatically infer the SDK location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rwxr-xr-xtools/scan-build/ccc-analyzer20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer
index 4c8f6482a1..c99328221a 100755
--- a/tools/scan-build/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer
@@ -41,10 +41,14 @@ my $Clang;
my $DefaultCCompiler;
my $DefaultCXXCompiler;
my $IsCXX;
+my $UseXCRUN = 0;
if (`uname -a` =~ m/Darwin/) {
$DefaultCCompiler = 'clang';
$DefaultCXXCompiler = 'clang++';
+ if (-x "/usr/bin/xcrun") {
+ $UseXCRUN = 1;
+ }
} else {
$DefaultCCompiler = 'gcc';
$DefaultCXXCompiler = 'g++';
@@ -478,6 +482,7 @@ my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'};
my %DisabledArchs = ('ppc' => 1, 'ppc64' => 1);
my %ArchsSeen;
my $HadArch = 0;
+my $HasSDK = 0;
# Process the arguments.
foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
@@ -500,6 +505,12 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
next;
}
+ # On OSX/iOS, record if an SDK path was specified. This
+ # is innocuous for other platforms, so the check just happens.
+ if ($Arg =~ /^-isysroot/) {
+ $HasSDK = 1;
+ }
+
# Options with possible arguments that should pass through to compiler.
if (defined $CompileOptionMap{$ArgKey}) {
my $Cnt = $CompileOptionMap{$ArgKey};
@@ -644,6 +655,15 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
}
}
+# If we are on OSX and have an installation where the
+# default SDK is inferred by xcrun use xcrun to infer
+# the SDK.
+if (not $HasSDK and $UseXCRUN) {
+ my $sdk = `/usr/bin/xcrun --show-sdk-path -sdk macosx`;
+ chomp $sdk;
+ push @CompileOpts, "-isysroot", $sdk;
+}
+
if ($Action eq 'compile' or $Action eq 'link') {
my @Archs = keys %ArchsSeen;
# Skip the file if we don't support the architectures specified.