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

john-brawn-arm via All-commits all-commits at lists.llvm.org
Mon Jul 24 05:14:56 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dfca88341794eec88c5009a93c569172fff62635
      https://github.com/llvm/llvm-project/commit/dfca88341794eec88c5009a93c569172fff62635
  Author: John Brawn <john.brawn at arm.com>
  Date:   2023-07-24 (Mon, 24 Jul 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