diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2020-07-23 12:47:16 -0700 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2020-08-25 16:31:27 -0700 |
commit | 8839e278ffcadc62b333423de07756488cae980f (patch) | |
tree | cfdb775198f1343299604b8ea0486f9ad07cb0e5 /clang/lib/Lex/ModuleMap.cpp | |
parent | 1e13372bc808eb72ca4b96285b9ba9a987a39965 (diff) | |
download | llvm-8839e278ffcadc62b333423de07756488cae980f.zip llvm-8839e278ffcadc62b333423de07756488cae980f.tar.gz llvm-8839e278ffcadc62b333423de07756488cae980f.tar.bz2 |
[Modules] Improve error message when cannot find parent module for submodule definition.
Before the change the diagnostic for
module unknown.submodule {}
was "error: expected module name" which is incorrect and misleading
because both "unknown" and "submodule" are valid module names.
We already have a better error message when a parent module is a
submodule itself and is missing. Make the error for a missing top-level
module more like the one for a submodule.
rdar://problem/64424407
Reviewed By: bruno
Differential Revision: https://reviews.llvm.org/D84458
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index bcdc5b8..12da5a8 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1903,18 +1903,16 @@ void ModuleMapParser::parseModuleDecl() { continue; } - if (ActiveModule) { - Diags.Report(Id[I].second, diag::err_mmap_missing_module_qualified) - << Id[I].first - << ActiveModule->getTopLevelModule()->getFullModuleName(); - } else { - Diags.Report(Id[I].second, diag::err_mmap_expected_module_name); - } + Diags.Report(Id[I].second, diag::err_mmap_missing_parent_module) + << Id[I].first << (ActiveModule != nullptr) + << (ActiveModule + ? ActiveModule->getTopLevelModule()->getFullModuleName() + : ""); HadError = true; - return; } - if (ModuleMapFile != Map.getContainingModuleMapFile(TopLevelModule)) { + if (TopLevelModule && + ModuleMapFile != Map.getContainingModuleMapFile(TopLevelModule)) { assert(ModuleMapFile != Map.getModuleMapFileForUniquing(TopLevelModule) && "submodule defined in same file as 'module *' that allowed its " "top-level module"); |