[clang-tools-extra] r213740 - Add the fix that should've accompanied r213738.

Daniel Jasper djasper at google.com
Wed Jul 23 06:37:11 PDT 2014


Yes. match() simply means, run this matcher on this node. There is no
inherent recursion.


On Wed, Jul 23, 2014 at 3:35 PM, Alexander Kornienko <alexfh at google.com>
wrote:

> On Wed, Jul 23, 2014 at 2:21 PM, Benjamin Kramer <benny.kra at gmail.com>
> wrote:
>
>> On Wed, Jul 23, 2014 at 2:07 PM, Alexander Kornienko <alexfh at google.com>
>> wrote:
>> > On Wed, Jul 23, 2014 at 1:50 PM, Benjamin Kramer <
>> benny.kra at googlemail.com>
>> > wrote:
>> >>
>> >> Author: d0k
>> >> Date: Wed Jul 23 06:50:54 2014
>> >> New Revision: 213740
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=213740&view=rev
>> >> Log:
>> >> Add the fix that should've accompanied r213738.
>> >>
>> >> Modified:
>> >>     clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp
>> >>
>> >> Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp
>> >> URL:
>> >>
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp?rev=213740&r1=213739&r2=213740&view=diff
>> >>
>> >>
>> ==============================================================================
>> >> --- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp (original)
>> >> +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp Wed Jul 23
>> >> 06:50:54 2014
>> >> @@ -34,7 +34,6 @@ void UnusedRAIICheck::registerMatchers(M
>> >>
>>  anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),
>> >>
>> >> functionDecl(ast_matchers::isTemplateInstantiation()))))),
>> >>            hasParent(compoundStmt().bind("compound")),
>> >> -          hasDescendant(typeLoc().bind("typeloc")),
>> >>            hasType(recordDecl(hasUserDeclaredDestructor())),
>> >>            anyOf(has(BindTemp),
>> has(functionalCastExpr(has(BindTemp)))))
>> >>            .bind("expr"),
>> >> @@ -71,8 +70,12 @@ void UnusedRAIICheck::check(const MatchF
>> >>        return;
>> >>      }
>> >>
>> >> -  // Otherwise just suggest adding a name.
>> >> -  const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("typeloc");
>> >> +  // Otherwise just suggest adding a name. To find the place to insert
>> >> the name
>> >> +  // find the first TypeLoc in the children of E, which always points
>> to
>> >> the
>> >> +  // written type.
>> >> +  const auto *TL =
>> >> +      selectFirst<TypeLoc>("t",
>> >> match(expr(hasDescendant(typeLoc().bind("t"))),
>> >> +                                      *E, *Result.Context));
>> >
>> >
>> > Can't you just match typeLoc()?
>>
>> I tried that and it doesn't work. Neither does findAll(typeLoc()).
>>
>
> Can you explain in more detail what specifically doesn't work? Does it
> match anything? Daniel, do you have an explanation of why matching
> typeLoc() works differently than matching expr(hasDescendant(typeLoc())) on
> Expr?
>
>
>> Took me a while to come up with the current incantation :|
>>
>> - Ben
>>
>> >>
>> >>    D << FixItHint::CreateInsertion(
>> >>        Lexer::getLocForEndOfToken(TL->getLocEnd(), 0,
>> >> *Result.SourceManager,
>> >>                                   Result.Context->getLangOpts()),
>> >>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140723/6a819a58/attachment.html>


More information about the cfe-commits mailing list