[cfe-commits] r157372 - /cfe/trunk/lib/Frontend/TextDiagnostic.cpp

Seth Cantrell seth.cantrell at gmail.com
Wed May 23 22:14:44 PDT 2012


Author: socantre
Date: Thu May 24 00:14:44 2012
New Revision: 157372

URL: http://llvm.org/viewvc/llvm-project?rev=157372&view=rev
Log:
fix Bug 12924

http://llvm.org/bugs/show_bug.cgi?id=12924

This issue was that the source location was pointing to a
non-printable character and so CaretEnd was pointing one
_column_ past the caret but not one _character_ past the
caret. So the conversion between column and byte locations
wasn't working (because the conversion is only valid from
the first column or byte of a character).

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=157372&r1=157371&r2=157372&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Thu May 24 00:14:44 2012
@@ -333,6 +333,22 @@
     CaretEnd = std::max(FixItEnd, CaretEnd);
   }
 
+  // CaretEnd may have been set at the middle of a character
+  // If it's not at a character's first column then advance it past the current
+  //   character.
+  while (static_cast<int>(CaretEnd) < map.columns() &&
+         -1 == map.columnToByte(CaretEnd))
+    ++CaretEnd;
+
+  assert((static_cast<int>(CaretStart) > map.columns() ||
+          -1!=map.columnToByte(CaretStart)) &&
+         "CaretStart must not point to a column in the middle of a source"
+         " line character");
+  assert((static_cast<int>(CaretEnd) > map.columns() ||
+          -1!=map.columnToByte(CaretEnd)) &&
+         "CaretEnd must not point to a column in the middle of a source line"
+         " character");
+
   // CaretLine[CaretStart, CaretEnd) contains all of the interesting
   // parts of the caret line. While this slice is smaller than the
   // number of columns we have, try to grow the slice to encompass





More information about the cfe-commits mailing list