aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPDirectives.cpp18
-rw-r--r--lib/Lex/Preprocessor.cpp8
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 88d9429f00..140f793234 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1279,13 +1279,17 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
// If we are supposed to import a module rather than including the header,
// do so now.
if (SuggestedModule) {
- // FIXME: Actually load the submodule that we were given.
- while (SuggestedModule->Parent)
- SuggestedModule = SuggestedModule->Parent;
-
- TheModuleLoader.loadModule(IncludeTok.getLocation(),
- Identifiers.get(SuggestedModule->Name),
- FilenameTok.getLocation());
+ // Compute the module access path corresponding to this module.
+ // FIXME: Should we have a second loadModule() overload to avoid this
+ // extra lookup step?
+ llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path;
+ for (ModuleMap::Module *Mod = SuggestedModule; Mod; Mod = Mod->Parent)
+ Path.push_back(std::make_pair(getIdentifierInfo(Mod->Name),
+ FilenameTok.getLocation()));
+ std::reverse(Path.begin(), Path.end());
+
+ // Load the module.
+ TheModuleLoader.loadModule(IncludeTok.getLocation(), Path);
return;
}
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index 798244c3d2..aeba32f96a 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -575,9 +575,11 @@ void Preprocessor::LexAfterModuleImport(Token &Result) {
return;
// Load the module.
- (void)TheModuleLoader.loadModule(ModuleImportLoc,
- *Result.getIdentifierInfo(),
- Result.getLocation());
+ llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path;
+ Path.push_back(std::make_pair(Result.getIdentifierInfo(),
+ Result.getLocation()));
+
+ (void)TheModuleLoader.loadModule(ModuleImportLoc, Path);
}
void Preprocessor::AddCommentHandler(CommentHandler *Handler) {