diff options
author | Richard Smith <richard@metafoo.co.uk> | 2020-04-28 18:22:34 -0700 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2020-04-28 18:41:14 -0700 |
commit | 0a088ead85fae11bb41d8a93ebe213db5554f087 (patch) | |
tree | 3c12b1b2f7f4e976566913034cfa9eb7dc3b1a9f /clang/lib/Lex/ModuleMap.cpp | |
parent | 216833b32befd14079130a3b857906f4e301179c (diff) | |
download | llvm-0a088ead85fae11bb41d8a93ebe213db5554f087.zip llvm-0a088ead85fae11bb41d8a93ebe213db5554f087.tar.gz llvm-0a088ead85fae11bb41d8a93ebe213db5554f087.tar.bz2 |
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.
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 4f7d5ab..85bf93a 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -662,7 +662,20 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(const FileEntry *File) { } ArrayRef<ModuleMap::KnownHeader> -ModuleMap::findAllModulesForHeader(const FileEntry *File) const { +ModuleMap::findAllModulesForHeader(const FileEntry *File) { + HeadersMap::iterator Known = findKnownHeader(File); + if (Known != Headers.end()) + return Known->second; + + if (findOrCreateModuleForHeaderInUmbrellaDir(File)) + return Headers.find(File)->second; + + return None; +} + +ArrayRef<ModuleMap::KnownHeader> +ModuleMap::findResolvedModulesForHeader(const FileEntry *File) const { + // FIXME: Is this necessary? resolveHeaderDirectives(File); auto It = Headers.find(File); if (It == Headers.end()) |