diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2018-09-18 23:27:02 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2018-09-18 23:27:02 +0000 |
commit | a4c53284c131bdd1ba2d330d918f42159af4eee2 (patch) | |
tree | 7b4f9f003435cc449adc070693a14da3a9bce6e4 /clang/lib/Frontend/DependencyFile.cpp | |
parent | 78381c63ae076f17092236b4e4c80df7fc222f15 (diff) | |
download | llvm-a4c53284c131bdd1ba2d330d918f42159af4eee2.zip llvm-a4c53284c131bdd1ba2d330d918f42159af4eee2.tar.gz llvm-a4c53284c131bdd1ba2d330d918f42159af4eee2.tar.bz2 |
Add a callback for `__has_include` and use it for dependency scanning.
This adds a preprocessor callback for the `__has_include` and
`__has_include_next` directives.
Successful checking for the presence of a header should add it to the list of
header dependencies so this overrides the callback in the dependency scanner.
Patch by Pete Cooper with some additions by me.
rdar://problem/39545636
Differential Revision: https://reviews.llvm.org/D30882
llvm-svn: 342517
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index a3f3479..fdccd91 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -200,6 +200,10 @@ public: const Module *Imported, SrcMgr::CharacteristicKind FileType) override; + void HasInclude(SourceLocation Loc, StringRef SpelledFilename, bool IsAngled, + const FileEntry *File, + SrcMgr::CharacteristicKind FileType) override; + void EndOfMainFile() override { OutputDependencyFile(); } @@ -328,6 +332,17 @@ void DFGImpl::InclusionDirective(SourceLocation HashLoc, } } +void DFGImpl::HasInclude(SourceLocation Loc, StringRef SpelledFilename, + bool IsAngled, const FileEntry *File, + SrcMgr::CharacteristicKind FileType) { + if (!File) + return; + StringRef Filename = File->getName(); + if (!FileMatchesDepCriteria(Filename.data(), FileType)) + return; + AddFilename(llvm::sys::path::remove_leading_dotslash(Filename)); +} + bool DFGImpl::AddFilename(StringRef Filename) { if (FilesSet.insert(Filename).second) { Files.push_back(Filename); |