diff options
| author | Ben Langmuir <blangmuir@apple.com> | 2014-01-22 23:19:39 +0000 | 
|---|---|---|
| committer | Ben Langmuir <blangmuir@apple.com> | 2014-01-22 23:19:39 +0000 | 
| commit | 9eb229bfe545a3b8484f15e42dfe567d6f3c0fcc (patch) | |
| tree | c3e6a40328a353f1248d744d7bfeaff720288bd9 /clang/lib/Frontend/CompilerInstance.cpp | |
| parent | 39536724a7332857a1b8ba8afd9da6a252e9f4e8 (diff) | |
| download | llvm-9eb229bfe545a3b8484f15e42dfe567d6f3c0fcc.zip llvm-9eb229bfe545a3b8484f15e42dfe567d6f3c0fcc.tar.gz llvm-9eb229bfe545a3b8484f15e42dfe567d6f3c0fcc.tar.bz2  | |
Require a module.map file to load a module
Removes some old code that allowed a module to be loaded from a pcm file
even if the module.map could not be found.  Also update a number of
tests that relied on the old behavior.
llvm-svn: 199852
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
| -rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 33 | 
1 files changed, 10 insertions, 23 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index e311465..0d2af33 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1129,11 +1129,15 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,    } else {      // Search for a module with the given name.      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 (!ModuleManager) { @@ -1180,17 +1184,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,      case ASTReader::OutOfDate:      case ASTReader::Missing: {        // 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.        ModuleBuildStack ModPath = getSourceManager().getModuleBuildStack();        ModuleBuildStack::iterator Pos = ModPath.begin(), PosEnd = ModPath.end(); @@ -1267,13 +1261,6 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,        ModuleBuildFailed = true;        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.      Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;  | 
