[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 14 00:32:14 PDT 2023


iains created this revision.
Herald added a subscriber: ChuanqiXu.
Herald added a project: All.
iains added a reviewer: ChuanqiXu.
iains added a comment.
iains published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

notes:
a) I need to update the commit log message so that it formats properly in the browser
b) since we are now seeing performance complaints against modules, and some of these routines are used many times (sometimes several time per name), I have tried to structure tests so that the cheapest ones execute first - and likewise the utility routines.


Some of the testcases committed during the merging of modules contain
FIXMEs concerning the visibility of declarations with internal-linkage in
module interface units as seen from module implementation units.

This is, in part, caused by an oversight in the utility routine that determines
whether a module is part of the current TU or not.

The lookup definition for `visible` was also too wide, failing to account
cases where a module was visible, but some declarations from it were not.

This patch has three components:
 1/ Fixing the behaviour of the `isModuleUnitOfCurrentTU` utility function to

  return the correct result for module implementation units.

2/ Checking for visibility of imported decls and excluding thsose with

  internal linkage (when from a different TU) or from a private module
  fragment.

3/ Updating the diagnostics in reponse to 1 and 2, in particular dealing

  better with the case that the user attempts to use a module-local linkage
  item in an importing TU (we now provide a fixit to indicate that the item
  needs to be exported to be used). When we search for possible "typos",
  which we do in response to failing to find an entity, we do so allowing
  finds of 'hidden' names.  Before we offer names found this as possible
  typo fixes, we need to check that they would be viable if not hidden.

There are a number of basically mechanical changes to tests to accommodate
the fixed rejection of relevant declarations and the improved diagnostic
messages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145965

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/module/basic/basic.def.odr/p4.cppm
  clang/test/CXX/module/basic/basic.link/p2.cppm
  clang/test/CXX/module/module.import/p2.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/module/module.interface/p7.cpp
  clang/test/CXX/module/module.reach/ex1.cpp
  clang/test/CXX/module/module.reach/p2.cpp
  clang/test/CXX/module/module.reach/p5.cpp
  clang/test/Modules/Reachability-template-default-arg.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp
  clang/test/Modules/deduction-guide3.cppm
  clang/test/Modules/diagnose-missing-import.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145965.504748.patch
Type: text/x-patch
Size: 30332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230314/9f52eb61/attachment-0001.bin>


More information about the cfe-commits mailing list