r173954 - scan-build: When using Xcode 4.6, use build settings for doing proper build interposition.
Ted Kremenek
kremenek at apple.com
Wed Jan 30 11:10:24 PST 2013
Author: kremenek
Date: Wed Jan 30 13:10:24 2013
New Revision: 173954
URL: http://llvm.org/viewvc/llvm-project?rev=173954&view=rev
Log:
scan-build: When using Xcode 4.6, use build settings for doing proper build interposition.
Modified:
cfe/trunk/tools/scan-build/scan-build
Modified: cfe/trunk/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=173954&r1=173953&r2=173954&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Wed Jan 30 13:10:24 2013
@@ -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);
More information about the cfe-commits
mailing list