[PATCH] D30881: Track skipped files in dependency scanning

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 1 15:23:01 PDT 2018


vsapsai marked 2 inline comments as done.
vsapsai added inline comments.


================
Comment at: lib/Frontend/DependencyFile.cpp:191
+                   const Token &FilenameTok,
+                   SrcMgr::CharacteristicKind FileType) override;
+
----------------
bruno wrote:
> Is there any `FileSkipped` callback invocation that might trigger an unwanted file to be added as a dependency or it will only trigger for the symlink case?
FileSkipped is called when a file has a mechanism for single inclusion (header guards or #import) and it was already included. The callback will be triggered also for

```lang=c++
// a.h
#ifndef A_H_
#define A_H_
#include "b.h"
#endif

// b.h
#ifndef B_H_
#define B_H_
#endif

// test.c
#include "a.h"
#include "b.h"
```

But AddFilename performs Filename uniqueness check, so there will be no duplicate b.h in dependencies.

If the same file is included by multiple paths, all paths can end up in dependency file. It is actually what we want to achieve and it shouldn't cause unnecessary rebuilds.


================
Comment at: test/Frontend/dependency-gen-symlink.c:11
+// RUN: echo "#endif" >> %t.dir/a/header.h
+// RUN: ln %t.dir/a/header.h %t.dir/b/header.h
+
----------------
bruno wrote:
> It seems that it works for hard links as well right? Is this intended or do you miss a `-s`?
It works when files have the same inode. Added `-s` to capture more common use case.


https://reviews.llvm.org/D30881





More information about the cfe-commits mailing list