[PATCH] D12769: [analyzer] Update SATestBuild.py to set -isysroot for preprocessed files

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 11:04:03 PDT 2015


dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, xazax.hun.
dcoughlin added a subscriber: cfe-commits.

Update the static analyzer buildbot script to set -isysroot to the OS X SDK path when analyzing preprocessed files.

http://reviews.llvm.org/D12769

Files:
  utils/analyzer/SATestBuild.py

Index: utils/analyzer/SATestBuild.py
===================================================================
--- utils/analyzer/SATestBuild.py
+++ utils/analyzer/SATestBuild.py
@@ -52,7 +52,7 @@
 import time
 import plistlib
 import argparse
-from subprocess import check_call, CalledProcessError
+from subprocess import check_call, check_output, CalledProcessError
 
 #------------------------------------------------------------------------------
 # Helper functions.
@@ -255,14 +255,31 @@
         return True
     return False
 
+# Get the path to the SDK for the given SDK name. Returns None if
+# the path cannot be determined.
+def getSDKPath(SDKName):
+    if which("xcrun") is None:
+        return None
+
+    Cmd = "xcrun --sdk " + SDKName + " --show-sdk-path"
+    return check_output(Cmd, shell=True).rstrip()
+
 # Run analysis on a set of preprocessed files.
 def runAnalyzePreprocessed(Dir, SBOutputDir, Mode):
     if os.path.exists(os.path.join(Dir, BuildScript)):
         print "Error: The preprocessed files project should not contain %s" % \
                BuildScript
         raise Exception()
 
-    CmdPrefix = Clang + " -cc1 -analyze -analyzer-output=plist -w "
+    CmdPrefix = Clang + " "
+
+    # For now, we assume the preprocessed files should be analyzed
+    # with the OS X SDK.
+    SDKPath = getSDKPath("macosx")
+    if SDKPath is not None:
+      CmdPrefix += "-cc1 -isysroot " + SDKPath + " "
+
+    CmdPrefix += "-analyze -analyzer-output=plist -w "
     CmdPrefix += "-analyzer-checker=" + Checkers +" -fcxx-exceptions -fblocks "
 
     if (Mode == 2) :


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12769.34466.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150910/269fc2c6/attachment-0001.bin>


More information about the cfe-commits mailing list