[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:13:24 PDT 2018
vsapsai updated this revision to Diff 144802.
vsapsai added a comment.
- Fix FileSkipped adding system headers when it shouldn't.
https://reviews.llvm.org/D30881
Files:
clang/lib/Frontend/DependencyFile.cpp
clang/test/Frontend/Inputs/SystemHeaderPrefix/with-header-guard.h
clang/test/Frontend/dependency-gen-symlink.c
Index: clang/test/Frontend/dependency-gen-symlink.c
===================================================================
--- /dev/null
+++ clang/test/Frontend/dependency-gen-symlink.c
@@ -0,0 +1,24 @@
+// REQUIRES: shell
+
+// Basic test
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+// RUN: mkdir %t.dir/a
+// RUN: mkdir %t.dir/b
+// RUN: echo "#ifndef HEADER_A" > %t.dir/a/header.h
+// RUN: echo "#define HEADER_A" >> %t.dir/a/header.h
+// RUN: echo "#endif" >> %t.dir/a/header.h
+// RUN: ln -s %t.dir/a/header.h %t.dir/b/header.h
+
+// RUN: %clang_cc1 -dependency-file %t.dir/file.deps -MT %s.o %s -fsyntax-only -I %t.dir -isystem %S/Inputs/SystemHeaderPrefix
+// RUN: FileCheck -input-file=%t.dir/file.deps %s
+// CHECK: dependency-gen-symlink.c.o
+// CHECK: dependency-gen-symlink.c
+// CHECK: a/header.h
+// CHECK: b/header.h
+// CHECK-NOT: with-header-guard.h
+#include "a/header.h"
+#include "b/header.h"
+// System header shouldn't be included in dependencies.
+#include <with-header-guard.h>
+#include <with-header-guard.h>
Index: clang/test/Frontend/Inputs/SystemHeaderPrefix/with-header-guard.h
===================================================================
--- /dev/null
+++ clang/test/Frontend/Inputs/SystemHeaderPrefix/with-header-guard.h
@@ -0,0 +1,3 @@
+#ifndef HEADER_GUARD
+#define HEADER_GUARD
+#endif
Index: clang/lib/Frontend/DependencyFile.cpp
===================================================================
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -185,6 +185,10 @@
void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID) override;
+
+ void FileSkipped(const FileEntry &SkippedFile, const Token &FilenameTok,
+ SrcMgr::CharacteristicKind FileType) override;
+
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange, const FileEntry *File,
@@ -291,6 +295,16 @@
AddFilename(llvm::sys::path::remove_leading_dotslash(Filename));
}
+void DFGImpl::FileSkipped(const FileEntry &SkippedFile,
+ const Token &FilenameTok,
+ SrcMgr::CharacteristicKind FileType) {
+ StringRef Filename = SkippedFile.getName();
+ if (!FileMatchesDepCriteria(Filename.data(), FileType))
+ return;
+
+ AddFilename(llvm::sys::path::remove_leading_dotslash(Filename));
+}
+
void DFGImpl::InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
StringRef FileName,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30881.144802.patch
Type: text/x-patch
Size: 2713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180501/f4ad10d1/attachment-0001.bin>
More information about the cfe-commits
mailing list