From eaa5a2b5e099bf29856bc88b03cd7c9d473f671d Mon Sep 17 00:00:00 2001 From: Seth Cantrell Date: Sat, 3 Nov 2012 21:21:14 +0000 Subject: [PATCH] fix bug in SourceColumnMap::startOfPreviousColumn git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167360 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/TextDiagnostic.cpp | 2 +- test/Misc/wrong-encoding2.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/Misc/wrong-encoding2.c diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index d622fb35f0..0eb3d60e0b 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -298,7 +298,7 @@ struct SourceColumnMap { /// \brief Map from a byte index to the previous byte which starts a column. int startOfPreviousColumn(int N) const { assert(0 < N && N < static_cast(m_columnToByte.size())); - while (byteToColumn(N--) == -1) {} + while (byteToColumn(--N) == -1) {} return N; } diff --git a/test/Misc/wrong-encoding2.c b/test/Misc/wrong-encoding2.c new file mode 100644 index 0000000000..43a0f4e900 --- /dev/null +++ b/test/Misc/wrong-encoding2.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -fmessage-length 100 %s 2>&1 | FileCheck -strict-whitespace %s +// REQUIRES: asserts + +int main() { + "É#x#p )6Ò)ѽŠ$ûž>U êhÑüÃö|Ÿ থϻgŸY|`?ò;;Æ¿VjÇ\\ù€‡ûݪW9úТ:̊O Eøېy?SKªy¦¹‡Øài&n"; +} + +// CHECK-NOT:Assertion -- 2.40.0