diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2018-05-01 23:59:33 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2018-05-01 23:59:33 +0000 |
commit | 210f0e880b2ecd0b9252c120839ac6ea115f2ce5 (patch) | |
tree | d364c34899198e254a8bbb3be32e3441940354ae /clang/lib/Frontend/DependencyFile.cpp | |
parent | ddbd2b530c42d46eff1ad1360eb6cc5664f52bb3 (diff) | |
download | bcm5719-llvm-210f0e880b2ecd0b9252c120839ac6ea115f2ce5.tar.gz bcm5719-llvm-210f0e880b2ecd0b9252c120839ac6ea115f2ce5.zip |
Track skipped files in dependency scanning.
It's possible for a header to be a symlink to another header. In this
case both will be represented by clang::FileEntry with the same UID and
they'll use the same clang::HeaderFileInfo.
If you include both headers and use some single-inclusion mechanism
like a header guard or #import, one header will get a FileChanged
callback, and another FileSkipped.
So that we get an accurate dependency file, we therefore need to also
implement the FileSkipped callback in dependency scanning.
Patch by Pete Cooper.
Reviewers: bruno, pete
Reviewed By: bruno
Subscribers: cfe-commits, jkorous, vsapsai
Differential Revision: https://reviews.llvm.org/D30881
llvm-svn: 331319
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 561eb9c4a31..5ad1e97a8ff 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -185,6 +185,10 @@ public: void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override; + + void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok, + SrcMgr::CharacteristicKind FileType) override; + void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File, @@ -291,6 +295,16 @@ void DFGImpl::FileChanged(SourceLocation Loc, AddFilename(llvm::sys::path::remove_leading_dotslash(Filename)); } +void DFGImpl::FileSkipped(const FileEntry &SkippedFile, + const Token &FilenameTok, + SrcMgr::CharacteristicKind FileType) { + StringRef Filename = SkippedFile.getName(); + if (!FileMatchesDepCriteria(Filename.data(), FileType)) + return; + + AddFilename(llvm::sys::path::remove_leading_dotslash(Filename)); +} + void DFGImpl::InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, |