[cfe-commits] r145940 - in /cfe/trunk: lib/Frontend/FrontendActions.cpp test/Modules/auto-module-import.c
Douglas Gregor
dgregor at apple.com
Tue Dec 6 09:15:12 PST 2011
Author: dgregor
Date: Tue Dec 6 11:15:11 2011
New Revision: 145940
URL: http://llvm.org/viewvc/llvm-project?rev=145940&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/auto-module-import.c
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=145940&r1=145939&r2=145940&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Tue Dec 6 11:15:11 2011
@@ -129,32 +129,38 @@
/// 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 @@
// 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.
Modified: cfe/trunk/test/Modules/auto-module-import.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/auto-module-import.c?rev=145940&r1=145939&r2=145940&view=diff
==============================================================================
--- cfe/trunk/test/Modules/auto-module-import.c (original)
+++ cfe/trunk/test/Modules/auto-module-import.c Tue Dec 6 11:15:11 2011
@@ -17,3 +17,4 @@
#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
Module *mod2;
+int getDependsOther() { return depends_on_module_other; }
More information about the cfe-commits
mailing list