Program: 53156
Project: 53156
Buggy source:
@VisibleForTesting static AppleCxxPlatform buildWithExecutableChecker(AppleSdk targetSdk,String minVersion,String targetArchitecture,AppleSdkPaths sdkPaths,BuckConfig buckConfig,ExecutableFinder executableFinder){
  ImmutableList.Builder<Path> toolSearchPathsBuilder=ImmutableList.builder();
  toolSearchPathsBuilder.add(sdkPaths.getSdkPath().resolve(USR_BIN)).add(sdkPaths.getSdkPath().resolve("String_Node_Str").resolve(USR_BIN)).add(sdkPaths.getPlatformPath().resolve("String_Node_Str").resolve(USR_BIN));
  for (  Path toolchainPath : sdkPaths.getToolchainPaths()) {
    toolSearchPathsBuilder.add(toolchainPath.resolve(USR_BIN));
  }
  if (sdkPaths.getDeveloperPath().isPresent()) {
    toolSearchPathsBuilder.add(sdkPaths.getDeveloperPath().get().resolve(USR_BIN));
    toolSearchPathsBuilder.add(sdkPaths.getDeveloperPath().get().resolve("String_Node_Str"));
  }
  ImmutableList<Path> toolSearchPaths=toolSearchPathsBuilder.build();
  ImmutableList.Builder<String> cflagsBuilder=ImmutableList.builder();
  cflagsBuilder.add("String_Node_Str",sdkPaths.getSdkPath().toString());
  cflagsBuilder.add("String_Node_Str",targetArchitecture);
switch (targetSdk.getApplePlatform().getName()) {
case ApplePlatform.Name.IPHONEOS:
    cflagsBuilder.add("String_Node_Str" + minVersion);
  break;
case ApplePlatform.Name.IPHONESIMULATOR:
cflagsBuilder.add("String_Node_Str" + minVersion);
break;
case ApplePlatform.Name.WATCHOS:
cflagsBuilder.add("String_Node_Str" + minVersion);
break;
case ApplePlatform.Name.WATCHSIMULATOR:
cflagsBuilder.add("String_Node_Str" + minVersion);
break;
default :
cflagsBuilder.add("String_Node_Str" + targetSdk.getApplePlatform().getName() + "String_Node_Str"+ minVersion);
break;
}
ImmutableList<String> ldflags=ImmutableList.copyOf(Linkers.iXlinker("String_Node_Str",targetSdk.getVersion()));
ImmutableList<String> asflags=ImmutableList.of("String_Node_Str",targetArchitecture);
ImmutableList.Builder<String> versionsBuilder=ImmutableList.builder();
versionsBuilder.add(targetSdk.getVersion());
for (AppleToolchain toolchain : targetSdk.getToolchains()) {
versionsBuilder.add(toolchain.getVersion());
}
String version=Joiner.on(':').join(versionsBuilder.build());
Tool clangPath=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool clangXxPath=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool ar=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool strip=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool actool=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool ibtool=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool xctest=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Optional<Tool> otest=getOptionalTool("String_Node_Str",toolSearchPaths,executableFinder,version);
Tool dsymutil=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
CxxBuckConfig config=new CxxBuckConfig(buckConfig);
ImmutableFlavor targetFlavor=ImmutableFlavor.of(ImmutableFlavor.replaceInvalidCharacters(targetSdk.getName() + "String_Node_Str" + targetArchitecture));
ImmutableBiMap.Builder<Path,Path> sanitizerPaths=ImmutableBiMap.builder();
sanitizerPaths.put(sdkPaths.getSdkPath(),Paths.get("String_Node_Str"));
sanitizerPaths.put(sdkPaths.getPlatformPath(),Paths.get("String_Node_Str"));
if (sdkPaths.getDeveloperPath().isPresent()) {
sanitizerPaths.put(sdkPaths.getDeveloperPath().get(),Paths.get("String_Node_Str"));
}
DebugPathSanitizer debugPathSanitizer=new DebugPathSanitizer(250,File.separatorChar,Paths.get("String_Node_Str"),sanitizerPaths.build());
ImmutableList<String> cflags=cflagsBuilder.build();
ImmutableMap.Builder<String,String> macrosBuilder=ImmutableMap.builder();
macrosBuilder.put("String_Node_Str",sdkPaths.getSdkPath().toString());
macrosBuilder.put("String_Node_Str",sdkPaths.getPlatformPath().toString());
if (sdkPaths.getDeveloperPath().isPresent()) {
macrosBuilder.put("String_Node_Str",sdkPaths.getDeveloperPath().get().toString());
}
ImmutableMap<String,String> macros=macrosBuilder.build();
CxxPlatform cxxPlatform=CxxPlatforms.build(targetFlavor,config,clangPath,new ClangPreprocessor(clangPath),new ClangCompiler(clangPath),new ClangCompiler(clangXxPath),new ClangPreprocessor(clangPath),new ClangPreprocessor(clangXxPath),new DarwinLinker(clangXxPath),ImmutableList.<String>builder().addAll(cflags).addAll(ldflags).build(),strip,new BsdArchiver(ar),asflags,ImmutableList.<String>of(),cflags,ImmutableList.<String>of(),getOptionalTool("String_Node_Str",toolSearchPaths,executableFinder,version),getOptionalTool("String_Node_Str",toolSearchPaths,executableFinder,version),"String_Node_Str",Optional.of(debugPathSanitizer),macros);
return AppleCxxPlatform.builder().setCxxPlatform(cxxPlatform).setAppleSdk(targetSdk).setAppleSdkPaths(sdkPaths).setActool(actool).setIbtool(ibtool).setXctest(xctest).setOtest(otest).setDsymutil(dsymutil).build();
}

Fixed version (ground truth):
@VisibleForTesting static AppleCxxPlatform buildWithExecutableChecker(AppleSdk targetSdk,String minVersion,String targetArchitecture,AppleSdkPaths sdkPaths,BuckConfig buckConfig,ExecutableFinder executableFinder){
  ImmutableList.Builder<Path> toolSearchPathsBuilder=ImmutableList.builder();
  toolSearchPathsBuilder.add(sdkPaths.getSdkPath().resolve(USR_BIN)).add(sdkPaths.getSdkPath().resolve("String_Node_Str").resolve(USR_BIN)).add(sdkPaths.getPlatformPath().resolve("String_Node_Str").resolve(USR_BIN));
  for (  Path toolchainPath : sdkPaths.getToolchainPaths()) {
    toolSearchPathsBuilder.add(toolchainPath.resolve(USR_BIN));
  }
  if (sdkPaths.getDeveloperPath().isPresent()) {
    toolSearchPathsBuilder.add(sdkPaths.getDeveloperPath().get().resolve(USR_BIN));
    toolSearchPathsBuilder.add(sdkPaths.getDeveloperPath().get().resolve("String_Node_Str"));
  }
  ImmutableList<Path> toolSearchPaths=toolSearchPathsBuilder.build();
  ImmutableList.Builder<String> cflagsBuilder=ImmutableList.builder();
  cflagsBuilder.add("String_Node_Str",sdkPaths.getSdkPath().toString());
  cflagsBuilder.add("String_Node_Str",targetArchitecture);
switch (targetSdk.getApplePlatform().getName()) {
case ApplePlatform.Name.IPHONEOS:
    cflagsBuilder.add("String_Node_Str" + minVersion);
  break;
case ApplePlatform.Name.IPHONESIMULATOR:
cflagsBuilder.add("String_Node_Str" + minVersion);
break;
case ApplePlatform.Name.WATCHOS:
cflagsBuilder.add("String_Node_Str" + minVersion);
break;
case ApplePlatform.Name.WATCHSIMULATOR:
cflagsBuilder.add("String_Node_Str" + minVersion);
break;
default :
cflagsBuilder.add("String_Node_Str" + targetSdk.getApplePlatform().getName() + "String_Node_Str"+ minVersion);
break;
}
ImmutableList<String> asflags=cflagsBuilder.build();
ImmutableList<String> ldflags=ImmutableList.copyOf(Linkers.iXlinker("String_Node_Str",targetSdk.getVersion()));
ImmutableList.Builder<String> versionsBuilder=ImmutableList.builder();
versionsBuilder.add(targetSdk.getVersion());
for (AppleToolchain toolchain : targetSdk.getToolchains()) {
versionsBuilder.add(toolchain.getVersion());
}
String version=Joiner.on(':').join(versionsBuilder.build());
Tool clangPath=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool clangXxPath=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool ar=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool strip=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool actool=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool ibtool=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Tool xctest=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
Optional<Tool> otest=getOptionalTool("String_Node_Str",toolSearchPaths,executableFinder,version);
Tool dsymutil=new VersionedTool(getToolPath("String_Node_Str",toolSearchPaths,executableFinder),ImmutableList.<String>of(),"String_Node_Str",version);
CxxBuckConfig config=new CxxBuckConfig(buckConfig);
ImmutableFlavor targetFlavor=ImmutableFlavor.of(ImmutableFlavor.replaceInvalidCharacters(targetSdk.getName() + "String_Node_Str" + targetArchitecture));
ImmutableBiMap.Builder<Path,Path> sanitizerPaths=ImmutableBiMap.builder();
sanitizerPaths.put(sdkPaths.getSdkPath(),Paths.get("String_Node_Str"));
sanitizerPaths.put(sdkPaths.getPlatformPath(),Paths.get("String_Node_Str"));
if (sdkPaths.getDeveloperPath().isPresent()) {
sanitizerPaths.put(sdkPaths.getDeveloperPath().get(),Paths.get("String_Node_Str"));
}
DebugPathSanitizer debugPathSanitizer=new DebugPathSanitizer(250,File.separatorChar,Paths.get("String_Node_Str"),sanitizerPaths.build());
ImmutableList<String> cflags=cflagsBuilder.build();
ImmutableMap.Builder<String,String> macrosBuilder=ImmutableMap.builder();
macrosBuilder.put("String_Node_Str",sdkPaths.getSdkPath().toString());
macrosBuilder.put("String_Node_Str",sdkPaths.getPlatformPath().toString());
if (sdkPaths.getDeveloperPath().isPresent()) {
macrosBuilder.put("String_Node_Str",sdkPaths.getDeveloperPath().get().toString());
}
ImmutableMap<String,String> macros=macrosBuilder.build();
CxxPlatform cxxPlatform=CxxPlatforms.build(targetFlavor,config,clangPath,new ClangPreprocessor(clangPath),new ClangCompiler(clangPath),new ClangCompiler(clangXxPath),new ClangPreprocessor(clangPath),new ClangPreprocessor(clangXxPath),new DarwinLinker(clangXxPath),ImmutableList.<String>builder().addAll(cflags).addAll(ldflags).build(),strip,new BsdArchiver(ar),asflags,ImmutableList.<String>of(),cflags,ImmutableList.<String>of(),getOptionalTool("String_Node_Str",toolSearchPaths,executableFinder,version),getOptionalTool("String_Node_Str",toolSearchPaths,executableFinder,version),"String_Node_Str",Optional.of(debugPathSanitizer),macros);
return AppleCxxPlatform.builder().setCxxPlatform(cxxPlatform).setAppleSdk(targetSdk).setAppleSdkPaths(sdkPaths).setActool(actool).setIbtool(ibtool).setXctest(xctest).setOtest(otest).setDsymutil(dsymutil).build();
}