forked from OSchip/llvm-project
Record whether a module came from a private module map
Right now we only use this information in one place, immediately after we calculate it, but it's still nice information to have. The Swift project is going to use this to tidy up its "API notes" feature (see past discussion on cfe-dev that never quite converged). Reviewed by Bruno Cardoso Lopes. llvm-svn: 330452
This commit is contained in:
parent
42b2a0e162
commit
90b0a1fc58
|
@ -258,6 +258,10 @@ public:
|
|||
/// and headers from used modules.
|
||||
unsigned NoUndeclaredIncludes : 1;
|
||||
|
||||
/// \brief Whether this module came from a "private" module map, found next
|
||||
/// to a regular (public) module map.
|
||||
unsigned ModuleMapIsPrivate : 1;
|
||||
|
||||
/// \brief Describes the visibility of the various names within a
|
||||
/// particular module.
|
||||
enum NameVisibilityKind {
|
||||
|
|
|
@ -44,7 +44,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
|
|||
IsSystem(false), IsExternC(false), IsInferred(false),
|
||||
InferSubmodules(false), InferExplicitSubmodules(false),
|
||||
InferExportWildcard(false), ConfigMacrosExhaustive(false),
|
||||
NoUndeclaredIncludes(false), NameVisibility(Hidden) {
|
||||
NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
|
||||
NameVisibility(Hidden) {
|
||||
if (Parent) {
|
||||
if (!Parent->isAvailable())
|
||||
IsAvailable = false;
|
||||
|
@ -54,6 +55,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
|
|||
IsExternC = true;
|
||||
if (Parent->NoUndeclaredIncludes)
|
||||
NoUndeclaredIncludes = true;
|
||||
if (Parent->ModuleMapIsPrivate)
|
||||
ModuleMapIsPrivate = true;
|
||||
IsMissingRequirement = Parent->IsMissingRequirement;
|
||||
|
||||
Parent->SubModuleIndex[Name] = Parent->SubModules.size();
|
||||
|
|
|
@ -1891,20 +1891,23 @@ void ModuleMapParser::parseModuleDecl() {
|
|||
ActiveModule->NoUndeclaredIncludes = true;
|
||||
ActiveModule->Directory = Directory;
|
||||
|
||||
StringRef MapFileName(ModuleMapFile->getName());
|
||||
if (MapFileName.endswith("module.private.modulemap") ||
|
||||
MapFileName.endswith("module_private.map")) {
|
||||
ActiveModule->ModuleMapIsPrivate = true;
|
||||
}
|
||||
|
||||
// Private modules named as FooPrivate, Foo.Private or similar are likely a
|
||||
// user error; provide warnings, notes and fixits to direct users to use
|
||||
// Foo_Private instead.
|
||||
SourceLocation StartLoc =
|
||||
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
|
||||
StringRef MapFileName(ModuleMapFile->getName());
|
||||
if (Map.HeaderInfo.getHeaderSearchOpts().ImplicitModuleMaps &&
|
||||
!Diags.isIgnored(diag::warn_mmap_mismatched_private_submodule,
|
||||
StartLoc) &&
|
||||
!Diags.isIgnored(diag::warn_mmap_mismatched_private_module_name,
|
||||
StartLoc) &&
|
||||
(MapFileName.endswith("module.private.modulemap") ||
|
||||
MapFileName.endswith("module_private.map")))
|
||||
ActiveModule->ModuleMapIsPrivate)
|
||||
diagnosePrivateModules(Map, Diags, ActiveModule, LastInlineParentLoc);
|
||||
|
||||
bool Done = false;
|
||||
|
|
|
@ -4980,7 +4980,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
|||
break;
|
||||
|
||||
case SUBMODULE_DEFINITION: {
|
||||
if (Record.size() < 8) {
|
||||
if (Record.size() < 12) {
|
||||
Error("malformed module definition");
|
||||
return Failure;
|
||||
}
|
||||
|
@ -4998,6 +4998,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
|||
bool InferExplicitSubmodules = Record[Idx++];
|
||||
bool InferExportWildcard = Record[Idx++];
|
||||
bool ConfigMacrosExhaustive = Record[Idx++];
|
||||
bool ModuleMapIsPrivate = Record[Idx++];
|
||||
|
||||
Module *ParentModule = nullptr;
|
||||
if (Parent)
|
||||
|
@ -5045,6 +5046,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
|||
CurrentModule->InferExplicitSubmodules = InferExplicitSubmodules;
|
||||
CurrentModule->InferExportWildcard = InferExportWildcard;
|
||||
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
|
||||
CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
|
||||
if (DeserializationListener)
|
||||
DeserializationListener->ModuleRead(GlobalID, CurrentModule);
|
||||
|
||||
|
|
|
@ -2809,6 +2809,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
|
|||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferExplicit...
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferExportWild...
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ConfigMacrosExh...
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModuleMapIsPriv...
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
|
||||
unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
|
||||
|
||||
|
@ -2913,7 +2914,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
|
|||
Mod->InferSubmodules,
|
||||
Mod->InferExplicitSubmodules,
|
||||
Mod->InferExportWildcard,
|
||||
Mod->ConfigMacrosExhaustive};
|
||||
Mod->ConfigMacrosExhaustive,
|
||||
Mod->ModuleMapIsPrivate};
|
||||
Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue