summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-10-23 02:01:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-10-23 02:01:19 +0000
commitfeb54b6ded123f8118fdc20620d3f657dfeab485 (patch)
tree2d5da6d7e7177e958d8bab12f2d7b6a6d4aa832b /clang/lib/Lex/ModuleMap.cpp
parent7db296eba537ace7bf9f19e3fc3a71457d90084d (diff)
downloadbcm5719-llvm-feb54b6ded123f8118fdc20620d3f657dfeab485.tar.gz
bcm5719-llvm-feb54b6ded123f8118fdc20620d3f657dfeab485.zip
Refactor implementation of 'exclude header'.
This was not a real header role, and was never exposed to clients of ModuleMap. Remove the enumeration value for it and track it as marking the header as 'known' rather than creating an extra KnownHeader entry that *every single* client ignores. llvm-svn: 220460
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r--clang/lib/Lex/ModuleMap.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 865b62a6a67..c191e0199a9 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -253,12 +253,6 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
HeadersMap::iterator Known = findKnownHeader(File);
if (Known != Headers.end()) {
for (const KnownHeader &Header : Known->second) {
- // Excluded headers don't really belong to a module.
- if (Header.getRole() == ModuleMap::ExcludedHeader) {
- Excluded = true;
- continue;
- }
-
// If 'File' is part of 'RequestingModule' we can definitely include it.
if (Header.getModule() == RequestingModule)
return;
@@ -281,6 +275,8 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
// We have found a module that we can happily use.
return;
}
+
+ Excluded = true;
}
// We have found a header, but it is private.
@@ -332,10 +328,6 @@ ModuleMap::findModuleForHeader(const FileEntry *File,
for (SmallVectorImpl<KnownHeader>::iterator I = Known->second.begin(),
E = Known->second.end();
I != E; ++I) {
- // Cannot use a module if the header is excluded in it.
- if (I->getRole() == ModuleMap::ExcludedHeader)
- continue;
-
// Cannot use a module if it is unavailable.
if (!I->getModule()->isAvailable())
continue;
@@ -791,9 +783,7 @@ void ModuleMap::setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir) {
void ModuleMap::addHeader(Module *Mod, const FileEntry *Header,
ModuleHeaderRole Role) {
- if (Role == ExcludedHeader) {
- Mod->ExcludedHeaders.push_back(Header);
- } else if (Role == TextualHeader) {
+ if (Role == TextualHeader) {
Mod->TextualHeaders.push_back(Header);
} else {
if (Role == PrivateHeader)
@@ -806,6 +796,16 @@ void ModuleMap::addHeader(Module *Mod, const FileEntry *Header,
Headers[Header].push_back(KnownHeader(Mod, Role));
}
+void ModuleMap::excludeHeader(Module *Mod, const FileEntry *Header) {
+ Mod->ExcludedHeaders.push_back(Header);
+
+ // Add this as a known header so we won't implicitly add it to any
+ // umbrella directory module.
+ // FIXME: Should we only exclude it from umbrella modules within the
+ // specified module?
+ (void) Headers[Header];
+}
+
const FileEntry *
ModuleMap::getContainingModuleMapFile(const Module *Module) const {
if (Module->DefinitionLoc.isInvalid())
@@ -1767,12 +1767,12 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
// Record this umbrella header.
Map.setUmbrellaHeader(ActiveModule, File);
}
+ } else if (LeadingToken == MMToken::ExcludeKeyword) {
+ Map.excludeHeader(ActiveModule, File);
} else {
// Record this header.
ModuleMap::ModuleHeaderRole Role = ModuleMap::NormalHeader;
- if (LeadingToken == MMToken::ExcludeKeyword)
- Role = ModuleMap::ExcludedHeader;
- else if (LeadingToken == MMToken::PrivateKeyword)
+ if (LeadingToken == MMToken::PrivateKeyword)
Role = ModuleMap::PrivateHeader;
else if (LeadingToken == MMToken::TextualKeyword)
Role = ModuleMap::TextualHeader;
OpenPOWER on IntegriCloud