This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.
ClosedPublic

Authored by hokein on Apr 16 2018, 11:53 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

hokein created this revision.Apr 16 2018, 11:53 AM
JonasToth added inline comments.
test/clang-tidy/read_file_config.cpp
1 ↗(On Diff #142670)

Will this work on windows?

hokein added inline comments.Apr 17 2018, 1:58 AM
test/clang-tidy/read_file_config.cpp
1 ↗(On Diff #142670)

I believe it works on windows (although I don't have a windows machine) -- this command has been used in a few existing tests.

alexfh requested changes to this revision.Apr 17 2018, 3:22 AM

Thank you for investigating and fixing this!

One comment re: the test below.

test/clang-tidy/read_file_config.cpp
5 ↗(On Diff #142670)

Please add a sanity check to ensure the code triggers the static analyzer check, when enabled explicitly:

// RUN: clang-tidy -checks=-*,clang-analyzer-* %T/read-file-config/test.cpp | grep "clang-analyzer-*"

(hint: it won't pass, since your regex in grep is incorrect ;)

This revision now requires changes to proceed.Apr 17 2018, 3:22 AM
hokein updated this revision to Diff 142759.Apr 17 2018, 4:34 AM
hokein marked an inline comment as done.

Add one more test to ensure the test code triggering "clang-analyzer-*" checks.

test/clang-tidy/read_file_config.cpp
5 ↗(On Diff #142670)

Done. This is valid regex, but doesn't do the expect thing, we expect to match the whole check name, which should be clang-analyzer-.*

alexfh accepted this revision.Apr 17 2018, 6:38 AM
alexfh added inline comments.
test/clang-tidy/read_file_config.cpp
5 ↗(On Diff #142670)

I didn't say the regex is invalid, I said it's incorrect (in the sense that it matches a pattern different from the one useful in this test). Anyway, thanks for the fix!

One more idea is to expand the pattern a bit to make it obvious it matches a specific static analyzer warning ("warning: .* [clang-analyzer-specific.checker.Name]$").

This revision is now accepted and ready to land.Apr 17 2018, 6:38 AM
hokein updated this revision to Diff 142817.Apr 17 2018, 12:41 PM
hokein marked an inline comment as done.

Make grep pattern more obvious.

This revision was automatically updated to reflect the committed changes.