Program: 52893
Project: 52893
Buggy source:
@VisibleForTesting static NdkCxxPlatform build(CxxBuckConfig config,AndroidBuckConfig androidConfig,ProjectFilesystem filesystem,Flavor flavor,Platform platform,Path ndkRoot,NdkCxxPlatformTargetConfiguration targetConfiguration,NdkCxxRuntime 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,String> sanitizePathsBuilder=ImmutableBiMap.builder();
  sanitizePathsBuilder.put(toolchainPaths.getNdkToolRoot(),sanitizedPaths.getNdkToolRoot().toString());
  if (compilerType != NdkCxxPlatformCompiler.Type.GCC) {
    sanitizePathsBuilder.put(toolchainPaths.getNdkGccToolRoot(),sanitizedPaths.getNdkGccToolRoot().toString());
  }
  sanitizePathsBuilder.put(ndkRoot,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();
  ImmutableBiMap<Path,String> sanitizePaths=sanitizePathsBuilder.build();
  PrefixMapDebugPathSanitizer compilerDebugPathSanitizer=new PrefixMapDebugPathSanitizer("String_Node_Str",sanitizePaths,type);
  MungingDebugPathSanitizer assemblerDebugPathSanitizer=new MungingDebugPathSanitizer(config.getDebugPathSanitizerLimit(),File.separatorChar,Paths.get("String_Node_Str"),sanitizePaths);
  cxxPlatformBuilder.setFlavor(flavor).setAs(cc).addAllAsflags(getAsflags(targetConfiguration,toolchainPaths)).setAspp(cpp).setCc(cc).addAllCflags(getCCompilationFlags(targetConfiguration,toolchainPaths,androidConfig)).setCpp(cpp).addAllCppflags(getCPreprocessorFlags(targetConfiguration,toolchainPaths,androidConfig)).setCxx(cxx).addAllCxxflags(getCxxCompilationFlags(targetConfiguration,toolchainPaths,androidConfig)).setCxxpp(cxxpp).addAllCxxppflags(getCxxPreprocessorFlags(targetConfiguration,toolchainPaths,androidConfig)).setLd(new DefaultLinkerProvider(LinkerProvider.Type.GNU,new ConstantToolProvider(getCcLinkTool(targetConfiguration,toolchainPaths,compilerType.getCxx(),version,cxxRuntime,executableFinder)))).addAllLdflags(getLdFlags(targetConfiguration,androidConfig)).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)).setCompilerDebugPathSanitizer(compilerDebugPathSanitizer).setAssemblerDebugPathSanitizer(assemblerDebugPathSanitizer).setSharedLibraryExtension("String_Node_Str").setSharedLibraryVersionedExtensionFormat("String_Node_Str").setStaticLibraryExtension("String_Node_Str").setObjectFileExtension("String_Node_Str").setSharedLibraryInterfaceFactory(config.shouldUseSharedLibraryInterfaces() ? Optional.of(ElfSharedLibraryInterfaceFactory.of(new ConstantToolProvider(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)))) : Optional.empty()).setPublicHeadersSymlinksEnabled(config.getPublicHeadersSymlinksEnabled()).setPrivateHeadersSymlinksEnabled(config.getPrivateHeadersSymlinksEnabled());
  HeaderVerification headerVerification=config.getHeaderVerification();
  try {
    headerVerification=headerVerification.withPlatformWhitelist(ImmutableList.of("String_Node_Str" + Pattern.quote(ndkRoot.toRealPath().toString() + File.separatorChar) + "String_Node_Str"));
  }
 catch (  IOException e) {
    LOG.warn(e,"String_Node_Str",ndkRoot);
  }
  cxxPlatformBuilder.setHeaderVerification(headerVerification);
  LOG.debug("String_Node_Str",ndkRoot.toString());
  LOG.debug("String_Node_Str",headerVerification.getPlatformWhitelist());
  if (cxxRuntime != NdkCxxRuntime.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();
  NdkCxxPlatform.Builder builder=NdkCxxPlatform.builder();
  builder.setCxxPlatform(cxxPlatform).setCxxRuntime(cxxRuntime).setObjdump(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder));
  if (cxxRuntime != NdkCxxRuntime.SYSTEM) {
    builder.setCxxSharedRuntimePath(toolchainPaths.getCxxRuntimeLibsDirectory().resolve(cxxRuntime.getSoname()));
  }
  return builder.build();
}

Fixed version (ground truth):
@VisibleForTesting static NdkCxxPlatform build(CxxBuckConfig config,AndroidBuckConfig androidConfig,ProjectFilesystem filesystem,Flavor flavor,Platform platform,Path ndkRoot,NdkCxxPlatformTargetConfiguration targetConfiguration,NdkCxxRuntime 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,String> sanitizePathsBuilder=ImmutableBiMap.builder();
  sanitizePathsBuilder.put(toolchainPaths.getNdkToolRoot(),sanitizedPaths.getNdkToolRoot().toString());
  if (compilerType != NdkCxxPlatformCompiler.Type.GCC) {
    sanitizePathsBuilder.put(toolchainPaths.getNdkGccToolRoot(),sanitizedPaths.getNdkGccToolRoot().toString());
  }
  sanitizePathsBuilder.put(ndkRoot,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();
  ImmutableBiMap<Path,String> sanitizePaths=sanitizePathsBuilder.build();
  PrefixMapDebugPathSanitizer compilerDebugPathSanitizer=new PrefixMapDebugPathSanitizer("String_Node_Str",sanitizePaths);
  MungingDebugPathSanitizer assemblerDebugPathSanitizer=new MungingDebugPathSanitizer(config.getDebugPathSanitizerLimit(),File.separatorChar,Paths.get("String_Node_Str"),sanitizePaths);
  cxxPlatformBuilder.setFlavor(flavor).setAs(cc).addAllAsflags(getAsflags(targetConfiguration,toolchainPaths)).setAspp(cpp).setCc(cc).addAllCflags(getCCompilationFlags(targetConfiguration,toolchainPaths,androidConfig)).setCpp(cpp).addAllCppflags(getCPreprocessorFlags(targetConfiguration,toolchainPaths,androidConfig)).setCxx(cxx).addAllCxxflags(getCxxCompilationFlags(targetConfiguration,toolchainPaths,androidConfig)).setCxxpp(cxxpp).addAllCxxppflags(getCxxPreprocessorFlags(targetConfiguration,toolchainPaths,androidConfig)).setLd(new DefaultLinkerProvider(LinkerProvider.Type.GNU,new ConstantToolProvider(getCcLinkTool(targetConfiguration,toolchainPaths,compilerType.getCxx(),version,cxxRuntime,executableFinder)))).addAllLdflags(getLdFlags(targetConfiguration,androidConfig)).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)).setCompilerDebugPathSanitizer(compilerDebugPathSanitizer).setAssemblerDebugPathSanitizer(assemblerDebugPathSanitizer).setSharedLibraryExtension("String_Node_Str").setSharedLibraryVersionedExtensionFormat("String_Node_Str").setStaticLibraryExtension("String_Node_Str").setObjectFileExtension("String_Node_Str").setSharedLibraryInterfaceFactory(config.shouldUseSharedLibraryInterfaces() ? Optional.of(ElfSharedLibraryInterfaceFactory.of(new ConstantToolProvider(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder)))) : Optional.empty()).setPublicHeadersSymlinksEnabled(config.getPublicHeadersSymlinksEnabled()).setPrivateHeadersSymlinksEnabled(config.getPrivateHeadersSymlinksEnabled());
  HeaderVerification headerVerification=config.getHeaderVerification();
  try {
    headerVerification=headerVerification.withPlatformWhitelist(ImmutableList.of("String_Node_Str" + Pattern.quote(ndkRoot.toRealPath().toString() + File.separatorChar) + "String_Node_Str"));
  }
 catch (  IOException e) {
    LOG.warn(e,"String_Node_Str",ndkRoot);
  }
  cxxPlatformBuilder.setHeaderVerification(headerVerification);
  LOG.debug("String_Node_Str",ndkRoot.toString());
  LOG.debug("String_Node_Str",headerVerification.getPlatformWhitelist());
  if (cxxRuntime != NdkCxxRuntime.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();
  NdkCxxPlatform.Builder builder=NdkCxxPlatform.builder();
  builder.setCxxPlatform(cxxPlatform).setCxxRuntime(cxxRuntime).setObjdump(getGccTool(toolchainPaths,"String_Node_Str",version,executableFinder));
  if (cxxRuntime != NdkCxxRuntime.SYSTEM) {
    builder.setCxxSharedRuntimePath(toolchainPaths.getCxxRuntimeLibsDirectory().resolve(cxxRuntime.getSoname()));
  }
  return builder.build();
}