<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 23, 2014 at 1:50 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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: <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>
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp (original)<br>
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp Wed Jul 23 06:50:54 2014<br>
@@ -34,7 +34,6 @@ void UnusedRAIICheck::registerMatchers(M<br>
               anyOf(recordDecl(ast_matchers::isTemplateInstantiation()),<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 the name<br>
+  // find the first TypeLoc in the children of E, which always points to the<br>
+  // written type.<br>
+  const auto *TL =<br>
+      selectFirst<TypeLoc>("t", match(expr(hasDescendant(typeLoc().bind("t"))),<br>
+                                      *E, *Result.Context));<br></blockquote><div><br></div><div>Can't you just match typeLoc()?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

   D << FixItHint::CreateInsertion(<br>
       Lexer::getLocForEndOfToken(TL->getLocEnd(), 0, *Result.SourceManager,<br>
                                  Result.Context->getLangOpts()),<br>
<br><br></blockquote></div>
</div></div>