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++ Modules TS or 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,10 @@ /// 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; } private: @@ -502,6 +511,13 @@ Parent->SubModules.push_back(this); } + /// Is this a module partition. + /// ??? : make a bit and stream it? + + bool isPartition() 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 @@ -1546,6 +1546,8 @@ return nullptr; case Module::ModuleInterfaceUnit: + case Module::ModulePartitionInterface: + case Module::ModulePartitionImplementation: return M; case Module::GlobalModuleFragment: { diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -167,6 +167,9 @@ } } + if (Kind == Module::ModulePartitionImplementation) + return false; + llvm_unreachable("could not find a reason why module is unavailable"); } 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 @@ -252,6 +252,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 @@ -2628,7 +2628,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