<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 23, 2014 at 2:21 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Wed, Jul 23, 2014 at 2:07 PM, Alexander Kornienko <<a href="mailto:alexfh@google.com">alexfh@google.com</a>> wrote:<br>

> On Wed, Jul 23, 2014 at 1:50 PM, Benjamin Kramer <<a href="mailto:benny.kra@googlemail.com">benny.kra@googlemail.com</a>><br>
> wrote:<br>
>><br>
>> Author: d0k<br>
>> Date: Wed Jul 23 06:50:54 2014<br>
>> New Revision: 213740<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213740&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213740&view=rev</a><br>
>> Log:<br>
>> Add the fix that should've accompanied r213738.<br>
>><br>
>> Modified:<br>
>>     clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp<br>
>><br>
>> Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp?rev=213740&r1=213739&r2=213740&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp?rev=213740&r1=213739&r2=213740&view=diff</a><br>

>><br>
>> ==============================================================================<br>
>> --- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp (original)<br>
>> +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp Wed Jul 23<br>
>> 06:50:54 2014<br>
>> @@ -34,7 +34,6 @@ void UnusedRAIICheck::registerMatchers(M<br>
>>                anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),<br>
>><br>
>> functionDecl(ast_matchers::isTemplateInstantiation()))))),<br>
>>            hasParent(compoundStmt().bind("compound")),<br>
>> -          hasDescendant(typeLoc().bind("typeloc")),<br>
>>            hasType(recordDecl(hasUserDeclaredDestructor())),<br>
>>            anyOf(has(BindTemp), has(functionalCastExpr(has(BindTemp)))))<br>
>>            .bind("expr"),<br>
>> @@ -71,8 +70,12 @@ void UnusedRAIICheck::check(const MatchF<br>
>>        return;<br>
>>      }<br>
>><br>
>> -  // Otherwise just suggest adding a name.<br>
>> -  const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("typeloc");<br>
>> +  // Otherwise just suggest adding a name. To find the place to insert<br>
>> the name<br>
>> +  // find the first TypeLoc in the children of E, which always points to<br>
>> the<br>
>> +  // written type.<br>
>> +  const auto *TL =<br>
>> +      selectFirst<TypeLoc>("t",<br>
>> match(expr(hasDescendant(typeLoc().bind("t"))),<br>
>> +                                      *E, *Result.Context));<br>
><br>
><br>
> Can't you just match typeLoc()?<br>
<br>
</div></div>I tried that and it doesn't work. Neither does findAll(typeLoc()).<br></blockquote><div><br></div><div>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?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Took me a while to come up with the current incantation :|<br>
<br>
- Ben<br>
<div class=""><div class="h5"><br>
>><br>
>>    D << FixItHint::CreateInsertion(<br>
>>        Lexer::getLocForEndOfToken(TL->getLocEnd(), 0,<br>
>> *Result.SourceManager,<br>
>>                                   Result.Context->getLangOpts()),<br>
>><br></div></div></blockquote></div>
</div></div>