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 | 30d3f201efd974e92af39ab7522ca30ddb2a379a (patch) | |
tree | 8de8a5966bdfce89dff257c1ff211ace4fef2086 /include/clang/Lex | |
parent | c8df8c22bd6f649763c20fb4b8a944309008da6a (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342517 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r-- | include/clang/Lex/PPCallbacks.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index 45c2d18da6..2448b34c8a 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -276,6 +276,12 @@ public: SourceRange Range) { } + /// Hook called when a '__has_include' or '__has_include_next' directive is + /// read. + virtual void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled, + const FileEntry *File, + SrcMgr::CharacteristicKind FileType) {} + /// Hook called when a source range is skipped. /// \param Range The SourceRange that was skipped. The range begins at the /// \#if/\#else directive and ends after the \#endif/\#else directive. @@ -443,6 +449,13 @@ public: Second->PragmaDiagnostic(Loc, Namespace, mapping, Str); } + void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled, + const FileEntry *File, + SrcMgr::CharacteristicKind FileType) override { + First->HasInclude(Loc, FileName, IsAngled, File, FileType); + Second->HasInclude(Loc, FileName, IsAngled, File, FileType); + } + void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State) override { First->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State); |