forked from OSchip/llvm-project
[C++20][Modules][2/8] Add enumerations for partition modules and stream them.
This is an initial enabling patch for module partition support. We add enumerations for partition interfaces/implementations. This means that the module kind enumeration now occupies three bits, so the AST streamer is adjusted for this. Adding one bit there seems preferable to trying to overload the meanings of existing kinds (and we will also want to add a C++20 header unit case later). Differential Revision: https://reviews.llvm.org/D114714
This commit is contained in:
parent
d6a9eec238
commit
c9cc8035eb
|
@ -106,9 +106,15 @@ public:
|
||||||
/// of header files.
|
/// of header files.
|
||||||
ModuleMapModule,
|
ModuleMapModule,
|
||||||
|
|
||||||
/// This is a C++ Modules TS module interface unit.
|
/// This is a C++20 module interface unit.
|
||||||
ModuleInterfaceUnit,
|
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.
|
/// This is a fragment of the global module within some C++ module.
|
||||||
GlobalModuleFragment,
|
GlobalModuleFragment,
|
||||||
|
|
||||||
|
@ -150,7 +156,9 @@ public:
|
||||||
|
|
||||||
/// Does this Module scope describe part of the purview of a named C++ module?
|
/// Does this Module scope describe part of the purview of a named C++ module?
|
||||||
bool isModulePurview() const {
|
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
|
/// Does this Module scope describe a fragment of the global module within
|
||||||
|
@ -506,6 +514,9 @@ public:
|
||||||
Parent->SubModules.push_back(this);
|
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
|
/// Retrieve the full name of this module, including the path from
|
||||||
/// its top-level module.
|
/// its top-level module.
|
||||||
/// \param AllowStringLiterals If \c true, components that might not be
|
/// \param AllowStringLiterals If \c true, components that might not be
|
||||||
|
|
|
@ -1550,6 +1550,8 @@ Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
case Module::ModuleInterfaceUnit:
|
case Module::ModuleInterfaceUnit:
|
||||||
|
case Module::ModulePartitionInterface:
|
||||||
|
case Module::ModulePartitionImplementation:
|
||||||
return M;
|
return M;
|
||||||
|
|
||||||
case Module::GlobalModuleFragment: {
|
case Module::GlobalModuleFragment: {
|
||||||
|
|
|
@ -261,6 +261,8 @@ Sema::ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc,
|
||||||
: ModuleScopes.back().Module->Kind) {
|
: ModuleScopes.back().Module->Kind) {
|
||||||
case Module::ModuleMapModule:
|
case Module::ModuleMapModule:
|
||||||
case Module::GlobalModuleFragment:
|
case Module::GlobalModuleFragment:
|
||||||
|
case Module::ModulePartitionImplementation:
|
||||||
|
case Module::ModulePartitionInterface:
|
||||||
Diag(PrivateLoc, diag::err_private_module_fragment_not_module);
|
Diag(PrivateLoc, diag::err_private_module_fragment_not_module);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -2674,7 +2674,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
|
||||||
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
|
Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
|
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)); // IsFramework
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem
|
||||||
|
|
Loading…
Reference in New Issue