[all-commits] [llvm/llvm-project] ce2257: [C++20] [Modules] Judge current module correctly

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Wed Apr 20 20:18:02 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ce2257d69fd02d0c34164ce3de9ab8dbe6991e0c
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2022-04-21 (Thu, 21 Apr 2022)

  Changed paths:
    M clang/include/clang/Basic/Module.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/SemaLookup.cpp
    A clang/test/CXX/module/module.import/p2.cpp
    M clang/test/Modules/cxx20-10-1-ex2.cpp

  Log Message:
  [C++20] [Modules] Judge current module correctly

Now the implementation would accept following code:
//--- impl.cppm
module M:impl;
class A {};

//--- M.cppm
export module M;
import :impl;

//--- Use.cpp
import M;
void test() {
    A a; // Expected error. A is not visible here.

which is clearly wrong.  The root cause is the implementation of
`isInCurrentModule` would return true if the module is a partition! So
in the above example, although Use.cpp is not a module unit,
`isInCurrentModule ` would still return true when the compiler tries to
see if the owning module of `A` is the current module. I believe this is
an oversight. This patch tries to fix this problem.

Reviewed By: iains

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

More information about the All-commits mailing list