summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-06 17:15:11 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-06 17:15:11 +0000
commite5626c4119b0e0a7902b2648a5696cc9595ed25f (patch)
tree811ef31249326472aa64b8730f64339b2ac6707c /clang/lib/Frontend/FrontendActions.cpp
parente946e361abc914243327f2af0925d6f63bcae384 (diff)
downloadbcm5719-llvm-e5626c4119b0e0a7902b2648a5696cc9595ed25f.tar.gz
bcm5719-llvm-e5626c4119b0e0a7902b2648a5696cc9595ed25f.zip
When building the main file to parse given a module map, don't skip
explicit submodules or umbrella headers from submodules. Instead, build the entire module at once, and let the name-hiding mechanisms hide the contents of explicit submodules at load time. llvm-svn: 145940
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 5c4e447ef5f..1a2df01bdfd 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -129,32 +129,38 @@ ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
/// module.
///
/// \param Module The module we're collecting includes from.
-/// \param ExplicitOnly Whether we should only add headers from explicit
+///
+/// \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,
clang::Module *Module,
- bool ExplicitOnly,
llvm::SmallString<256> &Includes) {
- if (!ExplicitOnly || Module->IsExplicit) {
- // Add includes for each of these headers.
- for (unsigned I = 0, N = Module->Headers.size(); I != N; ++I) {
- if (LangOpts.ObjC1)
- Includes += "#import \"";
- else
- Includes += "#include \"";
- Includes += Module->Headers[I]->getName();
- Includes += "\"\n";
- }
+ // Add includes for each of these headers.
+ for (unsigned I = 0, N = Module->Headers.size(); I != N; ++I) {
+ if (LangOpts.ObjC1)
+ Includes += "#import \"";
+ else
+ Includes += "#include \"";
+ Includes += Module->Headers[I]->getName();
+ Includes += "\"\n";
+ }
+
+ if (Module->UmbrellaHeader && Module->Parent) {
+ // Include the umbrella header for submodules.
+ if (LangOpts.ObjC1)
+ Includes += "#import \"";
+ else
+ Includes += "#include \"";
+ Includes += Module->UmbrellaHeader->getName();
+ Includes += "\"\n";
}
// Recurse into submodules.
for (llvm::StringMap<clang::Module *>::iterator
Sub = Module->SubModules.begin(),
SubEnd = Module->SubModules.end();
- Sub != SubEnd; ++Sub) {
- collectModuleHeaderIncludes(LangOpts, Sub->getValue(),
- ExplicitOnly && !Module->IsExplicit,
- Includes);
- }
+ Sub != SubEnd; ++Sub)
+ collectModuleHeaderIncludes(LangOpts, Sub->getValue(), Includes);
}
bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
@@ -193,8 +199,7 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,
// Collect the set of #includes we need to build the module.
llvm::SmallString<256> HeaderContents;
- collectModuleHeaderIncludes(CI.getLangOpts(), Module,
- Module->UmbrellaHeader != 0, HeaderContents);
+ collectModuleHeaderIncludes(CI.getLangOpts(), Module, HeaderContents);
if (Module->UmbrellaHeader && HeaderContents.empty()) {
// Simple case: we have an umbrella header and there are no additional
// includes, we can just parse the umbrella header directly.
OpenPOWER on IntegriCloud