[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 10 00:11:24 PST 2021


ChuanqiXu created this revision.
ChuanqiXu added reviewers: rsmith, aaron.ballman, erichkeane, urnathan, hubert.reinterpretcast.
ChuanqiXu added a project: clang.
Herald added a subscriber: dexonsmith.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

This fixes: https://bugs.llvm.org/show_bug.cgi?id=52281 and https://godbolt.org/z/81f3ocjfW.

This patch introduces a new kind of `ModuleOwnershipKind` as `ReachableWhenImported`. This intended the status for reachable described at: https://eel.is/c++draft/module.reach#3.

Note that this patch is not intended to support all semantics about reachable semantics.

An important feature not included in this patch is discarding declaration in global module fragment. See https://eel.is/c++draft/module.global.frag#3 and https://eel.is/c++draft/module.global.frag#4. This feature is important since it would cut off many unused declarations so that user could import a large module without worrying it would be too heavy. And I think this is related to the bug https://bugs.llvm.org/show_bug.cgi?id=52342 mentioned @rsmith .

But after all, I think it is not easy to implement in one shot. So this patch didn't contain that feature. In other words, now all the declarations in the global module fragment are reachable even they could be reduced. But this is not worse than the current situation. So I think it may not be unacceptable.

Test Plan: check-all and https://godbolt.org/z/81f3ocjfW.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113545

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/Module.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/module/module.reach/Inputs/p5-A.cppm
  clang/test/CXX/module/module.reach/p5.cpp
  clang/test/Modules/Inputs/Reachability-Private/Private.cppm
  clang/test/Modules/Inputs/Reachability-func-default-arg/func_default_arg.cppm
  clang/test/Modules/Inputs/Reachability-func-ret/func_ret.cppm
  clang/test/Modules/Inputs/Reachability-template-default-arg/template_default_arg.cppm
  clang/test/Modules/Inputs/Reachability-using-templates/mod-templates.cppm
  clang/test/Modules/Inputs/Reachability-using/mod.cppm
  clang/test/Modules/Reachability-Private.cpp
  clang/test/Modules/Reachability-func-default-arg.cpp
  clang/test/Modules/Reachability-func-ret.cpp
  clang/test/Modules/Reachability-template-default-arg.cpp
  clang/test/Modules/Reachability-using-templates.cpp
  clang/test/Modules/Reachability-using.cpp
  clang/test/SemaCXX/compare-modules-cxx2a.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113545.386071.patch
Type: text/x-patch
Size: 32049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211110/fc13eb72/attachment-0001.bin>


More information about the cfe-commits mailing list