Program: 52937
Project: 52937
Buggy source:
private <A extends AppleNativeTargetDescriptionArg>BuildRule requireSingleArchUnstrippedBuildRule(BuildRuleParams params,BuildRuleResolver resolver,CellPathResolver cellRoots,TargetGraph targetGraph,A args,Optional<Linker.LinkableDepType> linkableDepType,Optional<SourcePath> bundleLoader,ImmutableSet<BuildTarget> blacklist,SourcePathResolver pathResolver,ImmutableSortedSet<BuildTarget> extraCxxDeps) throws NoSuchBuildTargetException {
  CxxLibraryDescriptionArg.Builder delegateArg=CxxLibraryDescriptionArg.builder().from(args);
  AppleDescriptions.populateCxxLibraryDescriptionArg(pathResolver,delegateArg,args,params.getBuildTarget());
  Optional<BuildRule> swiftCompanionBuildRule=swiftDelegate.createCompanionBuildRule(targetGraph,params,resolver,cellRoots,args);
  if (swiftCompanionBuildRule.isPresent()) {
    if (isSwiftTarget(params.getBuildTarget())) {
      return swiftCompanionBuildRule.get();
    }
 else {
      delegateArg.addExportedDeps(swiftCompanionBuildRule.get().getBuildTarget());
      params=params.copyAppendingExtraDeps(ImmutableSet.of(swiftCompanionBuildRule.get()));
    }
  }
  BuildTarget unstrippedTarget=params.getBuildTarget().withoutFlavors(AppleDebugFormat.FLAVOR_DOMAIN.getFlavors());
  if (AppleDescriptions.flavorsDoNotAllowLinkerMapMode(params)) {
    unstrippedTarget=unstrippedTarget.withoutFlavors(LinkerMapMode.NO_LINKER_MAP.getFlavor());
  }
  Optional<BuildRule> existingRule=resolver.getRuleOptional(unstrippedTarget);
  if (existingRule.isPresent()) {
    return existingRule.get();
  }
 else {
    BuildRule rule=delegate.createBuildRule(params.withBuildTarget(unstrippedTarget),resolver,cellRoots,delegateArg.build(),linkableDepType,bundleLoader,blacklist,extraCxxDeps);
    return resolver.addToIndex(rule);
  }
}

Fixed version (ground truth):
private <A extends AppleNativeTargetDescriptionArg>BuildRule requireSingleArchUnstrippedBuildRule(BuildRuleParams params,BuildRuleResolver resolver,CellPathResolver cellRoots,TargetGraph targetGraph,A args,Optional<Linker.LinkableDepType> linkableDepType,Optional<SourcePath> bundleLoader,ImmutableSet<BuildTarget> blacklist,SourcePathResolver pathResolver,ImmutableSortedSet<BuildTarget> extraCxxDeps,CxxLibraryDescription.TransitiveCxxPreprocessorInputFunction transitiveCxxDeps) throws NoSuchBuildTargetException {
  CxxLibraryDescriptionArg.Builder delegateArg=CxxLibraryDescriptionArg.builder().from(args);
  AppleDescriptions.populateCxxLibraryDescriptionArg(pathResolver,delegateArg,args,params.getBuildTarget());
  Optional<BuildRule> swiftCompanionBuildRule=swiftDelegate.createCompanionBuildRule(targetGraph,params,resolver,cellRoots,args);
  if (swiftCompanionBuildRule.isPresent()) {
    if (isSwiftTarget(params.getBuildTarget())) {
      return swiftCompanionBuildRule.get();
    }
 else {
      delegateArg.addExportedDeps(swiftCompanionBuildRule.get().getBuildTarget());
      params=params.copyAppendingExtraDeps(ImmutableSet.of(swiftCompanionBuildRule.get()));
    }
  }
  BuildTarget unstrippedTarget=params.getBuildTarget().withoutFlavors(AppleDebugFormat.FLAVOR_DOMAIN.getFlavors());
  if (AppleDescriptions.flavorsDoNotAllowLinkerMapMode(params)) {
    unstrippedTarget=unstrippedTarget.withoutFlavors(LinkerMapMode.NO_LINKER_MAP.getFlavor());
  }
  Optional<BuildRule> existingRule=resolver.getRuleOptional(unstrippedTarget);
  if (existingRule.isPresent()) {
    return existingRule.get();
  }
 else {
    BuildRule rule=delegate.createBuildRule(params.withBuildTarget(unstrippedTarget),resolver,cellRoots,delegateArg.build(),linkableDepType,bundleLoader,blacklist,extraCxxDeps,transitiveCxxDeps);
    return resolver.addToIndex(rule);
  }
}