diff options
| author | Yitzhak Mandelbaum <yitzhakm@google.com> | 2019-05-24 16:32:03 +0000 |
|---|---|---|
| committer | Yitzhak Mandelbaum <yitzhakm@google.com> | 2019-05-24 16:32:03 +0000 |
| commit | 5b33554319cb3aeb88c43ecc6acbbef06a779190 (patch) | |
| tree | d1f7ce96d7ad0103d79c2c8d457b8fdf35cfd30d /clang-tools-extra/unittests/clang-tidy | |
| parent | 07745a131fa99931e83077e19cfaa4ae46e6c2bc (diff) | |
| download | bcm5719-llvm-5b33554319cb3aeb88c43ecc6acbbef06a779190.tar.gz bcm5719-llvm-5b33554319cb3aeb88c43ecc6acbbef06a779190.zip | |
[clang-tidy] In TransformerClangTidyCheck, require Explanation field.
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.
Reviewers: ilya-biryukov
Subscribers: xazax.hun, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D62340
llvm-svn: 361647
Diffstat (limited to 'clang-tools-extra/unittests/clang-tidy')
| -rw-r--r-- | clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp index 1426dbbc09b..6b8763810e9 100644 --- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp @@ -26,15 +26,18 @@ RewriteRule invertIf() { using tooling::change; using tooling::node; using tooling::statement; + using tooling::text; using tooling::stencil::cat; StringRef C = "C", T = "T", E = "E"; - return tooling::makeRule(ifStmt(hasCondition(expr().bind(C)), - hasThen(stmt().bind(T)), - hasElse(stmt().bind(E))), - change(statement(RewriteRule::RootID), - cat("if(!(", node(C), ")) ", statement(E), - " else ", statement(T)))); + RewriteRule Rule = tooling::makeRule( + ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)), + hasElse(stmt().bind(E))), + change( + statement(RewriteRule::RootID), + cat("if(!(", node(C), ")) ", statement(E), " else ", statement(T))), + text("negate condition and reverse `then` and `else` branches")); + return Rule; } class IfInverterCheck : public TransformerClangTidyCheck { |

