diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2018-07-09 09:07:01 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2018-07-09 09:07:01 +0000 |
commit | e5801b02e49b6fc4dd07702652ea70c9ea0275f3 (patch) | |
tree | fdaeacb9e138bd577953945ce1c7553e86ef81c7 | |
parent | 078c879a50f187c4c25e208565c7b34f1b3fc822 (diff) | |
download | bcm5719-llvm-e5801b02e49b6fc4dd07702652ea70c9ea0275f3.tar.gz bcm5719-llvm-e5801b02e49b6fc4dd07702652ea70c9ea0275f3.zip |
[Preamble] Check system dependencies in preamble too
Summary:
PrecompiledPreamble hasn't checked if the system dependencies changed
before. This resulted in invalid preamble not being rebuilt if headers
that changed were found in -isystem include paths.
This pattern is sometimes used to avoid showing warnings in third
party code, so we want to correctly handle those cases.
Tested in clangd, see the follow-up patch.
Reviewers: sammccall, ioeric
Reviewed By: sammccall
Subscribers: omtcyfz, cfe-commits
Differential Revision: https://reviews.llvm.org/D48946
llvm-svn: 336528
-rw-r--r-- | clang/lib/Frontend/PrecompiledPreamble.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp index 23371d1f426..30ae2db26d8 100644 --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -63,6 +63,16 @@ createVFSOverlayForPreamblePCH(StringRef PCHFilename, return Overlay; } +class PreambleDependencyCollector : public DependencyCollector { +public: + // We want to collect all dependencies for correctness. Avoiding the real + // system dependencies (e.g. stl from /usr/lib) would probably be a good idea, + // but there is no way to distinguish between those and the ones that can be + // spuriously added by '-isystem' (e.g. to suppress warnings from those + // headers). + bool needSystemDependencies() override { return true; } +}; + /// Keeps a track of files to be deleted in destructor. class TemporaryFiles { public: @@ -311,7 +321,7 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build( Clang->setSourceManager( new SourceManager(Diagnostics, Clang->getFileManager())); - auto PreambleDepCollector = std::make_shared<DependencyCollector>(); + auto PreambleDepCollector = std::make_shared<PreambleDependencyCollector>(); Clang->addDependencyCollector(PreambleDepCollector); // Remap the main source file to the preamble buffer. |