File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3243,7 +3243,7 @@ void Tokenizer::simplifyLabelsCaseDefault()
32433243void Tokenizer::simplifyCaseRange ()
32443244{
32453245 for (Token* tok = list.front (); tok; tok = tok->next ()) {
3246- if (Token::Match (tok, " case %num% ... %num% :" )) {
3246+ if (Token::Match (tok, " case %num%|%char% ... %num%|%char % :" )) {
32473247 const MathLib::bigint start = MathLib::toLongNumber (tok->strAt (1 ));
32483248 MathLib::bigint end = MathLib::toLongNumber (tok->strAt (3 ));
32493249 end = std::min (start + 50 , end); // Simplify it 50 times at maximum
@@ -3257,23 +3257,6 @@ void Tokenizer::simplifyCaseRange()
32573257 tok->insertToken (" case" );
32583258 }
32593259 }
3260- } else if (Token::Match (tok, " case %char% ... %char% :" )) {
3261- const char start = tok->strAt (1 )[1 ];
3262- const char end = tok->strAt (3 )[1 ];
3263- if (start < end) {
3264- tok = tok->tokAt (2 );
3265- tok->str (" :" );
3266- tok->insertToken (" case" );
3267- for (char i = end - 1 ; i > start; i--) {
3268- tok->insertToken (" :" );
3269- if (i == ' \\ ' ) {
3270- tok->insertToken (std::string (" \'\\ " ) + i + ' \' ' );
3271- } else {
3272- tok->insertToken (std::string (1 , ' \' ' ) + i + ' \' ' );
3273- }
3274- tok->insertToken (" case" );
3275- }
3276- }
32773260 }
32783261 }
32793262}
Original file line number Diff line number Diff line change @@ -5400,10 +5400,13 @@ class TestTokenizer : public TestFixture {
54005400 ASSERT_EQUALS (" void f ( ) { switch ( x ) { case 4 ... 1 : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case 4 ... 1: } }" ));
54015401 tokenizeAndStringify (" void f() { switch(x) { case 1 ... 1000000: } }" ); // Do not run out of memory
54025402
5403- ASSERT_EQUALS (" void f ( ) { switch ( x ) { case 'a' : case 'b' : case 'c' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case 'a' ... 'c': } }" ));
5403+ ASSERT_EQUALS (" void f ( ) { switch ( x ) { case 'a' : case 98 : case 'c' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case 'a' ... 'c': } }" ));
54045404 ASSERT_EQUALS (" void f ( ) { switch ( x ) { case 'c' ... 'a' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case 'c' ... 'a': } }" ));
54055405
5406- ASSERT_EQUALS (" void f ( ) { switch ( x ) { case '[' : case '\\\\ ' : case ']' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case '[' ... ']': } }" ));
5406+ ASSERT_EQUALS (" void f ( ) { switch ( x ) { case '[' : case 92 : case ']' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case '[' ... ']': } }" ));
5407+
5408+ ASSERT_EQUALS (" void f ( ) { switch ( x ) { case '&' : case 39 : case '(' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case '&' ... '(': } }" ));
5409+ ASSERT_EQUALS (" void f ( ) { switch ( x ) { case '\\ x61' : case 98 : case '\\ x63' : ; } }" , tokenizeAndStringify (" void f() { switch(x) { case '\\ x61' ... '\\ x63': } }" ));
54075410 }
54085411
54095412 void simplifyEmptyNamespaces () {
You can’t perform that action at this time.
0 commit comments