[PATCH] D154503: [Sema] Fix handling of functions that hide classes

John Brawn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 05:30:58 PDT 2023


john.brawn created this revision.
john.brawn added reviewers: dexonsmith, rsmith, rjmccall.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When a function is declared in the same scope as a class with the same name then the function hides that class. Currently this is done by a single check after the main loop in LookupResult::resolveKind, but this can give the wrong result when we have a using declaration in multiple namespace scopes in two different ways:

- When the using declaration is hidden in one namespace but not the other we can end up considering only the hidden one when deciding if the result is ambiguous, causing an incorrect "not ambiguous" result.
- When two classes with the same name in different namespace scopes are both hidden by using declarations this can result in incorrectly deciding the result is ambiguous. There's currently a comment saying this is expected, but I don't think that's correct.

Solve this by having a separate loop before the main loop to eliminate classes that have been hidden by functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154503

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaCXX/using-hiding.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154503.537312.patch
Type: text/x-patch
Size: 6583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230705/8ad716ed/attachment-0001.bin>


More information about the cfe-commits mailing list