aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/DependencyFile.cpp
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2018-09-18 23:27:02 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2018-09-18 23:27:02 +0000
commita4c53284c131bdd1ba2d330d918f42159af4eee2 (patch)
tree7b4f9f003435cc449adc070693a14da3a9bce6e4 /clang/lib/Frontend/DependencyFile.cpp
parent78381c63ae076f17092236b4e4c80df7fc222f15 (diff)
downloadllvm-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.cpp15
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);