Program: 110871
Project: 110871
Buggy source:
/** 
 * Create the C++ compile and link actions, and the corresponding C++-related providers.
 * @throws RuleErrorException
 */
public Info build() throws RuleErrorException, InterruptedException {
  Preconditions.checkState(ruleContext.getRule().getRuleClass().equals("String_Node_Str") || ruleContext.getRule().isAttrDefined("String_Node_Str",BuildType.LABEL));
  if (checkDepsGenerateCpp) {
    for (    LanguageDependentFragment dep : AnalysisUtils.getProviders(implementationDeps,LanguageDependentFragment.class)) {
      LanguageDependentFragment.Checker.depSupportsLanguage(ruleContext,dep,CppRuleClasses.LANGUAGE);
    }
  }
  CppModel model=initializeCppModel();
  CppCompilationContext cppCompilationContext=initializeCppCompilationContext(model,false);
  model.setContext(cppCompilationContext);
  CppCompilationContext interfaceCompilationContext=cppCompilationContext;
  if (implementationDeps.size() != interfaceDeps.size()) {
    interfaceCompilationContext=initializeCppCompilationContext(model,true);
  }
  model.setInterfaceContext(interfaceCompilationContext);
  boolean compileHeaderModules=featureConfiguration.isEnabled(CppRuleClasses.HEADER_MODULES);
  Preconditions.checkState(!compileHeaderModules || cppCompilationContext.getCppModuleMap() != null,"String_Node_Str");
  CcCompilationOutputs ccOutputs=model.createCcCompileActions();
  if (!objectFiles.isEmpty() || !picObjectFiles.isEmpty()) {
    ccOutputs=new CcCompilationOutputs.Builder().merge(ccOutputs).addLTOBitcodeFile(ccOutputs.getLtoBitcodeFiles()).addObjectFiles(objectFiles).addPicObjectFiles(picObjectFiles).build();
  }
  CcLinkingOutputs ccLinkingOutputs=CcLinkingOutputs.EMPTY;
  if (emitLinkActionsIfEmpty || !ccOutputs.isEmpty()) {
    if (linkType.staticness() == Staticness.STATIC) {
      ccLinkingOutputs=model.createCcLinkActions(ccOutputs,nonCodeLinkerInputs);
    }
  }
  CcLinkingOutputs originalLinkingOutputs=ccLinkingOutputs;
  if (!(staticLibraries.isEmpty() && picStaticLibraries.isEmpty() && dynamicLibraries.isEmpty())) {
    CcLinkingOutputs.Builder newOutputsBuilder=new CcLinkingOutputs.Builder();
    if (!ccOutputs.isEmpty()) {
      newOutputsBuilder.merge(originalLinkingOutputs);
      ImmutableSetMultimap<String,LibraryToLink> precompiledLibraryMap=CcLinkingOutputs.getLibrariesByIdentifier(Iterables.concat(staticLibraries,picStaticLibraries,dynamicLibraries));
      ImmutableSetMultimap<String,LibraryToLink> linkedLibraryMap=originalLinkingOutputs.getLibrariesByIdentifier();
      for (      String matchingIdentifier : Sets.intersection(precompiledLibraryMap.keySet(),linkedLibraryMap.keySet())) {
        Iterable<Artifact> matchingInputLibs=LinkerInputs.toNonSolibArtifacts(precompiledLibraryMap.get(matchingIdentifier));
        Iterable<Artifact> matchingOutputLibs=LinkerInputs.toNonSolibArtifacts(linkedLibraryMap.get(matchingIdentifier));
        ruleContext.ruleError("String_Node_Str" + Joiner.on("String_Node_Str").join(Iterables.transform(matchingInputLibs,FileType.TO_FILENAME)) + "String_Node_Str"+ ruleContext.getRuleClassNameForLogging()+ "String_Node_Str"+ ruleContext.getRule().getName()+ "String_Node_Str"+ Joiner.on("String_Node_Str").join(Iterables.transform(matchingOutputLibs,FileType.TO_FILENAME))+ "String_Node_Str"+ "String_Node_Str");
      }
    }
    ccLinkingOutputs=newOutputsBuilder.addStaticLibraries(staticLibraries).addPicStaticLibraries(picStaticLibraries).addDynamicLibraries(dynamicLibraries).addExecutionDynamicLibraries(dynamicLibraries).build();
  }
  DwoArtifactsCollector dwoArtifacts=DwoArtifactsCollector.transitiveCollector(ccOutputs,implementationDeps);
  Runfiles cppStaticRunfiles=collectCppRunfiles(ccLinkingOutputs,true);
  Runfiles cppSharedRunfiles=collectCppRunfiles(ccLinkingOutputs,false);
  Map<Class<? extends TransitiveInfoProvider>,TransitiveInfoProvider> providers=new LinkedHashMap<>();
  providers.put(CppRunfilesProvider.class,new CppRunfilesProvider(cppStaticRunfiles,cppSharedRunfiles));
  providers.put(CppCompilationContext.class,interfaceCompilationContext);
  providers.put(CppDebugFileProvider.class,new CppDebugFileProvider(dwoArtifacts.getDwoArtifacts(),dwoArtifacts.getPicDwoArtifacts()));
  providers.put(TransitiveLipoInfoProvider.class,collectTransitiveLipoInfo(ccOutputs));
  Map<String,NestedSet<Artifact>> outputGroups=new TreeMap<>();
  if (shouldAddLinkerOutputArtifacts(ruleContext,ccOutputs)) {
    addLinkerOutputArtifacts(outputGroups);
  }
  outputGroups.put(OutputGroupProvider.TEMP_FILES,getTemps(ccOutputs));
  if (emitCompileProviders) {
    boolean isLipoCollector=ruleContext.getFragment(CppConfiguration.class).isLipoContextCollector();
    boolean processHeadersInDependencies=ruleContext.getFragment(CppConfiguration.class).processHeadersInDependencies();
    boolean usePic=CppHelper.usePic(ruleContext,false);
    outputGroups.put(OutputGroupProvider.FILES_TO_COMPILE,ccOutputs.getFilesToCompile(isLipoCollector,processHeadersInDependencies,usePic));
    outputGroups.put(OutputGroupProvider.COMPILATION_PREREQUISITES,CcCommon.collectCompilationPrerequisites(ruleContext,cppCompilationContext));
  }
  if (emitCcNativeLibrariesProvider) {
    providers.put(CcNativeLibraryProvider.class,new CcNativeLibraryProvider(collectNativeCcLibraries(ccLinkingOutputs)));
  }
  providers.put(CcExecutionDynamicLibrariesProvider.class,collectExecutionDynamicLibraryArtifacts(ccLinkingOutputs.getExecutionDynamicLibraries()));
  boolean forcePic=ruleContext.getFragment(CppConfiguration.class).forcePic();
  if (emitCcSpecificLinkParamsProvider) {
    providers.put(CcSpecificLinkParamsProvider.class,new CcSpecificLinkParamsProvider(createCcLinkParamsStore(ccLinkingOutputs,cppCompilationContext,forcePic)));
  }
 else {
    providers.put(CcLinkParamsProvider.class,new CcLinkParamsProvider(createCcLinkParamsStore(ccLinkingOutputs,cppCompilationContext,forcePic)));
  }
  return new Info(providers,outputGroups,ccOutputs,ccLinkingOutputs,originalLinkingOutputs,cppCompilationContext);
}

Fixed version (ground truth):
/** 
 * Create the C++ compile and link actions, and the corresponding C++-related providers.
 * @throws RuleErrorException
 */
public Info build() throws RuleErrorException, InterruptedException {
  Preconditions.checkState(ruleContext.getRule().getRuleClass().equals("String_Node_Str") || ruleContext.getRule().isAttrDefined("String_Node_Str",BuildType.LABEL));
  if (checkDepsGenerateCpp) {
    for (    LanguageDependentFragment dep : AnalysisUtils.getProviders(implementationDeps,LanguageDependentFragment.class)) {
      LanguageDependentFragment.Checker.depSupportsLanguage(ruleContext,dep,CppRuleClasses.LANGUAGE);
    }
  }
  CppModel model=initializeCppModel();
  CppCompilationContext cppCompilationContext=initializeCppCompilationContext(model,false);
  model.setContext(cppCompilationContext);
  CppCompilationContext interfaceCompilationContext=cppCompilationContext;
  if (implementationDeps.size() != interfaceDeps.size()) {
    interfaceCompilationContext=initializeCppCompilationContext(model,true);
  }
  model.setInterfaceContext(interfaceCompilationContext);
  boolean compileHeaderModules=featureConfiguration.isEnabled(CppRuleClasses.HEADER_MODULES);
  Preconditions.checkState(!compileHeaderModules || cppCompilationContext.getCppModuleMap() != null,"String_Node_Str");
  CcCompilationOutputs ccOutputs=model.createCcCompileActions();
  if (!objectFiles.isEmpty() || !picObjectFiles.isEmpty()) {
    ccOutputs=new CcCompilationOutputs.Builder().merge(ccOutputs).addLTOBitcodeFile(ccOutputs.getLtoBitcodeFiles()).addObjectFiles(objectFiles).addPicObjectFiles(picObjectFiles).build();
  }
  CcLinkingOutputs ccLinkingOutputs=CcLinkingOutputs.EMPTY;
  if (emitLinkActionsIfEmpty || !ccOutputs.isEmpty()) {
    if (linkType.staticness() == Staticness.STATIC) {
      ccLinkingOutputs=model.createCcLinkActions(ccOutputs,nonCodeLinkerInputs);
    }
  }
  CcLinkingOutputs originalLinkingOutputs=ccLinkingOutputs;
  if (!(staticLibraries.isEmpty() && picStaticLibraries.isEmpty() && dynamicLibraries.isEmpty())) {
    CcLinkingOutputs.Builder newOutputsBuilder=new CcLinkingOutputs.Builder();
    if (!ccOutputs.isEmpty()) {
      newOutputsBuilder.merge(originalLinkingOutputs);
      ImmutableSetMultimap<String,LibraryToLink> precompiledLibraryMap=CcLinkingOutputs.getLibrariesByIdentifier(Iterables.concat(staticLibraries,picStaticLibraries,dynamicLibraries));
      ImmutableSetMultimap<String,LibraryToLink> linkedLibraryMap=originalLinkingOutputs.getLibrariesByIdentifier();
      for (      String matchingIdentifier : Sets.intersection(precompiledLibraryMap.keySet(),linkedLibraryMap.keySet())) {
        Iterable<Artifact> matchingInputLibs=LinkerInputs.toNonSolibArtifacts(precompiledLibraryMap.get(matchingIdentifier));
        Iterable<Artifact> matchingOutputLibs=LinkerInputs.toNonSolibArtifacts(linkedLibraryMap.get(matchingIdentifier));
        ruleContext.ruleError("String_Node_Str" + Joiner.on("String_Node_Str").join(Iterables.transform(matchingInputLibs,FileType.TO_FILENAME)) + "String_Node_Str"+ ruleContext.getRuleClassNameForLogging()+ "String_Node_Str"+ ruleContext.getRule().getName()+ "String_Node_Str"+ Joiner.on("String_Node_Str").join(Iterables.transform(matchingOutputLibs,FileType.TO_FILENAME))+ "String_Node_Str"+ "String_Node_Str");
      }
    }
    ccLinkingOutputs=newOutputsBuilder.addStaticLibraries(staticLibraries).addPicStaticLibraries(picStaticLibraries).addDynamicLibraries(dynamicLibraries).addExecutionDynamicLibraries(dynamicLibraries).build();
  }
  DwoArtifactsCollector dwoArtifacts=DwoArtifactsCollector.transitiveCollector(ccOutputs,implementationDeps);
  Runfiles cppStaticRunfiles=collectCppRunfiles(ccLinkingOutputs,true);
  Runfiles cppSharedRunfiles=collectCppRunfiles(ccLinkingOutputs,false);
  Map<Class<? extends TransitiveInfoProvider>,TransitiveInfoProvider> providers=new LinkedHashMap<>();
  providers.put(CppRunfilesProvider.class,new CppRunfilesProvider(cppStaticRunfiles,cppSharedRunfiles));
  providers.put(CppCompilationContext.class,interfaceCompilationContext);
  providers.put(CppDebugFileProvider.class,new CppDebugFileProvider(dwoArtifacts.getDwoArtifacts(),dwoArtifacts.getPicDwoArtifacts()));
  providers.put(TransitiveLipoInfoProvider.class,collectTransitiveLipoInfo(ccOutputs));
  Map<String,NestedSet<Artifact>> outputGroups=new TreeMap<>();
  if (shouldAddLinkerOutputArtifacts(ruleContext,ccOutputs)) {
    addLinkerOutputArtifacts(outputGroups);
  }
  outputGroups.put(OutputGroupProvider.TEMP_FILES,getTemps(ccOutputs));
  CppConfiguration cppConfiguration=ruleContext.getFragment(CppConfiguration.class);
  if (emitCompileProviders) {
    boolean isLipoCollector=cppConfiguration.isLipoContextCollector();
    boolean processHeadersInDependencies=cppConfiguration.processHeadersInDependencies();
    boolean usePic=CppHelper.usePic(ruleContext,false);
    outputGroups.put(OutputGroupProvider.FILES_TO_COMPILE,ccOutputs.getFilesToCompile(isLipoCollector,processHeadersInDependencies,usePic));
    outputGroups.put(OutputGroupProvider.COMPILATION_PREREQUISITES,CcCommon.collectCompilationPrerequisites(ruleContext,cppCompilationContext));
  }
  if (emitCcNativeLibrariesProvider) {
    providers.put(CcNativeLibraryProvider.class,new CcNativeLibraryProvider(collectNativeCcLibraries(ccLinkingOutputs)));
  }
  providers.put(CcExecutionDynamicLibrariesProvider.class,collectExecutionDynamicLibraryArtifacts(ccLinkingOutputs.getExecutionDynamicLibraries()));
  boolean forcePic=cppConfiguration.forcePic();
  if (emitCcSpecificLinkParamsProvider) {
    providers.put(CcSpecificLinkParamsProvider.class,new CcSpecificLinkParamsProvider(createCcLinkParamsStore(ccLinkingOutputs,cppCompilationContext,forcePic)));
  }
 else {
    providers.put(CcLinkParamsProvider.class,new CcLinkParamsProvider(createCcLinkParamsStore(ccLinkingOutputs,cppCompilationContext,forcePic)));
  }
  return new Info(providers,outputGroups,ccOutputs,ccLinkingOutputs,originalLinkingOutputs,cppCompilationContext);
}