diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2017-04-27 22:29:14 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2017-04-27 22:29:14 +0000 |
commit | 4ef94de34993f694aced084f55c7d2263ca7c367 (patch) | |
tree | c85c5614e1bf384e14abe887039084a134621375 /lib/Lex | |
parent | c5a1b98af41696441c247686a80357f478fb000c (diff) |
[Modules] Improve diagnostics for incomplete umbrella
One of the -Wincomplete-umbrella warnings diagnoses when a header is present in
the directory but it's not present in the umbrella header. Currently, this
warning only happens on top level modules; any submodule using an umbrella
header does not get this warning. Fix that by also considering the submodules.
Differential Revision: https://reviews.llvm.org/D32576
rdar://problem/22623686
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 9f68f3bb89..fcc49b3870 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEndPos() { return EndPos; } +static void collectAllSubModulesWithUmbrellaHeader( + const Module &Mod, SmallVectorImpl<const Module *> &SubMods) { + if (Mod.getUmbrellaHeader()) + SubMods.push_back(&Mod); + for (auto *M : Mod.submodules()) + collectAllSubModulesWithUmbrellaHeader(*M, SubMods); +} + void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) { assert(Mod.getUmbrellaHeader() && "Module must use umbrella header"); SourceLocation StartLoc = @@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { } // If we are building a module that has an umbrella header, make sure that - // each of the headers within the directory covered by the umbrella header - // was actually included by the umbrella header. - if (Module *Mod = getCurrentModule()) - diagnoseMissingHeaderInUmbrellaDir(*Mod); + // each of the headers within the directory, including all submodules, is + // covered by the umbrella header was actually included by the umbrella + // header. + if (Module *Mod = getCurrentModule()) { + llvm::SmallVector<const Module *, 4> AllMods; + collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods); + for (auto *M : AllMods) + diagnoseMissingHeaderInUmbrellaDir(*M); + } return true; } |