|
@@ -1129,11 +1129,15 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
|
|
} else {
|
|
} else {
|
|
// Search for a module with the given name.
|
|
// Search for a module with the given name.
|
|
Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
|
|
Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
|
|
- std::string ModuleFileName;
|
|
|
|
- if (Module) {
|
|
|
|
- ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module);
|
|
|
|
- } else
|
|
|
|
- ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(ModuleName);
|
|
|
|
|
|
+ if (!Module) {
|
|
|
|
+ getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
|
|
|
|
+ << ModuleName
|
|
|
|
+ << SourceRange(ImportLoc, ModuleNameLoc);
|
|
|
|
+ ModuleBuildFailed = true;
|
|
|
|
+ return ModuleLoadResult();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ std::string ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module);
|
|
|
|
|
|
// If we don't already have an ASTReader, create one now.
|
|
// If we don't already have an ASTReader, create one now.
|
|
if (!ModuleManager) {
|
|
if (!ModuleManager) {
|
|
@@ -1180,17 +1184,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
|
|
case ASTReader::OutOfDate:
|
|
case ASTReader::OutOfDate:
|
|
case ASTReader::Missing: {
|
|
case ASTReader::Missing: {
|
|
// The module file is missing or out-of-date. Build it.
|
|
// The module file is missing or out-of-date. Build it.
|
|
-
|
|
|
|
- // If we don't have a module, we don't know how to build the module file.
|
|
|
|
- // Complain and return.
|
|
|
|
- if (!Module) {
|
|
|
|
- getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
|
|
|
|
- << ModuleName
|
|
|
|
- << SourceRange(ImportLoc, ModuleNameLoc);
|
|
|
|
- ModuleBuildFailed = true;
|
|
|
|
- return ModuleLoadResult();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ assert(Module && "missing module file");
|
|
// Check whether there is a cycle in the module graph.
|
|
// Check whether there is a cycle in the module graph.
|
|
ModuleBuildStack ModPath = getSourceManager().getModuleBuildStack();
|
|
ModuleBuildStack ModPath = getSourceManager().getModuleBuildStack();
|
|
ModuleBuildStack::iterator Pos = ModPath.begin(), PosEnd = ModPath.end();
|
|
ModuleBuildStack::iterator Pos = ModPath.begin(), PosEnd = ModPath.end();
|
|
@@ -1267,13 +1261,6 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
|
|
ModuleBuildFailed = true;
|
|
ModuleBuildFailed = true;
|
|
return ModuleLoadResult();
|
|
return ModuleLoadResult();
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (!Module) {
|
|
|
|
- // If we loaded the module directly, without finding a module map first,
|
|
|
|
- // we'll have loaded the module's information from the module itself.
|
|
|
|
- Module = PP->getHeaderSearchInfo().getModuleMap()
|
|
|
|
- .findModule((Path[0].first->getName()));
|
|
|
|
- }
|
|
|
|
|
|
|
|
// Cache the result of this top-level module lookup for later.
|
|
// Cache the result of this top-level module lookup for later.
|
|
Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
|
|
Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
|