[PATCH] D121465: WIP: [clang][modules] Do not report declarations without linkage as ambiguous
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 11 07:54:56 PST 2022
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, vsapsai.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121465
Files:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/Modules/ambiguous-anonymous-enum-lookup.m.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121465.414658.patch
Type: text/x-patch
Size: 7120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220311/0eb40ce1/attachment.bin>
More information about the cfe-commits
mailing list