llvm.org GIT mirror llvm / 867c189
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 Dmitri Gribenko 6 years ago
2 changed file(s) with 13 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
469469 if (FixItInsertionLine.empty())
470470 return;
471471
472 for (size_t i = 0, e = FixItInsertionLine.size(), OutCol = 0; i != e; ++i) {
472 for (size_t i = 0, e = FixItInsertionLine.size(), OutCol = 0; i < e; ++i) {
473473 if (i >= LineContents.size() || LineContents[i] != '\t') {
474474 S << FixItInsertionLine[i];
475475 ++OutCol;
159159 Output);
160160 }
161161
162 TEST_F(SourceMgrTest, FixitForTab) {
163 setMainBuffer("aaa\tbbb\nccc ddd\n", "file.in");
164 printMessage(getLoc(3), SourceMgr::DK_Error, "message", None,
165 makeArrayRef(SMFixIt(getRange(3, 1), "zzz")));
166
167 EXPECT_EQ("file.in:1:4: error: message\n"
168 "aaa bbb\n"
169 " ^^^^^\n"
170 " zzz\n",
171 Output);
172 }
173