This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add support for diagnostics with no location
ClosedPublic

Authored by njames93 on Nov 20 2020, 11:18 AM.

Details

Summary

Add methods for emitting diagnostics with no location as well as a special diagnostic for configuration errors.
These show up in the errors as [clang-tidy-config].
The reason to use a custom name rather than the check name is to distinguish the error isn't the same category as the check that reported it.

Diff Detail

Event Timeline

njames93 created this revision.Nov 20 2020, 11:18 AM
njames93 requested review of this revision.Nov 20 2020, 11:18 AM
njames93 updated this revision to Diff 306884.Nov 21 2020, 4:20 PM

Fix unittest failing.

aaron.ballman added inline comments.Dec 3 2020, 9:51 AM
clang-tools-extra/clang-tidy/ClangTidyCheck.h
183

checks -> check's

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
276

Perhaps this is a bad idea, but would it make sense to have isCheckEnabled() report true for clang-tidy-config? It's not really a check, so that's a bit odd, but it seems like anywhere we're testing this property we wouldn't want to ignore config issues?

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
102

with reading configuration -> with reading the configuration

and add a full stop to the end of the comment.

njames93 marked 2 inline comments as done.Dec 4 2020, 5:49 AM
njames93 added inline comments.
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
276

I didn't personally think that was a good way to go. This is the only real place its used where you would get isCheckEnabled called with clang-tidy-config.

njames93 updated this revision to Diff 309521.Dec 4 2020, 5:49 AM

Address comments.

aaron.ballman accepted this revision.Dec 4 2020, 12:31 PM

LGTM!

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
276

Okay, that's good enough for me, thank you!

This revision is now accepted and ready to land.Dec 4 2020, 12:31 PM