In Lexer::getCharAndSizeSlow[NoWarn] if we come up against

\<newline><newline>

don't consume the second newline.

Thanks to David Blaikie for pointing out the crash!

llvm-svn: 147138
This commit is contained in:
Argyrios Kyrtzidis 2011-12-22 04:38:07 +00:00
parent 803acb3ff2
commit 8a26c4de64
2 changed files with 11 additions and 12 deletions

View File

@ -1172,8 +1172,11 @@ Slash:
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
if (Ptr[0] == '\0')
return '\\';
// If the char that we finally got was a \n, then we must have had
// something like \<newline><newline>. We don't want to consume the
// second newline.
if (*Ptr == '\n' || *Ptr == '\r' || *Ptr == '\0')
return ' ';
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlow(Ptr, Size, Tok);
@ -1226,8 +1229,11 @@ Slash:
Size += EscapedNewLineSize;
Ptr += EscapedNewLineSize;
if (Ptr[0] == '\0')
return '\\';
// If the char that we finally got was a \n, then we must have had
// something like \<newline><newline>. We don't want to consume the
// second newline.
if (*Ptr == '\n' || *Ptr == '\r' || *Ptr == '\0')
return ' ';
// Use slow version to accumulate a correct size field.
return getCharAndSizeSlowNoWarn(Ptr, Size, Features);
@ -1696,14 +1702,6 @@ bool Lexer::SkipBCPLComment(Token &Result, const char *CurPtr) {
break;
}
// If the char that we finally got was a \n, then we must have had something
// like \<newline><newline>. We don't want to have consumed the second
// newline, we want CurPtr, to end up pointing to it down below.
if (C == '\n' || C == '\r') {
--CurPtr;
C = 'x'; // doesn't matter what this is.
}
// If we read multiple characters, and one of those characters was a \r or
// \n, then we had an escaped newline within the comment. Emit diagnostic
// unless the next line is also a // comment.

View File

@ -8,3 +8,4 @@
>
// \