diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-07-12 08:20:49 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-07-12 08:20:49 +0000 |
commit | 29f90e804d12daaaba89b1830de27af0e69e5af4 (patch) | |
tree | c4774fb35573c1fd88c9f346ec9d7360e2c84cdd /clang/lib/Frontend/TextDiagnostic.cpp | |
parent | 9a2cb4245118aa246da073e77187cad55d9406d6 (diff) | |
download | bcm5719-llvm-29f90e804d12daaaba89b1830de27af0e69e5af4.tar.gz bcm5719-llvm-29f90e804d12daaaba89b1830de27af0e69e5af4.zip |
PR13312: Don't crash when printing a fixit that ends in a unicode character.
llvm-svn: 160112
Diffstat (limited to 'clang/lib/Frontend/TextDiagnostic.cpp')
-rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index ae1396672b7..306306d3ace 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -1160,8 +1160,13 @@ std::string TextDiagnostic::buildFixItInsertionLine( unsigned LastColumnModified = HintColNo + I->CodeToInsert.size(); - if (LastColumnModified <= static_cast<unsigned>(map.bytes())) + if (LastColumnModified <= static_cast<unsigned>(map.bytes())) { + // If we're right in the middle of a multibyte character skip to + // the end of it. + while (map.byteToColumn(LastColumnModified) == -1) + ++LastColumnModified; LastColumnModified = map.byteToColumn(LastColumnModified); + } if (LastColumnModified > FixItInsertionLine.size()) FixItInsertionLine.resize(LastColumnModified, ' '); |