When finalizing the result of name lookup that encountered ambiguity, we check equivalence for declarations with internal linkage. If the declarations are equivalent, we just produce a warning instead of ambiguous result.
In Sema::isEquivalentInternalLinkageDeclaration that implements the check, we have a special case for constants of anonymous enums. However, it only kicks in for C++ anonymous enums (since they have NoLinkage, meaning they are not externally visible).
In (Objective)C, constants of anonymous enums are VisibleNoLinkage, meaning they _are_ externally visible, so the special case doesn't apply for them.
This patch renames the function to isEquivalentNonExternalLinkageDeclaration (its documentation already says it handles declarations with "internal/no linkage") and makes it so that even VisibleNoLinkage declarations are not marked as ambiguous. This is achieved by using hasExternalFormalLinkage instead of isExternallyVisible in one of the equivalence checks. Later on, we don't even emit the warning for such declarations, since they are considered the same entity.
For enums it is nice to test having a constant that references another constant in the same enum. E.g., kAnonymousEnumAnotherValue = kAnonymousEnumValue + 1.