/// \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.
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);
.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 \"";
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,
// 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.