summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/ModuleMap.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-04-27 21:57:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-04-27 21:57:05 +0000
commit4eb8393c636b5525ac92ee0ac8efcf263e0a2541 (patch)
tree4e85116ed26bc9b32d45f3fc6002ec97899023b2 /clang/lib/Lex/ModuleMap.cpp
parent575ad8c2e13d6099f67d9d5e816fad8968c6e900 (diff)
downloadbcm5719-llvm-4eb8393c636b5525ac92ee0ac8efcf263e0a2541.tar.gz
bcm5719-llvm-4eb8393c636b5525ac92ee0ac8efcf263e0a2541.zip
[modules] When diagnosing a missing module import, suggest adding a #include if
the current language doesn't have an import syntax and we can figure out a suitable file to include. llvm-svn: 267802
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r--clang/lib/Lex/ModuleMap.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 4b782a3e8ec..467ae7ec518 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -209,29 +209,25 @@ ModuleMap::findHeaderInUmbrellaDirs(const FileEntry *File,
static bool violatesPrivateInclude(Module *RequestingModule,
const FileEntry *IncFileEnt,
- ModuleMap::ModuleHeaderRole Role,
- Module *RequestedModule) {
- bool IsPrivateRole = Role & ModuleMap::PrivateHeader;
+ ModuleMap::KnownHeader Header) {
#ifndef NDEBUG
- if (IsPrivateRole) {
+ if (Header.getRole() & ModuleMap::PrivateHeader) {
// Check for consistency between the module header role
// as obtained from the lookup and as obtained from the module.
// This check is not cheap, so enable it only for debugging.
bool IsPrivate = false;
SmallVectorImpl<Module::Header> *HeaderList[] = {
- &RequestedModule->Headers[Module::HK_Private],
- &RequestedModule->Headers[Module::HK_PrivateTextual]};
+ &Header.getModule()->Headers[Module::HK_Private],
+ &Header.getModule()->Headers[Module::HK_PrivateTextual]};
for (auto *Hs : HeaderList)
IsPrivate |=
std::find_if(Hs->begin(), Hs->end(), [&](const Module::Header &H) {
return H.Entry == IncFileEnt;
}) != Hs->end();
- assert((!IsPrivateRole || IsPrivate) && "inconsistent headers and roles");
+ assert(IsPrivate && "inconsistent headers and roles");
}
#endif
- return IsPrivateRole && (!RequestingModule ||
- RequestedModule->getTopLevelModule() !=
- RequestingModule->getTopLevelModule());
+ return !Header.isAccessibleFrom(RequestingModule);
}
static Module *getTopLevelOrNull(Module *M) {
@@ -259,8 +255,7 @@ void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
if (Known != Headers.end()) {
for (const KnownHeader &Header : Known->second) {
// Remember private headers for later printing of a diagnostic.
- if (violatesPrivateInclude(RequestingModule, File, Header.getRole(),
- Header.getModule())) {
+ if (violatesPrivateInclude(RequestingModule, File, Header)) {
Private = Header.getModule();
continue;
}
OpenPOWER on IntegriCloud