When generating includes for all of the headers we found in an

umbrella directory, skip includes for any headers that are part of an
unavailable module.

llvm-svn: 147572
This commit is contained in:
Douglas Gregor 2012-01-05 00:04:05 +00:00
parent 7735a7d1a0
commit d2a8fe187d
3 changed files with 20 additions and 4 deletions

View File

@ -134,6 +134,8 @@ ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
/// \param Includes Will be augmented with the set of #includes or #imports
/// needed to load all of the named headers.
static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
FileManager &FileMgr,
ModuleMap &ModMap,
clang::Module *Module,
llvm::SmallString<256> &Includes) {
// Don't collect any headers for unavailable modules.
@ -161,7 +163,7 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
Includes += "\"\n";
}
} else if (const DirectoryEntry *UmbrellaDir = Module->getUmbrellaDir()) {
// Add all of the headers we find in this subdirectory (FIXME: recursively!).
// Add all of the headers we find in this subdirectory.
llvm::error_code EC;
llvm::SmallString<128> DirNative;
llvm::sys::path::native(UmbrellaDir->getName(), DirNative);
@ -175,6 +177,12 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
.Default(false))
continue;
// If this header is marked 'unavailable' in this module, don't include
// it.
if (const FileEntry *Header = FileMgr.getFile(Dir->path()))
if (ModMap.isHeaderInUnavailableModule(Header))
continue;
// Include this header umbrella header for submodules.
if (LangOpts.ObjC1)
Includes += "#import \"";
@ -189,7 +197,7 @@ static void collectModuleHeaderIncludes(const LangOptions &LangOpts,
for (clang::Module::submodule_iterator Sub = Module->submodule_begin(),
SubEnd = Module->submodule_end();
Sub != SubEnd; ++Sub)
collectModuleHeaderIncludes(LangOpts, *Sub, Includes);
collectModuleHeaderIncludes(LangOpts, FileMgr, ModMap, *Sub, Includes);
}
bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
@ -241,7 +249,9 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
// Collect the set of #includes we need to build the module.
llvm::SmallString<256> HeaderContents;
collectModuleHeaderIncludes(CI.getLangOpts(), Module, HeaderContents);
collectModuleHeaderIncludes(CI.getLangOpts(), CI.getFileManager(),
CI.getPreprocessor().getHeaderSearchInfo().getModuleMap(),
Module, HeaderContents);
if (UmbrellaHeader && HeaderContents.empty()) {
// Simple case: we have an umbrella header and there are no additional
// includes, we can just parse the umbrella header directly.

View File

@ -0,0 +1 @@
this is gibberish

View File

@ -1,4 +1,9 @@
framework module NoUmbrella {
umbrella "Headers"
module * { }
}
module unavailable {
requires unavailable
header "Boom.h"
}
}