mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
SourceMgr diagnotics printing: fix a bug where printing a fixit for a source
range that includes a tab character will cause out-of-bounds access to the fixit string. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191563 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
36fd952bc1
commit
867c189d89
@ -470,7 +470,7 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &S,
|
|||||||
if (FixItInsertionLine.empty())
|
if (FixItInsertionLine.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (size_t i = 0, e = FixItInsertionLine.size(), OutCol = 0; i != e; ++i) {
|
for (size_t i = 0, e = FixItInsertionLine.size(), OutCol = 0; i < e; ++i) {
|
||||||
if (i >= LineContents.size() || LineContents[i] != '\t') {
|
if (i >= LineContents.size() || LineContents[i] != '\t') {
|
||||||
S << FixItInsertionLine[i];
|
S << FixItInsertionLine[i];
|
||||||
++OutCol;
|
++OutCol;
|
||||||
|
@ -160,3 +160,15 @@ TEST_F(SourceMgrTest, BasicFixit) {
|
|||||||
Output);
|
Output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SourceMgrTest, FixitForTab) {
|
||||||
|
setMainBuffer("aaa\tbbb\nccc ddd\n", "file.in");
|
||||||
|
printMessage(getLoc(3), SourceMgr::DK_Error, "message", None,
|
||||||
|
makeArrayRef(SMFixIt(getRange(3, 1), "zzz")));
|
||||||
|
|
||||||
|
EXPECT_EQ("file.in:1:4: error: message\n"
|
||||||
|
"aaa bbb\n"
|
||||||
|
" ^^^^^\n"
|
||||||
|
" zzz\n",
|
||||||
|
Output);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user