Fix an assertion failure printing the unused-label fixit in files using CRLF line endings. <rdar://problem/12639047>.

llvm-svn: 167900
This commit is contained in:
Eli Friedman 2012-11-14 01:28:38 +00:00
parent 41ae3288fd
commit b699e619fe
2 changed files with 19 additions and 1 deletions

View File

@ -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);

View File

@ -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:
;
}