[cfe-commits] r167900 - in /cfe/trunk: lib/Lex/Lexer.cpp test/FixIt/fixit-newline-style.c
Eli Friedman
eli.friedman at gmail.com
Tue Nov 13 17:28:38 PST 2012
Author: efriedma
Date: Tue Nov 13 19:28:38 2012
New Revision: 167900
URL: http://llvm.org/viewvc/llvm-project?rev=167900&view=rev
Log:
Fix an assertion failure printing the unused-label fixit in files using CRLF line endings. <rdar://problem/12639047>.
Added:
cfe/trunk/test/FixIt/fixit-newline-style.c (with props)
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=167900&r1=167899&r2=167900&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Tue Nov 13 19:28:38 2012
@@ -1319,8 +1319,15 @@
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);
Added: cfe/trunk/test/FixIt/fixit-newline-style.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-newline-style.c?rev=167900&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/fixit-newline-style.c (added)
+++ cfe/trunk/test/FixIt/fixit-newline-style.c Tue Nov 13 19:28:38 2012
@@ -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
+// <rdar://problem/12639047>
+// CHECK: warning: unused label 'ddd'
+// CHECK-NEXT: {{^ ddd:}}
+// CHECK-NEXT: {{^ \^~~~$}}
+void f() {
+ ddd:
+ ;
+}
Propchange: cfe/trunk/test/FixIt/fixit-newline-style.c
------------------------------------------------------------------------------
svn:eol-style = CRLF
More information about the cfe-commits
mailing list