Program: 53039
Project: 53039
Buggy source:
@VisibleForTesting static NdkCxxPlatform build(CxxBuckConfig config,Flavor flavor,Platform platform,Path ndkRoot,NdkCxxPlatformTargetConfiguration targetConfiguration,CxxRuntime cxxRuntime,ExecutableFinder executableFinder,boolean strictToolchainPaths){
  NdkCxxPlatformCompiler.Type compilerType=targetConfiguration.getCompiler().getType();
  String version=Joiner.on('-').join(ImmutableList.of(readVersion(ndkRoot),targetConfiguration.getToolchain(),targetConfiguration.getTargetAppPlatform(),compilerType,targetConfiguration.getCompiler().getVersion(),targetConfiguration.getCompiler().getGccVersion(),cxxRuntime));
  Host host=Preconditions.checkNotNull(BUILD_PLATFORMS.get(platform));
  NdkCxxToolchainPaths toolchainPaths=new NdkCxxToolchainPaths(ndkRoot,targetConfiguration,host.toString(),cxxRuntime,strictToolchainPaths);
  NdkCxxToolchainPaths sanitizedPaths=toolchainPaths.getSanitizedPaths();
  ImmutableBiMap.Builder<Path,Path> sanitizePaths=ImmutableBiMap.builder();
  sanitizePaths.put(toolchainPaths.getNdkToolRoot(),sanitizedPaths.getNdkToolRoot());
  if (compilerType != NdkCxxPlatformCompiler.Type.GCC) {
    sanitizePaths.put(toolchainPaths.getNdkGccToolRoot(),sanitizedPaths.getNdkGccToolRoot());
  }
  sanitizePaths.put(ndkRoot,Paths.get(ANDROID_NDK_ROOT));
  CxxToolProvider.Type type=compilerType == NdkCxxPlatformCompiler.Type.CLANG ? CxxToolProvider.Type.CLANG : CxxToolProvider.Type.GCC;
  ToolProvider ccTool=new ConstantToolProvider(getCTool(toolchainPaths,compilerType.getCc(),version,executableFinder));
  ToolProvider cxxTool=new ConstantToolProvider(getCTool(toolchainPaths,compilerType.getCxx(),version,executableFinder));
  CompilerProvider cc=new CompilerProvider(ccTool,type);
  PreprocessorProvider cpp=new PreprocessorProvider(ccTool,type);
  CompilerProvider cxx=new CompilerProvider(cxxTool,type);
  PreprocessorProvider cxxpp=new PreprocessorProvider(cxxTool,type);
  CxxPlatform.Builder cxxPlatformBuilder=CxxPlatform.builder();
  cxxPlatformBuilder.setFlavor(flavor).setAs(cc).addAllAsflags(getAsflags(targetConfiguration,toolchainPaths)).setAspp(cpp).setCc(cc).addAllCflags(getCflagsInternal(targetConfiguration,toolchainPaths)).setCpp(cpp).addAllCppflags(getCppflags(targetConfiguration,toolchainPaths)).setCxx(cxx).addAllCxxflags(getCxxflagsInternal(targetConfiguration,toolchainPaths)).setCxxpp(cxxpp).addAllCxxppflags(getCxxppflags(targetConfiguration,toolchainPaths)).setLd(new DefaultLinkerProvider(LinkerProvider.Type.GNU,new ConstantToolProvider(getCcLinkTool(targetConfiguration,toolchainPaths,compilerType.getCxx(),version,executableFinder)))).addAllLdflags(targetConfiguration.getLinkerFlags(compilerType)).addLdflags("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").setStrip(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)).setSymbolNameTool(new PosixNmSymbolNameTool(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder))).setAr(new GnuArchiver(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder))).setRanlib(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)).setDebugPathSanitizer(new MungingDebugPathSanitizer(config.getDebugPathSanitizerLimit(),File.separatorChar,Paths.get("String_Node_Str"),sanitizePaths.build())).setSharedLibraryExtension("String_Node_Str").setSharedLibraryVersionedExtensionFormat("String_Node_Str").setStaticLibraryExtension("String_Node_Str").setObjectFileExtension("String_Node_Str");
  if (cxxRuntime != CxxRuntime.SYSTEM) {
    cxxPlatformBuilder.putRuntimeLdflags(Linker.LinkableDepType.SHARED,"String_Node_Str" + cxxRuntime.getSharedName());
    cxxPlatformBuilder.putRuntimeLdflags(Linker.LinkableDepType.STATIC,"String_Node_Str" + cxxRuntime.getStaticName());
  }
  CxxPlatform cxxPlatform=cxxPlatformBuilder.build();
  return NdkCxxPlatform.builder().setCxxPlatform(cxxPlatform).setCxxRuntime(cxxRuntime).setCxxSharedRuntimePath(toolchainPaths.getCxxRuntimeLibsDirectory().resolve(cxxRuntime.getSoname())).setObjdump(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)).build();
}

Fixed version (ground truth):
@VisibleForTesting static NdkCxxPlatform build(CxxBuckConfig config,ProjectFilesystem filesystem,Flavor flavor,Platform platform,Path ndkRoot,NdkCxxPlatformTargetConfiguration targetConfiguration,CxxRuntime cxxRuntime,ExecutableFinder executableFinder,boolean strictToolchainPaths){
  NdkCxxPlatformCompiler.Type compilerType=targetConfiguration.getCompiler().getType();
  String version=Joiner.on('-').join(ImmutableList.of(readVersion(ndkRoot),targetConfiguration.getToolchain(),targetConfiguration.getTargetAppPlatform(),compilerType,targetConfiguration.getCompiler().getVersion(),targetConfiguration.getCompiler().getGccVersion(),cxxRuntime));
  Host host=Preconditions.checkNotNull(BUILD_PLATFORMS.get(platform));
  NdkCxxToolchainPaths toolchainPaths=new NdkCxxToolchainPaths(filesystem,ndkRoot,targetConfiguration,host.toString(),cxxRuntime,strictToolchainPaths);
  NdkCxxToolchainPaths sanitizedPaths=toolchainPaths.getSanitizedPaths();
  ImmutableBiMap.Builder<Path,Path> sanitizePaths=ImmutableBiMap.builder();
  sanitizePaths.put(toolchainPaths.getNdkToolRoot(),sanitizedPaths.getNdkToolRoot());
  if (compilerType != NdkCxxPlatformCompiler.Type.GCC) {
    sanitizePaths.put(toolchainPaths.getNdkGccToolRoot(),sanitizedPaths.getNdkGccToolRoot());
  }
  sanitizePaths.put(ndkRoot,Paths.get(ANDROID_NDK_ROOT));
  CxxToolProvider.Type type=compilerType == NdkCxxPlatformCompiler.Type.CLANG ? CxxToolProvider.Type.CLANG : CxxToolProvider.Type.GCC;
  ToolProvider ccTool=new ConstantToolProvider(getCTool(toolchainPaths,compilerType.getCc(),version,executableFinder));
  ToolProvider cxxTool=new ConstantToolProvider(getCTool(toolchainPaths,compilerType.getCxx(),version,executableFinder));
  CompilerProvider cc=new CompilerProvider(ccTool,type);
  PreprocessorProvider cpp=new PreprocessorProvider(ccTool,type);
  CompilerProvider cxx=new CompilerProvider(cxxTool,type);
  PreprocessorProvider cxxpp=new PreprocessorProvider(cxxTool,type);
  CxxPlatform.Builder cxxPlatformBuilder=CxxPlatform.builder();
  PrefixMapDebugPathSanitizer debugPathSanitizer=new PrefixMapDebugPathSanitizer(config.getDebugPathSanitizerLimit(),File.separatorChar,Paths.get("String_Node_Str"),sanitizePaths.build(),filesystem.getRootPath().toAbsolutePath(),type);
  ImmutableList<String> sanitizerFlags=debugPathSanitizer.getCompilationFlags();
  cxxPlatformBuilder.setFlavor(flavor).setAs(cc).addAllAsflags(getAsflags(targetConfiguration,toolchainPaths,sanitizerFlags)).setAspp(cpp).setCc(cc).addAllCflags(getCflagsInternal(targetConfiguration,toolchainPaths)).setCpp(cpp).addAllCppflags(getCppflags(targetConfiguration,toolchainPaths,sanitizerFlags)).setCxx(cxx).addAllCxxflags(getCxxflagsInternal(targetConfiguration,toolchainPaths,sanitizerFlags)).setCxxpp(cxxpp).addAllCxxppflags(getCxxppflags(targetConfiguration,toolchainPaths,sanitizerFlags)).setLd(new DefaultLinkerProvider(LinkerProvider.Type.GNU,new ConstantToolProvider(getCcLinkTool(targetConfiguration,toolchainPaths,compilerType.getCxx(),version,executableFinder)))).addAllLdflags(targetConfiguration.getLinkerFlags(compilerType)).addLdflags("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str").setStrip(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)).setSymbolNameTool(new PosixNmSymbolNameTool(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder))).setAr(new GnuArchiver(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder))).setRanlib(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)).setDebugPathSanitizer(debugPathSanitizer).setSharedLibraryExtension("String_Node_Str").setSharedLibraryVersionedExtensionFormat("String_Node_Str").setStaticLibraryExtension("String_Node_Str").setObjectFileExtension("String_Node_Str");
  if (cxxRuntime != CxxRuntime.SYSTEM) {
    cxxPlatformBuilder.putRuntimeLdflags(Linker.LinkableDepType.SHARED,"String_Node_Str" + cxxRuntime.getSharedName());
    cxxPlatformBuilder.putRuntimeLdflags(Linker.LinkableDepType.STATIC,"String_Node_Str" + cxxRuntime.getStaticName());
  }
  CxxPlatform cxxPlatform=cxxPlatformBuilder.build();
  return NdkCxxPlatform.builder().setCxxPlatform(cxxPlatform).setCxxRuntime(cxxRuntime).setCxxSharedRuntimePath(toolchainPaths.getCxxRuntimeLibsDirectory().resolve(cxxRuntime.getSoname())).setObjdump(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)).build();
}