This is an archive of the discontinued LLVM Phabricator instance.

Validate clang-tidy check names.
ClosedPublic

Authored by alexfh on Aug 20 2014, 6:55 AM.

Details

Reviewers
djasper
Summary

ClangTidy and its frontends rely on check names being restricted to
certain rules, e.g. having a comma in a check name would break -checks=
parameter parsing. So we need to validate check names early.

Diff Detail

Event Timeline

alexfh updated this revision to Diff 12698.Aug 20 2014, 6:55 AM
alexfh retitled this revision from to Validate clang-tidy check names..
alexfh updated this object.
alexfh edited the test plan for this revision. (Show Details)
alexfh added a reviewer: djasper.
alexfh added a subscriber: Unknown Object (MLST).
djasper added inline comments.Aug 20 2014, 7:15 AM
clang-tidy/ClangTidy.cpp
294

Should we really validate the analyzer check names here? And if so, should we assert?

I'd be more comfortable moving at least the assert to somewhere in the static analyzer itself, so that people working on it know what valid names are and don't have to discover that by breaking an assert build of clang-tidy.

Or, alternatively, people can't add more analyzer checks by linking additional libraries to clang-tidy, right? Should we just have a test that calls "clang-tidy -list-checks" and verifies all the names?

323

It almost feels like it is not worth implementing and testing this function. I'd be fine with simply defining the string as a constant and then calling llvm::Regex().match() at the two call sites. Specifically, if it is located here, people might think that they have to do something with this function when writing a check.

clang-tidy/ClangTidy.h
89

Maybe: .., if \p Name can be used as a check name.

alexfh updated this revision to Diff 13025.Aug 28 2014, 2:41 AM

Use a test instead of runtime checks.

djasper edited edge metadata.Aug 28 2014, 3:05 AM

I think this is fine for the analyzer checks. However, as people can link in their checks, it might make sense to do runtime checks for those. WDYT?

In D4982#7, @djasper wrote:

I think this is fine for the analyzer checks. However, as people can link in their checks, it might make sense to do runtime checks for those. WDYT?

Well, if someone links their checks in, they should still run clang-tidy tests.

alexfh added a comment.Sep 4 2014, 7:40 AM

Daily pIng ;)

djasper accepted this revision.Sep 8 2014, 9:32 AM
djasper edited edge metadata.

But they won't run clang-tidy checks, but I can see reasons for keeping the implementation simpler. Either way, this is a strict improvement, so looks good.

This revision is now accepted and ready to land.Sep 8 2014, 9:32 AM
alexfh closed this revision.Sep 8 2014, 9:38 AM

This has already landed unintentionally in r217155.