<div class="gmail_quote">On Fri, Jun 8, 2012 at 2:14 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: jrose<br>
Date: Fri Jun  8 16:14:19 2012<br>
New Revision: 158229<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=158229&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=158229&view=rev</a><br>
Log:<br>
If fixits appear to overlap, move the second one over in the output.<br>
<br>
This occurs when you have two insertions and the first one is so long that the<br>
second fixit's column is before the first fixit ends. The edits themselves<br>
don't actually overlap, but our command-line preview does.<br></blockquote><div><br></div><div>Can you use FileCheck to write a test case please?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Modified:<br>
    cfe/trunk/lib/Frontend/TextDiagnostic.cpp<br>
<br>
Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=158229&r1=158228&r2=158229&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=158229&r1=158228&r2=158229&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Fri Jun  8 16:14:19 2012<br>
@@ -1090,6 +1090,7 @@<br>
   std::string FixItInsertionLine;<br>
   if (Hints.empty() || !DiagOpts.ShowFixits)<br>
     return FixItInsertionLine;<br>
+  unsigned PrevHintEnd = 0;<br>
<br>
   for (ArrayRef<FixItHint>::iterator I = Hints.begin(), E = Hints.end();<br>
        I != E; ++I) {<br>
@@ -1107,6 +1108,16 @@<br>
         assert(HintColNo<static_cast<unsigned>(map.bytes())+1);<br>
         HintColNo = map.byteToColumn(HintColNo);<br>
<br>
+        // If we inserted a long previous hint, push this one forwards, and add<br>
+        // an extra space to show that this is not part of the previous<br>
+        // completion. This is sort of the best we can do when two hints appear<br>
+        // to overlap.<br>
+        //<br>
+        // Note that if this hint is located immediately after the previous<br>
+        // hint, no space will be added, since the location is more important.<br>
+        if (HintColNo < PrevHintEnd)<br>
+          HintColNo = PrevHintEnd + 1;<br>
+<br>
         // FIXME: if the fixit includes tabs or other characters that do not<br>
         //  take up a single column per byte when displayed then<br>
         //  I->CodeToInsert.size() is not a column number and we're mixing<br>
@@ -1115,19 +1126,16 @@<br>
         unsigned LastColumnModified<br>
           = HintColNo + I->CodeToInsert.size();<br>
<br>
-        if (LastColumnModified > static_cast<unsigned>(map.bytes())) {<br>
-          unsigned LastExistingColumn = map.byteToColumn(map.bytes());<br>
-          unsigned AddedColumns = LastColumnModified-LastExistingColumn;<br>
-          LastColumnModified = LastExistingColumn + AddedColumns;<br>
-        } else {<br>
+        if (LastColumnModified <= static_cast<unsigned>(map.bytes()))<br>
           LastColumnModified = map.byteToColumn(LastColumnModified);<br>
-        }<br>
<br>
         if (LastColumnModified > FixItInsertionLine.size())<br>
           FixItInsertionLine.resize(LastColumnModified, ' ');<br>
         assert(HintColNo+I->CodeToInsert.size() <= FixItInsertionLine.size());<br>
         std::copy(I->CodeToInsert.begin(), I->CodeToInsert.end(),<br>
                   FixItInsertionLine.begin() + HintColNo);<br>
+<br>
+        PrevHintEnd = LastColumnModified;<br>
       } else {<br>
         FixItInsertionLine.clear();<br>
         break;<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>