1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[AsmParser] Avoid recursing when lexing ';'. NFC.

This should prevent stack overflows in non-optimized builds on
.ll files with lots of consecutive commented-out lines.

Instead of recursing into LexToken(), continue into a 'while (true)'.

llvm-svn: 287170
This commit is contained in:
Ahmed Bougacha 2016-11-16 22:25:05 +00:00
parent 040d69db42
commit 8d7afbaec0

View File

@ -180,6 +180,7 @@ int LLLexer::getNextChar() {
}
lltok::Kind LLLexer::LexToken() {
while (true) {
TokStart = CurPtr;
int CurChar = getNextChar();
@ -197,7 +198,7 @@ lltok::Kind LLLexer::LexToken() {
case '\n':
case '\r':
// Ignore whitespace.
return LexToken();
continue;
case '+': return LexPositive();
case '@': return LexAt();
case '$': return LexDollar();
@ -216,7 +217,7 @@ lltok::Kind LLLexer::LexToken() {
return lltok::Error;
case ';':
SkipLineComment();
return LexToken();
continue;
case '!': return LexExclaim();
case '#': return LexHash();
case '0': case '1': case '2': case '3': case '4':
@ -236,6 +237,7 @@ lltok::Kind LLLexer::LexToken() {
case '*': return lltok::star;
case '|': return lltok::bar;
}
}
}
void LLLexer::SkipLineComment() {