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
clang
include/clang/Basic
lib
|
@ -258,6 +258,10 @@ public:
|
||||||
/// and headers from used modules.
|
/// and headers from used modules.
|
||||||
unsigned NoUndeclaredIncludes : 1;
|
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
|
/// \brief Describes the visibility of the various names within a
|
||||||
/// particular module.
|
/// particular module.
|
||||||
enum NameVisibilityKind {
|
enum NameVisibilityKind {
|
||||||
|
|
|
@ -44,7 +44,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
|
||||||
IsSystem(false), IsExternC(false), IsInferred(false),
|
IsSystem(false), IsExternC(false), IsInferred(false),
|
||||||
InferSubmodules(false), InferExplicitSubmodules(false),
|
InferSubmodules(false), InferExplicitSubmodules(false),
|
||||||
InferExportWildcard(false), ConfigMacrosExhaustive(false),
|
InferExportWildcard(false), ConfigMacrosExhaustive(false),
|
||||||
NoUndeclaredIncludes(false), NameVisibility(Hidden) {
|
NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
|
||||||
|
NameVisibility(Hidden) {
|
||||||
if (Parent) {
|
if (Parent) {
|
||||||
if (!Parent->isAvailable())
|
if (!Parent->isAvailable())
|
||||||
IsAvailable = false;
|
IsAvailable = false;
|
||||||
|
@ -54,6 +55,8 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
|
||||||
IsExternC = true;
|
IsExternC = true;
|
||||||
if (Parent->NoUndeclaredIncludes)
|
if (Parent->NoUndeclaredIncludes)
|
||||||
NoUndeclaredIncludes = true;
|
NoUndeclaredIncludes = true;
|
||||||
|
if (Parent->ModuleMapIsPrivate)
|
||||||
|
ModuleMapIsPrivate = true;
|
||||||
IsMissingRequirement = Parent->IsMissingRequirement;
|
IsMissingRequirement = Parent->IsMissingRequirement;
|
||||||
|
|
||||||
Parent->SubModuleIndex[Name] = Parent->SubModules.size();
|
Parent->SubModuleIndex[Name] = Parent->SubModules.size();
|
||||||
|
|
|
@ -1891,20 +1891,23 @@ void ModuleMapParser::parseModuleDecl() {
|
||||||
ActiveModule->NoUndeclaredIncludes = true;
|
ActiveModule->NoUndeclaredIncludes = true;
|
||||||
ActiveModule->Directory = Directory;
|
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
|
// Private modules named as FooPrivate, Foo.Private or similar are likely a
|
||||||
// user error; provide warnings, notes and fixits to direct users to use
|
// user error; provide warnings, notes and fixits to direct users to use
|
||||||
// Foo_Private instead.
|
// Foo_Private instead.
|
||||||
SourceLocation StartLoc =
|
SourceLocation StartLoc =
|
||||||
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
|
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
|
||||||
StringRef MapFileName(ModuleMapFile->getName());
|
|
||||||
if (Map.HeaderInfo.getHeaderSearchOpts().ImplicitModuleMaps &&
|
if (Map.HeaderInfo.getHeaderSearchOpts().ImplicitModuleMaps &&
|
||||||
!Diags.isIgnored(diag::warn_mmap_mismatched_private_submodule,
|
!Diags.isIgnored(diag::warn_mmap_mismatched_private_submodule,
|
||||||
StartLoc) &&
|
StartLoc) &&
|
||||||
!Diags.isIgnored(diag::warn_mmap_mismatched_private_module_name,
|
!Diags.isIgnored(diag::warn_mmap_mismatched_private_module_name,
|
||||||
StartLoc) &&
|
StartLoc) &&
|
||||||
(MapFileName.endswith("module.private.modulemap") ||
|
ActiveModule->ModuleMapIsPrivate)
|
||||||
MapFileName.endswith("module_private.map")))
|
|
||||||
diagnosePrivateModules(Map, Diags, ActiveModule, LastInlineParentLoc);
|
diagnosePrivateModules(Map, Diags, ActiveModule, LastInlineParentLoc);
|
||||||
|
|
||||||
bool Done = false;
|
bool Done = false;
|
||||||
|
|
|
@ -4980,7 +4980,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SUBMODULE_DEFINITION: {
|
case SUBMODULE_DEFINITION: {
|
||||||
if (Record.size() < 8) {
|
if (Record.size() < 12) {
|
||||||
Error("malformed module definition");
|
Error("malformed module definition");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
@ -4998,6 +4998,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
||||||
bool InferExplicitSubmodules = Record[Idx++];
|
bool InferExplicitSubmodules = Record[Idx++];
|
||||||
bool InferExportWildcard = Record[Idx++];
|
bool InferExportWildcard = Record[Idx++];
|
||||||
bool ConfigMacrosExhaustive = Record[Idx++];
|
bool ConfigMacrosExhaustive = Record[Idx++];
|
||||||
|
bool ModuleMapIsPrivate = Record[Idx++];
|
||||||
|
|
||||||
Module *ParentModule = nullptr;
|
Module *ParentModule = nullptr;
|
||||||
if (Parent)
|
if (Parent)
|
||||||
|
@ -5045,6 +5046,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
|
||||||
CurrentModule->InferExplicitSubmodules = InferExplicitSubmodules;
|
CurrentModule->InferExplicitSubmodules = InferExplicitSubmodules;
|
||||||
CurrentModule->InferExportWildcard = InferExportWildcard;
|
CurrentModule->InferExportWildcard = InferExportWildcard;
|
||||||
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
|
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
|
||||||
|
CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
|
||||||
if (DeserializationListener)
|
if (DeserializationListener)
|
||||||
DeserializationListener->ModuleRead(GlobalID, CurrentModule);
|
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)); // InferExplicit...
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferExportWild...
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // InferExportWild...
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ConfigMacrosExh...
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ConfigMacrosExh...
|
||||||
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ModuleMapIsPriv...
|
||||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
|
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
|
||||||
unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
|
unsigned DefinitionAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
|
||||||
|
|
||||||
|
@ -2913,7 +2914,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
|
||||||
Mod->InferSubmodules,
|
Mod->InferSubmodules,
|
||||||
Mod->InferExplicitSubmodules,
|
Mod->InferExplicitSubmodules,
|
||||||
Mod->InferExportWildcard,
|
Mod->InferExportWildcard,
|
||||||
Mod->ConfigMacrosExhaustive};
|
Mod->ConfigMacrosExhaustive,
|
||||||
|
Mod->ModuleMapIsPrivate};
|
||||||
Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
|
Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue