aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-09-14 19:06:33 +0000
committerTed Kremenek <kremenek@apple.com>2012-09-14 19:06:33 +0000
commitf8dcac5d6589414e646ae9cbf834f612510a08b1 (patch)
tree946d18356d1fb1f18a1d437f5152b362c839b87c
parenta778d710e2c62d62e0b78d120254764142801196 (diff)
Utilize new build system support in Xcode 4.5 for easier interposition
of a build without needing to use ccc-analyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163927 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-xtools/scan-build/scan-build30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build
index a13b235aa9..d27a07396d 100755
--- a/tools/scan-build/scan-build
+++ b/tools/scan-build/scan-build
@@ -884,6 +884,36 @@ sub RunXcodebuild {
if ($IgnoreErrors) {
AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES");
}
+
+ # Detect the version of Xcode. If Xcode 4.5 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.5) {
+ $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);