[all-commits] [llvm/llvm-project] 9e11a6: [Sema] Fix handling of functions that hide classes

john-brawn-arm via All-commits all-commits at lists.llvm.org
Fri Aug 18 04:40:40 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9e11a6d8fdd745f20bada10473b701d2e21492a5
      https://github.com/llvm/llvm-project/commit/9e11a6d8fdd745f20bada10473b701d2e21492a5
  Author: John Brawn <john.brawn at arm.com>
  Date:   2023-08-18 (Fri, 18 Aug 2023)

  Changed paths:
    M clang/lib/Sema/SemaLookup.cpp
    A clang/test/SemaCXX/using-hiding.cpp

  Log Message:
  -----------
  [Sema] Fix handling of functions that hide classes

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 checking each Decl to see if it's hidden by some other
Decl in the same scope. This means we have to delay removing anything
from Decls until after the main loop, in case a Decl is hidden by
another that is removed due to being non-unique.

Differential Revision: https://reviews.llvm.org/D154503




More information about the All-commits mailing list