diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index fbcd8f980c1..d4b94f8cd5d 100644 --- a/lib/Support/SourceMgr.cpp +++ b/lib/Support/SourceMgr.cpp @@ -470,7 +470,7 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &S, if (FixItInsertionLine.empty()) 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') { S << FixItInsertionLine[i]; ++OutCol; diff --git a/unittests/Support/SourceMgrTest.cpp b/unittests/Support/SourceMgrTest.cpp index 9bc0cf67b75..2b69fe98444 100644 --- a/unittests/Support/SourceMgrTest.cpp +++ b/unittests/Support/SourceMgrTest.cpp @@ -160,3 +160,15 @@ TEST_F(SourceMgrTest, BasicFixit) { 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); +} +