[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 30 19:09:19 PDT 2018
rsmith added inline comments.
================
Comment at: include/clang/Lex/PPCallbacks.h:263
+ /// \brief Callback invoked when a has_include directive is read.
+ virtual void HasInclude(SourceLocation Loc, const FileEntry *File) {
+ }
----------------
This callback seems pretty unhelpful in the case where lookup of the file failed (you just get a source location). Could we pass in the `FileName` and `IsAngled` flag too (like we do for `InclusionDirective`)? I think that's what (eg) a callback tracking anti-dependencies (for a more sophisticated build system that can handle them) would want.
================
Comment at: lib/Frontend/DependencyFile.cpp:325
+void DFGImpl::HasInclude(SourceLocation Loc, const FileEntry *File) {
+ if (!File)
+ return;
----------------
Have you thought about whether we should add a dependency even for a missing file under `-MG` (`AddMissingHeaderDeps`) mode? I think it's probably better to not do so (ie, the behavior in this patch), but it seems worth considering.
https://reviews.llvm.org/D30882
More information about the cfe-commits
mailing list