diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-01-30 19:10:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-01-30 19:10:24 +0000 |
commit | 1afc201e644ce6379b115b1fae0608dee1b0ab5f (patch) | |
tree | 1f3918b4bcd84e1711364ddb74cd272ad6d39761 | |
parent | 16bdd3b98e40a5a04705d399b90ddd88babd1c3d (diff) |
scan-build: When using Xcode 4.6, use build settings for doing proper build interposition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173954 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-x | tools/scan-build/scan-build | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build index 16ce931c99..e99b49d13a 100755 --- a/tools/scan-build/scan-build +++ b/tools/scan-build/scan-build @@ -882,6 +882,36 @@ sub RunXcodebuild { if ($IgnoreErrors) { AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES"); } + + # Detect the version of Xcode. If Xcode 4.6 or higher, use new + # in situ support for analyzer interposition without needed to override + # the compiler. + open(DETECT_XCODE, "xcodebuild -version |") or + die "error: cannot detect version of xcodebuild\n"; + + my $oldBehavior = 1; + + while(<DETECT_XCODE>) { + if (/^Xcode (.+)$/) { + if ($1 >= 4.6) { + $oldBehavior = 0; + last; + } + } + } + close(DETECT_XCODE); + + if ($oldBehavior == 0) { + my $OutputDir = $Options->{"OUTPUT_DIR"}; + my $CLANG = $Options->{"CLANG"}; + push @$Args, + "RUN_CLANG_STATIC_ANALYZER=YES", + "CLANG_ANALYZER_OUTPUT=plist-html", + "CLANG_ANALYZER_EXEC=$CLANG", + "CLANG_ANALYZER_OUTPUT_DIR=$OutputDir"; + + return (system(@$Args) >> 8); + } # Default to old behavior where we insert a bogus compiler. SetEnv($Options); |