<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 17, 2014 at 1:48 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 Sep 17 06:48:34 2014<br>
New Revision: 217951<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217951&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217951&view=rev</a><br>
Log:<br>
[clang-tidy] Don't emit the same fixit multiple times.<br>
<br>
If we had many header files we would attach the fix-it for all files to all<br>
warnings, oops. This is harmless 99.9% of the time but can confuse the rewriter<br>
in some edge cases. Sadly I failed to create a small test case for this.<br>
<br>
While there move fix-its instead of copying.<br>
<br>
Modified:<br>
    clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp<br>
<br>
Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp?rev=217951&r1=217950&r2=217951&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp?rev=217951&r1=217950&r2=217951&view=diff</a><br>
==============================================================================<br>
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp (original)<br>
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp Wed Sep 17 06:48:34 2014<br>
@@ -125,15 +125,16 @@ public:<br>
         if (CurHeaderGuard != NewGuard) {<br>
           auto D = Check->diag(Ifndef,<br>
                                "header guard does not follow preferred style");<br>
-          for (const FixItHint Fix : FixIts)<br>
-            D.AddFixItHint(Fix);<br>
+          for (FixItHint &Fix : FixIts)<br>
+            D.AddFixItHint(std::move(Fix));<br>
         } else {<br>
           auto D = Check->diag(EndIf, "#endif for a header guard should "<br>
                                       "reference the guard macro in a comment");<br>
-          for (const FixItHint Fix : FixIts)<br>
-            D.AddFixItHint(Fix);<br>
+          for (FixItHint &Fix : FixIts)<br>
+            D.AddFixItHint(std::move(Fix));<br>
         }<br>
       }<br>
+      FixIts.clear();<br></blockquote><div><br></div><div>From how it is used, FixIts could also be a local variable.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     }<br>
<br>
     // Emit warnings for headers that are missing guards.<br>
@@ -144,7 +145,6 @@ public:<br>
     Files.clear();<br>
     Ifndefs.clear();<br>
     EndIfs.clear();<br>
-    FixIts.clear();<br>
   }<br>
<br>
   bool wouldFixEndifComment(StringRef FileName, SourceLocation EndIf,<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>
</div></div>