[modules] When building a module, make sure we don't serialize out HeaderFileInfo for headers not belonging to the module.

After r180934 we may initiate module map parsing for modules not related to the module what we are building,
make sure we ignore the header file info of headers from such modules.

First part of rdar://13840148

llvm-svn: 181489
This commit is contained in:
Argyrios Kyrtzidis
2013-05-08 23:46:46 +00:00
parent 65c163529d
commit 6f722b4eb9
11 changed files with 45 additions and 7 deletions

View File

@@ -87,7 +87,7 @@ ModuleMap::ModuleMap(FileManager &FileMgr, DiagnosticConsumer &DC,
const LangOptions &LangOpts, const TargetInfo *Target,
HeaderSearch &HeaderInfo)
: LangOpts(LangOpts), Target(Target), HeaderInfo(HeaderInfo),
BuiltinIncludeDir(0)
BuiltinIncludeDir(0), CompilingModule(0)
{
IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(new DiagnosticIDs);
Diags = IntrusiveRefCntPtr<DiagnosticsEngine>(
@@ -388,8 +388,13 @@ ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
// Create a new module with this name.
Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework,
IsExplicit);
if (!Parent)
if (!Parent) {
Modules[Name] = Result;
if (!LangOpts.CurrentModule.empty() && !CompilingModule &&
Name == LangOpts.CurrentModule) {
CompilingModule = Result;
}
}
return std::make_pair(Result, true);
}
@@ -605,7 +610,8 @@ void ModuleMap::addHeader(Module *Mod, const FileEntry *Header,
Mod->ExcludedHeaders.push_back(Header);
} else {
Mod->Headers.push_back(Header);
HeaderInfo.MarkFileModuleHeader(Header);
bool isCompilingModuleHeader = Mod->getTopLevelModule() == CompilingModule;
HeaderInfo.MarkFileModuleHeader(Header, isCompilingModuleHeader);
}
Headers[Header] = KnownHeader(Mod, Excluded);
}