Improve diagnostics for missing import / #include of module.
authorRichard Smith <richard@metafoo.co.uk>
Wed, 29 Apr 2020 01:22:34 +0000 (18:22 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Wed, 29 Apr 2020 01:41:14 +0000 (18:41 -0700)
commit0a088ead85fae11bb41d8a93ebe213db5554f087
tree3c12b1b2f7f4e976566913034cfa9eb7dc3b1a9f
parent216833b32befd14079130a3b857906f4e301179c
Improve diagnostics for missing import / #include of module.

Fix a few bugs where we would fail to properly determine header to
module correspondence when determining whether to suggest a #include or
import, and suggest a #include more often in language modes where there
is no import syntax. Generally, if the target is in a header with
include guards or #pragma once, we should suggest either #including or
importing that header, and not importing a module that happens to
textually include it.

In passing, improve the notes we attach to the corresponding
diagnostics: calling an entity that we couldn't see "previous" is
confusing.
36 files changed:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/ModuleMap.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
clang/test/CXX/module/module.unit/p8.cpp
clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp
clang/test/Modules/auto-module-import.m
clang/test/Modules/cxx-templates.cpp
clang/test/Modules/decldef.m
clang/test/Modules/decldef.mm
clang/test/Modules/diagnose-missing-import.m
clang/test/Modules/interface-diagnose-missing-import.m
clang/test/Modules/ms-enums.cpp
clang/test/Modules/no-module-map.cpp
clang/test/Modules/normal-module-map.cpp
clang/test/Modules/stddef.c
clang/test/Modules/subframeworks.m
clang/test/Modules/submodule-visibility-cycles.cpp
clang/test/Modules/submodule-visibility.cpp
clang/test/Modules/submodules-merge-defs.cpp
clang/test/Modules/submodules.cpp
clang/test/Modules/suggest-include.cpp
clang/test/Modules/tag-injection.c
clang/test/Modules/tag-injection.cpp
clang/test/Modules/template-default-args.cpp
clang/test/Modules/undefined-type-fixit1.cpp
clang/test/Modules/visibility-in-instantiation.cpp
clang/test/SemaCXX/compare-modules-cxx2a.cpp
clang/test/SemaCXX/modules-ts.cppm
clang/tools/libclang/Indexing.cpp