diff options
| author | Seth Cantrell <seth.cantrell@gmail.com> | 2012-05-24 05:14:44 +0000 |
|---|---|---|
| committer | Seth Cantrell <seth.cantrell@gmail.com> | 2012-05-24 05:14:44 +0000 |
| commit | ac6fb8f9f602fa74cf16e43520c12a302627c873 (patch) | |
| tree | 1e4212985325a25bfcf74f98b31d73d315bf4de0 /clang/lib | |
| parent | 2edc84ee60453dea192e609619c522216eb9073b (diff) | |
| download | bcm5719-llvm-ac6fb8f9f602fa74cf16e43520c12a302627c873.tar.gz bcm5719-llvm-ac6fb8f9f602fa74cf16e43520c12a302627c873.zip | |
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).
llvm-svn: 157372
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index 454018b2969..663dc96af7d 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -333,6 +333,22 @@ static void selectInterestingSourceRegion(std::string &SourceLine, 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 |

