This is an archive of the discontinued LLVM Phabricator instance.

[Modules] Improve error message when cannot find parent module for submodule definition.
ClosedPublic

Authored by vsapsai on Jul 23 2020, 12:52 PM.

Details

Summary

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

Diff Detail

Event Timeline

vsapsai created this revision.Jul 23 2020, 12:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 12:52 PM
vsapsai marked 3 inline comments as done.Jul 23 2020, 12:57 PM
vsapsai added inline comments.
clang/include/clang/Basic/DiagnosticLexKinds.td
700

Not sure about this second part of the message ("expected..."). Wanted to make it more actionable but not entirely happy with the wording. Any suggestions including removal are welcome.

clang/lib/Lex/ModuleMap.cpp
1911

Both of err_mmap_missing_module_qualified and err_mmap_expected_module_name are still used in other places.

1914

I've removed this return because otherwise you get spurious "expected module declaration" errors for valid module definition.

bruno accepted this revision.Aug 18 2020, 10:25 AM

LGTM as is, minor suggestion below.

clang/include/clang/Basic/DiagnosticLexKinds.td
700

How about , parent module must be defined before the submodule?

This revision is now accepted and ready to land.Aug 18 2020, 10:25 AM
vsapsai updated this revision to Diff 287749.Aug 25 2020, 12:30 PM

Tweak the error text.

vsapsai marked an inline comment as done.Aug 25 2020, 4:33 PM

Thanks for the review.

clang/include/clang/Basic/DiagnosticLexKinds.td
700

Thanks, I think it is more direct and slightly more concise.