[cfe-commits] r158229 - /cfe/trunk/lib/Frontend/TextDiagnostic.cpp
Chandler Carruth
chandlerc at google.com
Fri Jun 8 14:21:42 PDT 2012
On Fri, Jun 8, 2012 at 2:14 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> Author: jrose
> Date: Fri Jun 8 16:14:19 2012
> New Revision: 158229
>
> URL: http://llvm.org/viewvc/llvm-project?rev=158229&view=rev
> Log:
> If fixits appear to overlap, move the second one over in the output.
>
> This occurs when you have two insertions and the first one is so long that
> the
> second fixit's column is before the first fixit ends. The edits themselves
> don't actually overlap, but our command-line preview does.
>
Can you use FileCheck to write a test case please?
>
> Modified:
> cfe/trunk/lib/Frontend/TextDiagnostic.cpp
>
> Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=158229&r1=158228&r2=158229&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
> +++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Fri Jun 8 16:14:19 2012
> @@ -1090,6 +1090,7 @@
> std::string FixItInsertionLine;
> if (Hints.empty() || !DiagOpts.ShowFixits)
> return FixItInsertionLine;
> + unsigned PrevHintEnd = 0;
>
> for (ArrayRef<FixItHint>::iterator I = Hints.begin(), E = Hints.end();
> I != E; ++I) {
> @@ -1107,6 +1108,16 @@
> assert(HintColNo<static_cast<unsigned>(map.bytes())+1);
> HintColNo = map.byteToColumn(HintColNo);
>
> + // If we inserted a long previous hint, push this one forwards,
> and add
> + // an extra space to show that this is not part of the previous
> + // completion. This is sort of the best we can do when two hints
> appear
> + // to overlap.
> + //
> + // Note that if this hint is located immediately after the
> previous
> + // hint, no space will be added, since the location is more
> important.
> + if (HintColNo < PrevHintEnd)
> + HintColNo = PrevHintEnd + 1;
> +
> // FIXME: if the fixit includes tabs or other characters that do
> not
> // take up a single column per byte when displayed then
> // I->CodeToInsert.size() is not a column number and we're mixing
> @@ -1115,19 +1126,16 @@
> unsigned LastColumnModified
> = HintColNo + I->CodeToInsert.size();
>
> - if (LastColumnModified > static_cast<unsigned>(map.bytes())) {
> - unsigned LastExistingColumn = map.byteToColumn(map.bytes());
> - unsigned AddedColumns = LastColumnModified-LastExistingColumn;
> - LastColumnModified = LastExistingColumn + AddedColumns;
> - } else {
> + if (LastColumnModified <= static_cast<unsigned>(map.bytes()))
> LastColumnModified = map.byteToColumn(LastColumnModified);
> - }
>
> if (LastColumnModified > FixItInsertionLine.size())
> FixItInsertionLine.resize(LastColumnModified, ' ');
> assert(HintColNo+I->CodeToInsert.size() <=
> FixItInsertionLine.size());
> std::copy(I->CodeToInsert.begin(), I->CodeToInsert.end(),
> FixItInsertionLine.begin() + HintColNo);
> +
> + PrevHintEnd = LastColumnModified;
> } else {
> FixItInsertionLine.clear();
> break;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120608/1c36463b/attachment.html>
More information about the cfe-commits
mailing list