diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -106,9 +106,15 @@ /// of header files. ModuleMapModule, - /// This is a C++ Modules TS module interface unit. + /// This is a C++20 module interface unit. ModuleInterfaceUnit, + /// This is a C++ 20 module partition interface. + ModulePartitionInterface, + + /// This is a C++ 20 module partition implementation. + ModulePartitionImplementation, + /// This is a fragment of the global module within some C++ module. GlobalModuleFragment, @@ -150,7 +156,9 @@ /// Does this Module scope describe part of the purview of a named C++ module? bool isModulePurview() const { - return Kind == ModuleInterfaceUnit || Kind == PrivateModuleFragment; + return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface || + Kind == ModulePartitionImplementation || + Kind == PrivateModuleFragment; } /// Does this Module scope describe a fragment of the global module within @@ -506,6 +514,9 @@ Parent->SubModules.push_back(this); } + /// Is this a module partition. + bool isModulePartition() const { return Name.find(':') != std::string::npos; } + /// Retrieve the full name of this module, including the path from /// its top-level module. /// \param AllowStringLiterals If \c true, components that might not be diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1550,6 +1550,8 @@ return nullptr; case Module::ModuleInterfaceUnit: + case Module::ModulePartitionInterface: + case Module::ModulePartitionImplementation: return M; case Module::GlobalModuleFragment: { diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -261,6 +261,8 @@ : ModuleScopes.back().Module->Kind) { case Module::ModuleMapModule: case Module::GlobalModuleFragment: + case Module::ModulePartitionImplementation: + case Module::ModulePartitionInterface: Diag(PrivateLoc, diag::err_private_module_fragment_not_module); return nullptr; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2674,7 +2674,7 @@ Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent - Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Kind + Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Kind Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem