summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2017-04-27 22:29:14 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2017-04-27 22:29:14 +0000
commitb907563fbcd71abcf6600688942c710468d43168 (patch)
treec227166320e80a33c2e11aa6d7f968ec68b371c7 /clang/lib/Lex/PPLexerChange.cpp
parentce9a8102a2a1f5e3db25c8444c46e36a5c03a523 (diff)
downloadbcm5719-llvm-b907563fbcd71abcf6600688942c710468d43168.tar.gz
bcm5719-llvm-b907563fbcd71abcf6600688942c710468d43168.zip
[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 llvm-svn: 301597
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r--clang/lib/Lex/PPLexerChange.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index 9f68f3bb89d..fcc49b38703 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud