This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] In TransformerClangTidyCheck, require Explanation field.
ClosedPublic

Authored by ymandel on May 23 2019, 12:45 PM.

Details

Summary

In general, the Explanation field is optional in RewriteRule cases. But,
because the primary purpose of clang-tidy checks is to provide users with
diagnostics, we assume that a missing explanation is a bug. This change adds an
assertion that checks all cases for an explanation, and updates the code to rely
on that assertion correspondingly.

Diff Detail

Repository
rL LLVM

Event Timeline

ymandel created this revision.May 23 2019, 12:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2019, 12:46 PM
Herald added a subscriber: xazax.hun. · View Herald Transcript
ilya-biryukov accepted this revision.May 24 2019, 12:49 AM

LGTM, thanks!

clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
38 ↗(On Diff #201041)

NIT: this might be the first place people look at when writing the check, so we might want to provide a real explanation here.
Something like negate condition and revert then and else branches

This revision is now accepted and ready to land.May 24 2019, 12:49 AM
ymandel added inline comments.May 24 2019, 7:08 AM
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
38 ↗(On Diff #201041)

will do. But, realized this is a bit ugly so sent https://reviews.llvm.org/D62390 to add support for the explanation to makeRule.

ymandel updated this revision to Diff 201256.May 24 2019, 8:17 AM

updated to use new version of makeRule; changed explanation text in test

ymandel marked 2 inline comments as done.May 24 2019, 8:17 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2019, 9:29 AM