summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-01-29 17:08:11 +0000
committerDouglas Gregor <dgregor@apple.com>2012-01-29 17:08:11 +0000
commit279a6c3747b10c33f8f425cf4a24e64db015d3e9 (patch)
tree1bd2e50168448e6deff7d3299f6c86a52c26e8cf /clang/lib/Frontend/CompilerInstance.cpp
parentdd7cae51d8e050162c351a57df1a0d60d68c3ec9 (diff)
downloadbcm5719-llvm-279a6c3747b10c33f8f425cf4a24e64db015d3e9.tar.gz
bcm5719-llvm-279a6c3747b10c33f8f425cf4a24e64db015d3e9.zip
Rework HeaderSearch's interface for getting a module from a name and
for getting the name of the module file, unifying the code for searching for a module with a given name (into lookupModule()) and separating out the mapping to a module file (into getModuleFileName()). No functionality change. llvm-svn: 149197
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index b8075ed87a3..7f22247e57f 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1116,11 +1116,25 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc,
Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;
} else {
// Search for a module with the given name.
+ Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
std::string ModuleFileName;
- ModuleFile
- = PP->getHeaderSearchInfo().lookupModule(ModuleName, Module,
- &ModuleFileName);
-
+ if (Module)
+ ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(Module);
+ else
+ ModuleFileName = PP->getHeaderSearchInfo().getModuleFileName(ModuleName);
+
+ if (ModuleFileName.empty()) {
+ getDiagnostics().Report(ModuleNameLoc, diag::err_module_not_found)
+ << ModuleName
+ << SourceRange(ImportLoc, ModuleNameLoc);
+ LastModuleImportLoc = ImportLoc;
+ LastModuleImportResult = 0;
+ return 0;
+ }
+
+ const FileEntry *ModuleFile
+ = getFileManager().getFile(ModuleFileName, /*OpenFile=*/false,
+ /*CacheFailure=*/false);
bool BuildingModule = false;
if (!ModuleFile && Module) {
// The module is not cached, but we have a module map from which we can
OpenPOWER on IntegriCloud