Fix infinite-loop in unwrapped line parser.

Discovered when accidentally formatting a python file :-).

llvm-svn: 177527
This commit is contained in:
Daniel Jasper 2013-03-20 15:12:38 +00:00
parent 6120bac6e6
commit 1a32a61ad4
2 changed files with 4 additions and 1 deletions

View File

@ -684,7 +684,7 @@ void UnwrappedLineParser::parseRecord() {
// (this would still leave us with an ambiguity between template function
// and class declarations).
if (FormatTok.Tok.is(tok::colon) || FormatTok.Tok.is(tok::less)) {
while (FormatTok.Tok.isNot(tok::l_brace)) {
while (!eof() && FormatTok.Tok.isNot(tok::l_brace)) {
if (FormatTok.Tok.is(tok::semi))
return;
nextToken();

View File

@ -2544,6 +2544,9 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
" class X x;\n"
"else\n"
" f();\n");
// This is simply incomplete. Formatting is not important, but must not crash.
verifyFormat("class A:");
}
TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) {