summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPLexerChange.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-05-20 13:49:41 +0000
committerDouglas Gregor <dgregor@apple.com>2013-05-20 13:49:41 +0000
commitf4e76b864f772fb2792e89a83e29c5ee340d58f4 (patch)
tree68c1cae0560735184b3f06245c648b9e61a564b1 /clang/lib/Lex/PPLexerChange.cpp
parent9711b25d4ba545f6deb7a285c40b1fc8669f4fd5 (diff)
downloadbcm5719-llvm-f4e76b864f772fb2792e89a83e29c5ee340d58f4.tar.gz
bcm5719-llvm-f4e76b864f772fb2792e89a83e29c5ee340d58f4.zip
Add -Wincomplete-module, which detects when a header is included from a module but isn't itself part of a module.
llvm-svn: 182263
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r--clang/lib/Lex/PPLexerChange.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp
index a22d67a6edf..deec5a8766c 100644
--- a/clang/lib/Lex/PPLexerChange.cpp
+++ b/clang/lib/Lex/PPLexerChange.cpp
@@ -401,8 +401,36 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
}
}
}
+
+ // Check whether there are any headers that were included, but not
+ // mentioned at all in the module map. Such headers
+ SourceLocation StartLoc
+ = SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
+ if (getDiagnostics().getDiagnosticLevel(diag::warn_forgotten_module_header,
+ StartLoc)
+ != DiagnosticsEngine::Ignored) {
+ ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
+ for (unsigned I = 0, N = SourceMgr.local_sloc_entry_size(); I != N; ++I) {
+ // We only care about file entries.
+ const SrcMgr::SLocEntry &Entry = SourceMgr.getLocalSLocEntry(I);
+ if (!Entry.isFile())
+ continue;
+
+ // Dig out the actual file.
+ const FileEntry *File = Entry.getFile().getContentCache()->OrigEntry;
+ if (!File)
+ continue;
+
+ // If it's not part of a module and not unknown, complain.
+ if (!ModMap.findModuleForHeader(File) &&
+ !ModMap.isHeaderInUnavailableModule(File)) {
+ Diag(StartLoc, diag::warn_forgotten_module_header)
+ << File->getName() << Mod->getFullModuleName();
+ }
+ }
+ }
}
-
+
return true;
}
OpenPOWER on IntegriCloud