aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/SourceMgrTest.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2013-09-27 21:24:36 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2013-09-27 21:24:36 +0000
commit78fe2ba3ba92c25b4b1ae42027081af16f0ddf06 (patch)
treefbd5beb795fa828e3335d6203b500f91531ba611 /llvm/unittests/Support/SourceMgrTest.cpp
parent30e9b6c47d8891b68f8cea1125987e4a0b8b6a82 (diff)
downloadllvm-78fe2ba3ba92c25b4b1ae42027081af16f0ddf06.zip
llvm-78fe2ba3ba92c25b4b1ae42027081af16f0ddf06.tar.gz
llvm-78fe2ba3ba92c25b4b1ae42027081af16f0ddf06.tar.bz2
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. llvm-svn: 191563
Diffstat (limited to 'llvm/unittests/Support/SourceMgrTest.cpp')
-rw-r--r--llvm/unittests/Support/SourceMgrTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/unittests/Support/SourceMgrTest.cpp b/llvm/unittests/Support/SourceMgrTest.cpp
index 9bc0cf6..2b69fe9 100644
--- a/llvm/unittests/Support/SourceMgrTest.cpp
+++ b/llvm/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);
+}
+