diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-05 00:04:05 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-05 00:04:05 +0000 |
commit | 752769f080e217747f7756d3db2b4ee405bf3767 (patch) | |
tree | 66d27d9b76ea1084da1fb4e75772068ca7ae295d /lib/Frontend/FrontendActions.cpp | |
parent | 273c3a3a3f009e26349ad9dfe67eaaa12db43af4 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/FrontendActions.cpp')
-rw-r--r-- | lib/Frontend/FrontendActions.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index d9a385d232..2261b30712 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -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. |