Limit the number of cases created by Tokenizer::simplifyCaseRange().
This commit is contained in:
parent
1fe1d7ea4a
commit
95a0c0f14c
|
@ -2386,6 +2386,7 @@ void Tokenizer::simplifyCaseRange()
|
|||
if (Token::Match(tok, "case %num% . . . %num% :")) {
|
||||
MathLib::bigint start = MathLib::toLongNumber(tok->strAt(1));
|
||||
MathLib::bigint end = MathLib::toLongNumber(tok->strAt(5));
|
||||
end = std::min(start + 50, end); // Simplify it 50 times at maximum
|
||||
if (start < end) {
|
||||
tok = tok->tokAt(2);
|
||||
tok->str(":");
|
||||
|
|
|
@ -7996,6 +7996,7 @@ private:
|
|||
void simplifyCaseRange() {
|
||||
ASSERT_EQUALS("void f ( ) { case 1 : ; case 2 : ; case 3 : ; case 4 : ; }", tokenizeAndStringify("void f() { case 1 ... 4: }"));
|
||||
ASSERT_EQUALS("void f ( ) { case 4 . . . 1 : ; }", tokenizeAndStringify("void f() { case 4 ... 1: }"));
|
||||
tokenizeAndStringify("void f() { case 1 ... 1000000: }"); // Do not run out of memory
|
||||
|
||||
ASSERT_EQUALS("void f ( ) { case 'a' : ; case 'b' : ; case 'c' : ; }", tokenizeAndStringify("void f() { case 'a' ... 'c': }"));
|
||||
ASSERT_EQUALS("void f ( ) { case 'c' . . . 'a' : ; }", tokenizeAndStringify("void f() { case 'c' ... 'a': }"));
|
||||
|
|
Loading…
Reference in New Issue