[clang-tidy] Fix relative path in header-filter.
authorDmitri Gribenko <gribozavr@gmail.com>
Fri, 20 Sep 2019 13:19:32 +0000 (13:19 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Fri, 20 Sep 2019 13:19:32 +0000 (13:19 +0000)
commit4a13c828f6d78e49eabffc7b57f805ca46a2a827
tree33ed6a9e5cbc2ba84539e6af0f2a338648f2dc85
parent81aa62addf7bd8d1cf57adc86dabcbc1c91f7a2c
[clang-tidy] Fix relative path in header-filter.

Summary:
Clang-tidy supports output diagnostics from header files if user
specifies --header-filter. But it can't handle relative path well.
For example, the folder structure of a project is:

```
// a.h is in /src/a/a.h

// b.h is in /src/b/b.h
...

// c.cpp is in /src/c.cpp

```

Now, we set --header-filter as --header-filter=/a/. That means we only
want to check header files under /src/a/ path, and ignore header files
uder /src/b/ path, but in current implementation, clang-tidy will check
/src/b/b.h also, because the name of b.h used in clang-tidy is
/src/a/../b/b.h.

This change tries to fix this issue.

Reviewers: alexfh, hokein, aaron.ballman, gribozavr

Reviewed By: gribozavr

Subscribers: MyDeveloperDay, xazax.hun, cfe-commits

Tags: #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D67501

Patch by Yubo Xie.

llvm-svn: 372388
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/test/clang-tidy/Inputs/file-filter/subfolder_a/header_a.h [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/Inputs/file-filter/subfolder_b/header_b.h [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/Inputs/file-filter/subfolder_c/header_c.h [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/file-filter.cpp