[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

Malcolm Parsons via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 13:05:49 PST 2016


On 1 Dec 2016 8:37 p.m., "Mads Ravn" <madsravn at gmail.com> wrote:
> I see the idea for the fixit clearly for case 3 & 4. Just erase
.compare(str2) and replace 0 with str2. I have a quick question though:
Given the declRefExpr().bind("str2"), how do I read the name of it in
clang-tidy? Or should I just bind 0 as well and then create replacement
with str where const auto str = Result.Nodes.getNodeAs<Stmt>("str2") ?

You could use
FixItHint::CreateInsertionFromRange to copy str2 to 0, or leave str2 where
it is, remove the binary operator and create a new one between the strings.

> Where I seem to find a little trouble is how to fixit case 1 & 2 now that
they are reduced to one case. How do I check whether or not there is a
unary operator in front of the implicitCast?

No idea.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161201/804c0430/attachment.html>


More information about the cfe-commits mailing list