scan-build: Disable distributed builds for xcodebuild


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50506 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/scan-build b/utils/scan-build
index 0eb7980..0024c8e 100755
--- a/utils/scan-build
+++ b/utils/scan-build
@@ -390,6 +390,23 @@
 # RunBuildCommand - Run the build command.
 ##----------------------------------------------------------------------------##
 
+sub AddIfNotPresent {
+  my $Args = shift;
+  my $Arg = shift;  
+  my $found = 0;
+  
+  foreach my $k (@$Args) {
+    if ($k eq $Arg) {
+      $found = 1;
+      last;
+    }
+  }
+  
+  if ($found == 0) {
+    push @$Args, $Arg;
+  }
+}
+
 sub RunBuildCommand {
   
   my $Args = shift;
@@ -402,12 +419,17 @@
   }
   elsif ($IgnoreErrors) {
     if ($Cmd eq "make" or $Cmd eq "gmake") {
-      push @$Args, "-k";
+      AddIfNotPresent($Args,"-k");
     }
     elsif ($Cmd eq "xcodebuild") {
-      push @$Args, "-PBXBuildsContinueAfterErrors=YES";
+      AddIfNotPresent($Args,"-PBXBuildsContinueAfterErrors=YES");
     }
-  }  
+  } 
+  
+  # Disable distributed builds for xcodebuild.
+  if ($Cmd eq "xcodebuild") {
+    AddIfNotPresent($Args,"-nodistribute");
+  }
   
   system(@$Args);
 }