[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2023-07-10 Thread Justin Cady via Phabricator via cfe-commits
justincady added subscribers: njames93, LegalizeAdulthood, justincady.
justincady added a comment.

This feature appears to have strong user support throughout this review, and a 
lot of people (including myself) seem interested in having it landed.

cc'ing some clang-tidy owners 
:
 @LegalizeAdulthood @carlosgalvezp @njames93

Is there anything blocking this from moving forward? Can we work to get it 
submitted?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2022-02-23 Thread Amin Yahyaabadi via Phabricator via cfe-commits
aminya added a comment.

Clang-tidy is very slow if you use it on a medium or large project. Something 
like this feature, even if it is not perfect, will definitely improve the 
experience with clang-tidy. The low performance of clang-tidy is one of the 
biggest frictions for using it.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Here's a patch that uses Globs, let me know how you like it!
https://reviews.llvm.org/D112720


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

> everyone has .* in their config file, which will silently stop to work

Nevermind this. `.*` treated as a glob will turn into the regex `..*` which is 
equivalent.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Also, the new header filter expresion would need to be: `HeaderFilter: 
'*/mydir/*' instead of `HeaderFilter: 'mydir'`


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

On the other hand, switching from Regex to Glob will be quite a breaking change 
- everyone has `.*` in their config file, which will silently stop to work when 
switching to Glob and suddenly people won't get their headers linted. What do 
you think?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

I've recently fiddled with the `GlobList` to enable globbing in `NOLINT` 
expressions, so I have it quite fresh and I think it could easily be re-used 
here. I'd be happy to implement this feature, should I (can I?) continue on 
this patch or create a brand new one?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Mateusz via Phabricator via cfe-commits
Ashimaru added a comment.

In D34654#3022728 , @alexfh wrote:

> Repeating my question from an earlier comment: would a header glob list 
> (similar to how the format of the `-checks=` flag) be enough for the use 
> cases folks have? On the one hand glob list doesn't support all the features 
> of regular expressions, but are they all useful for matching paths? Glob list 
> in clang-tidy currently supports set union (similar to regex `|`) and  subsequence> - `*` (regex `.*`). If needed, the support can be expanded with 
> `?`, character classes, character ranges and/or other features of POSIX globs 
> (https://man7.org/linux/man-pages/man7/glob.7.html). On the flipside, glob 
> list has a cleaner syntax (no need to quote characters common in paths - like 
> `.`), and allows to easily express exclusion of subsets. It should be a 
> convenient tool to represent a set of files / directories. In comparison to 
> the proposed header-filter + exclude-header-filter glob list makes it 
> possible to naturally express restrictions similar to "everything under a/ 
> (except for everything under a/b/ (except for everything under a/b/c/))" - 
> `a/,-a/b/,a/b/c/`.
>
> What do folks think?

Yes in my case this would be enough :)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-09-30 Thread Alan via Phabricator via cfe-commits
aco added a comment.

Hi, first of all I want to say that the name "HeaderFilterRegex" is a bit 
ambiguous, we don't know intuitively if we define what is filtered or what 
passes.

in my humble opinion alexfh's proposal would be much easier to use than 2 regex.

In D34654#3022728 , @alexfh wrote:

> would a header glob list (similar to how the format of the `-checks=` flag) 
> be enough for the use cases folks have?



  For me yes it's enough, and will be welcome. 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-09-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Repeating my question from an earlier comment: would a header glob list 
(similar to how the format of the `-checks=` flag) be enough for the use cases 
folks have? On the one hand glob list doesn't support all the features of 
regular expressions, but are they all useful for matching paths? Glob list in 
clang-tidy currently supports set union (similar to regex `|`) and  - `*` (regex `.*`). If needed, the support can be expanded with 
`?`, character classes, character ranges and/or other features of POSIX globs 
(https://man7.org/linux/man-pages/man7/glob.7.html). On the flipside, glob list 
has a cleaner syntax (no need to quote characters common in paths - like `.`), 
and allows to easily express exclusion of subsets. It should be a convenient 
tool to represent a set of files / directories. In comparison to the proposed 
header-filter + exclude-header-filter glob list makes it possible to naturally 
express restrictions similar to "everything under a/ (except for everything 
under a/b/ (except for everything under a/b/c/))" - `a/,-a/b/,a/b/c/`.

What do folks think?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-08-27 Thread Mateusz via Phabricator via cfe-commits
Ashimaru added a comment.

In my company we are using a lot of standard checks and it becomes time 
consuming - this patch would be extremely useful to us and non of proposals 
montioned @alexfh seem to solve the issue.
We would like to select which directories containing headers would be checked 
and using filtering after checking still has problem of running all checks on 
file that will later discarded - and we do not like paying for something we do 
not use ;)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-02-12 Thread Martin G via Phabricator via cfe-commits
MartinG added a comment.

More than 3.5 years later and this extremely basic feature hasn't been merged 
yet? Clang-tidy's interface is completely broken.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2020-12-09 Thread Hiral via Phabricator via cfe-commits
Hiralo added a comment.

We are dependent on this patch to exclude headers in regex while running 
clang-tidy.
Can we have this patch merged with upcoming GA versions? or
Can someone summarize what is pending in this review or what could be good 
alternative in v11 clang-tidy?
Thank you in advance.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2020-10-13 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

This is marked as "needs revision", but it's not clear to me what the requested 
changes actually are.

The proposed fix here may not be perfect, but AFAICT, there is simply no good 
way to exclude headers that are beyond your control at present.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2020-08-07 Thread Saimus Dev via Phabricator via cfe-commits
saimusdev added a comment.

Hello,

Any news on accepting this feature?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2020-03-22 Thread Elvis Stansvik via Phabricator via cfe-commits
estan added a comment.

It would be great to get something like this in.

In our project we're currently using a kludge of overriding the 
`RULE_LAUNCH_COMPILE` CMake variable to insert our own shell script as the 
compiler. The script strips the clang-tidy invocation inserted by CMake if the 
source path matches any of a set of regexes we have in a .clang-tidy-exclude 
file.

The original suggested solution with an exclude regex would be sufficient for 
us, but the source-centric approach described by @alexfh would also work. Just 
something would be good.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34654/new/

https://reviews.llvm.org/D34654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2018-11-15 Thread Laurent Nicolas via Phabricator via cfe-commits
lonico added a comment.



> The second way to handle this use case is possible on a different level: one 
> can run clang-tidy over the whole project with `-header-filter=.*` and then 
> filter the results and use a specialized tool to display them, e.g. 
> https://github.com/Ericsson/codechecker. I'm not sure though whether this 
> suits your needs or is an overkill.

This approach does not work for us, as our external headers generate a lot of 
warnings.  It's not so much the warnings that are an issue, but generating the 
notes is taking a lot of time.  We implemented this patch in our local 
installation, and it dramatically reduces the time it takes to run clang-tidy 
on a "component", where we can focus on the source and header files in a 
subdirectory tree, and exclude headers from other subdirectories.  In the worst 
case, we're really comparing 1 hour to a few minutes.

Even the first approach is not so interesting, as we would like warnings for 
another subdirectory tree to be visible in this subdirectory.   What we really 
want is to be able to segregate warnings per component (a subdirectory tree) 
and don't bother people who import headers from other subdirectory trees with 
local warnings.  So the owner of a subdirectory tree should see all warnings 
for their tree, but consumers of headers should not be bothered.


Repository:
  rL LLVM

https://reviews.llvm.org/D34654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-07-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> In our project we want to do something like include src/.*.h but exclude 
> src/some-thirdparty/.*.h.

There are at least two other possibilities to handle this use case.

The first one is to extend the way clang-tidy handles per-directory configs. 
Currently, for each translation unit clang-tidy takes the configuration for the 
main file of the translation unit and uses the Checks option found in this 
configuration to filter diagnostics coming from the main file as well as from 
the headers included by the translation unit. In a better world, it would take 
the configuration for the header where the diagnostic originates and thus allow 
a more source-centric way of controlling the set of diagnostics it displays. 
For example, consider this setup:

  a/.clang-tidy: Checks=-*,check1,check2
  a/a.cpp: #include a/a.h, #include b/b.h, #include third-party/c.h
  a/a.h
  b/.clang-tidy: Checks=-*,check2,check3
  b/b.h
  third-party/.clang-tidy: Checks=-*
  third-party/c.h

Let's assume that each of a/a.h, b/b.h, third-party/c.h and a/a.cpp contain 
code that triggers check1, check2 and check3. Currently, when run on a.cpp 
without `-header-filter`, clang-tidy would only output check1 and check2 from 
a.cpp. `-header-filter=.*` will result in check1 and check2 diagnostics from 
all the files.

If we change clang-tidy to apply the most relevant local configuration to the 
generated diagnostics (and get rid of `-header-filter` altogether, or set it to 
`.*` by default), in the case above it would output check1 and check2 from 
a/a.cpp and a/a.h, check2 from b/b.h (since we don't even run check3 on the 
code, and check1 gets filtered out), and no diagnostics from third-party/c.h, 
since we filter out check1 and check2 according to the local configuration. 
This seems like a more logical and useful behavior, however, when implementing 
this we'll have to make sure configuration retrieval doesn't become a 
bottleneck (FileOptionsProvider already implements some sort of caching, but 
we'd have to carefully benchmark it on large translation units with tons of 
diagnostics).

The second way to handle this use case is possible on a different level: one 
can run clang-tidy over the whole project with `-header-filter=.*` and then 
filter the results and use a specialized tool to display them, e.g. 
https://github.com/Ericsson/codechecker. I'm not sure though whether this suits 
your needs or is an overkill.


Repository:
  rL LLVM

https://reviews.llvm.org/D34654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-07-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I wonder whether anyone uses file patterns that need anything from regular 
expressions beyond `|` and `.*`. If not, globs (as used in -checks=) would be a 
better solution.

One problem with a header-filter + exclude-header-filter is that it doesn't 
make it easier to express restrictions similar to "everything under a/ (except 
for everything under a/b/ (except for everything under a/b/c/))".


Repository:
  rL LLVM

https://reviews.llvm.org/D34654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-07-18 Thread Todd Lipcon via Phabricator via cfe-commits
toddlipcon updated this revision to Diff 107148.
toddlipcon added a comment.

Regenerated patch with full context


Repository:
  rL LLVM

https://reviews.llvm.org/D34654

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst
  test/clang-tidy/file-filter.cpp

Index: test/clang-tidy/file-filter.cpp
===
--- test/clang-tidy/file-filter.cpp
+++ test/clang-tidy/file-filter.cpp
@@ -9,6 +9,7 @@
 //   file-filter\header*.h due to code order between '/' and '\\'.
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -exclude-header-filter='header1\.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5 %s
 
 #include "header1.h"
 // CHECK-NOT: warning:
@@ -19,6 +20,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: header1.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 #include "header2.h"
 // CHECK-NOT: warning:
@@ -29,6 +31,7 @@
 // CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
 // CHECK4: header2.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK5: header2.h:1:12: warning: single-argument constructors
 
 #include 
 // CHECK-NOT: warning:
@@ -39,6 +42,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: system-header.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: system-header.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 class A { A(int); };
 // CHECK: :[[@LINE-1]]:11: warning: single-argument constructors
@@ -49,6 +53,7 @@
 // CHECK3-QUIET: :[[@LINE-6]]:11: warning: single-argument constructors
 // CHECK4: :[[@LINE-7]]:11: warning: single-argument constructors
 // CHECK4-QUIET: :[[@LINE-8]]:11: warning: single-argument constructors
+// CHECK5: :[[@LINE-9]]:11: warning: single-argument constructors
 
 // CHECK-NOT: warning:
 // CHECK-QUIET-NOT: warning:
@@ -58,9 +63,10 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4-NOT: warning:
 // CHECK4-QUIET-NOT: warning:
+// CHECK5-NOT: warning:
 
 // CHECK: Suppressed 3 warnings (3 in non-user code)
-// CHECK: Use -header-filter=.* to display errors from all non-system headers.
+// CHECK: Use -header-filter=.* -exclude-header-filter='' to display errors from all non-system headers.
 // CHECK-QUIET-NOT: Suppressed
 // CHECK2: Suppressed 1 warnings (1 in non-user code)
 // CHECK2: Use -header-filter=.* {{.*}}
@@ -71,3 +77,5 @@
 // CHECK4-NOT: Suppressed {{.*}} warnings
 // CHECK4-NOT: Use -header-filter=.* {{.*}}
 // CHECK4-QUIET-NOT: Suppressed
+// CHECK5: Suppressed 2 warnings (2 in non-user code)
+// CHECK5: Use -header-filter=.* {{.*}}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -240,6 +240,7 @@
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
+  ExcludeHeaderFilterRegex: ''
   AnalyzeTemporaryDtors: false
   FormatStyle: none
   User:user
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -40,6 +40,7 @@
 Checks:  '-*,some-check'
 WarningsAsErrors: ''
 HeaderFilterRegex: ''
+ExcludeHeaderFilterRegex: ''
 AnalyzeTemporaryDtors: false
 FormatStyle: none
 User:user
@@ -89,6 +90,19 @@
  cl::init(""),
  cl::cat(ClangTidyCategory));
 
+static cl::opt
+ExcludeHeaderFilter("exclude-header-filter", cl::desc(R"(
+Regular expression matching the names of the
+headers to exclude when outputting diagnostics.
+Diagnostics from the main file of each translation
+unit are always displayed.
+Can be used together with -line-filter.
+This option overrides the 'ExcludeHeaderFilter' option
+in .clang-tidy file, if any.
+)"),
+ cl::init(""),
+ cl::cat(ClangTidyCategory));
+
 static cl::opt
 SystemHeaders("system-headers",
   cl::desc("Display th

[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-07-14 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Please regenerate the patch with full context (e.g. as described in 
llvm.org/docs/Phabricator.html).


Repository:
  rL LLVM

https://reviews.llvm.org/D34654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-07-14 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added reviewers: aaron.ballman, alexfh, hokein.
JonasToth added a comment.

i added reviewers, since it seems nobody takes care of this check.
remove if this was bad.


Repository:
  rL LLVM

https://reviews.llvm.org/D34654



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2017-06-26 Thread Todd Lipcon via Phabricator via cfe-commits
toddlipcon created this revision.
toddlipcon added a project: clang-tools-extra.
Herald added a subscriber: JDevlieghere.

This patch adds the ability to specify a regex of headers to exclude from 
clang-tidy diagnostics. This is the inverse of the existing header regex.

In our project we want to do something like include src/.*.h but exclude 
src/some-thirdparty/.*.h. Given only a positive regex configuration, we would 
have had to list all directories aside from 'some-thirdparty' such as 
src/(foo|bar|baz|...)/, which isn't practical or maintainable.

A while back there was a thread 
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046203.html which 
suggested using extended regexes which offer negative lookahead assertions to 
achieve this, but it was rejected due to poor stdlib support. I think an 
"exclude" regex is also more familiar to users since it shows up commonly in 
tools like rsync/tar/etc.

(note: I previously posted this as https://reviews.llvm.org/D34415 but was 
asked to re-post it with cfe-commits as a subscriber. Sorry for the double-post)


Repository:
  rL LLVM

https://reviews.llvm.org/D34654

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/index.rst
  test/clang-tidy/file-filter.cpp

Index: test/clang-tidy/file-filter.cpp
===
--- test/clang-tidy/file-filter.cpp
+++ test/clang-tidy/file-filter.cpp
@@ -9,6 +9,7 @@
 //   file-filter\header*.h due to code order between '/' and '\\'.
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -exclude-header-filter='header1\.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5 %s
 
 #include "header1.h"
 // CHECK-NOT: warning:
@@ -19,6 +20,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: header1.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 #include "header2.h"
 // CHECK-NOT: warning:
@@ -29,6 +31,7 @@
 // CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
 // CHECK4: header2.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK5: header2.h:1:12: warning: single-argument constructors
 
 #include 
 // CHECK-NOT: warning:
@@ -39,6 +42,7 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: system-header.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: system-header.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
 
 class A { A(int); };
 // CHECK: :[[@LINE-1]]:11: warning: single-argument constructors
@@ -49,6 +53,7 @@
 // CHECK3-QUIET: :[[@LINE-6]]:11: warning: single-argument constructors
 // CHECK4: :[[@LINE-7]]:11: warning: single-argument constructors
 // CHECK4-QUIET: :[[@LINE-8]]:11: warning: single-argument constructors
+// CHECK5: :[[@LINE-9]]:11: warning: single-argument constructors
 
 // CHECK-NOT: warning:
 // CHECK-QUIET-NOT: warning:
@@ -58,9 +63,10 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4-NOT: warning:
 // CHECK4-QUIET-NOT: warning:
+// CHECK5-NOT: warning:
 
 // CHECK: Suppressed 3 warnings (3 in non-user code)
-// CHECK: Use -header-filter=.* to display errors from all non-system headers.
+// CHECK: Use -header-filter=.* -exclude-header-filter='' to display errors from all non-system headers.
 // CHECK-QUIET-NOT: Suppressed
 // CHECK2: Suppressed 1 warnings (1 in non-user code)
 // CHECK2: Use -header-filter=.* {{.*}}
@@ -71,3 +77,5 @@
 // CHECK4-NOT: Suppressed {{.*}} warnings
 // CHECK4-NOT: Use -header-filter=.* {{.*}}
 // CHECK4-QUIET-NOT: Suppressed
+// CHECK5: Suppressed 2 warnings (2 in non-user code)
+// CHECK5: Use -header-filter=.* {{.*}}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -238,6 +238,7 @@
   Checks:  '-*,some-check'
   WarningsAsErrors: ''
   HeaderFilterRegex: ''
+  ExcludeHeaderFilterRegex: ''
   AnalyzeTemporaryDtors: false
   FormatStyle: none
   User:user
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -40,6 +40,7 @@