From 8839e278ffcadc62b333423de07756488cae980f Mon Sep 17 00:00:00 2001 From: Volodymyr Sapsai Date: Thu, 23 Jul 2020 12:47:16 -0700 Subject: [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 --- clang/lib/Lex/ModuleMap.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') 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"); -- cgit v1.1