From: Eli Friedman Date: Wed, 14 Nov 2012 01:28:38 +0000 (+0000) Subject: Fix an assertion failure printing the unused-label fixit in files using CRLF line... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b699e619fef502b02264264e2545ebdce7b7d12d;p=platform%2Fupstream%2Fllvm.git Fix an assertion failure printing the unused-label fixit in files using CRLF line endings. . llvm-svn: 167900 --- diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index bf0883e..354a44d 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -1319,8 +1319,15 @@ SourceLocation Lexer::findLocationAfterToken(SourceLocation Loc, C = *(++TokenEnd); NumWhitespaceChars++; } - if (isVerticalWhitespace(C)) + + // Skip \r, \n, \r\n, or \n\r + if (C == '\n' || C == '\r') { + char PrevC = C; + C = *(++TokenEnd); NumWhitespaceChars++; + if ((C == '\n' || C == '\r') && C != PrevC) + NumWhitespaceChars++; + } } return TokenLoc.getLocWithOffset(Tok.getLength() + NumWhitespaceChars); diff --git a/clang/test/FixIt/fixit-newline-style.c b/clang/test/FixIt/fixit-newline-style.c new file mode 100644 index 0000000..c43eb37 --- /dev/null +++ b/clang/test/FixIt/fixit-newline-style.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -pedantic -Wunused-label -x c %s 2>&1 | FileCheck %s -strict-whitespace + +// This file intentionally uses a CRLF newline style +// +// CHECK: warning: unused label 'ddd' +// CHECK-NEXT: {{^ ddd:}} +// CHECK-NEXT: {{^ \^~~~$}} +void f() { + ddd: + ; +}