@@ -52,8 +52,6 @@ class TestSimplifyTokens : public TestFixture {
5252 settings_std.checkUnusedTemplates = true ;
5353 settings_windows.checkUnusedTemplates = true ;
5454
55- TEST_CASE (test1); // array access. replace "*(p+1)" => "p[1]"
56-
5755 TEST_CASE (cast);
5856 TEST_CASE (iftruefalse);
5957
@@ -162,12 +160,6 @@ class TestSimplifyTokens : public TestFixture {
162160 // ticket #3140
163161 TEST_CASE (while0for);
164162
165- // remove "std::" on some standard functions
166- TEST_CASE (removestd);
167-
168- // Tokenizer::simplifyReference
169- TEST_CASE (simplifyReference);
170-
171163 // x = realloc(y,0); => free(y);x=0;
172164 TEST_CASE (simplifyRealloc);
173165
@@ -212,7 +204,6 @@ class TestSimplifyTokens : public TestFixture {
212204
213205 TEST_CASE (undefinedSizeArray);
214206
215- TEST_CASE (simplifyArrayAddress); // Replace "&str[num]" => "(str + num)"
216207 TEST_CASE (simplifyOverride); // ticket #5069
217208 TEST_CASE (simplifyNestedNamespace);
218209 TEST_CASE (simplifyNamespaceAliases1);
@@ -432,52 +423,6 @@ class TestSimplifyTokens : public TestFixture {
432423 }
433424
434425
435- void test1 () {
436- // "&p[1]" => "p+1"
437- /*
438- ASSERT_EQUALS("; x = p + n ;", tok("; x = & p [ n ] ;"));
439- ASSERT_EQUALS("; x = ( p + n ) [ m ] ;", tok("; x = & p [ n ] [ m ] ;"));
440- ASSERT_EQUALS("; x = y & p [ n ] ;", tok("; x = y & p [ n ] ;"));
441- ASSERT_EQUALS("; x = 10 & p [ n ] ;", tok("; x = 10 & p [ n ] ;"));
442- ASSERT_EQUALS("; x = y [ 10 ] & p [ n ] ;", tok("; x = y [ 10 ] & p [ n ] ;"));
443- ASSERT_EQUALS("; x = ( a + m ) & p [ n ] ;", tok("; x = ( a + m ) & p [ n ] ;"));
444- */
445- // "*(p+1)" => "p[1]"
446- ASSERT_EQUALS (" ; x = p [ 1 ] ;" , tok (" ; x = * ( p + 1 ) ;" ));
447- ASSERT_EQUALS (" ; x = p [ 0xA ] ;" , tok (" ; x = * ( p + 0xA ) ;" ));
448- ASSERT_EQUALS (" ; x = p [ n ] ;" , tok (" ; x = * ( p + n ) ;" ));
449- ASSERT_EQUALS (" ; x = y * ( p + n ) ;" , tok (" ; x = y * ( p + n ) ;" ));
450- ASSERT_EQUALS (" ; x = 10 * ( p + n ) ;" , tok (" ; x = 10 * ( p + n ) ;" ));
451- ASSERT_EQUALS (" ; x = y [ 10 ] * ( p + n ) ;" , tok (" ; x = y [ 10 ] * ( p + n ) ;" ));
452- ASSERT_EQUALS (" ; x = ( a + m ) * ( p + n ) ;" , tok (" ; x = ( a + m ) * ( p + n ) ;" ));
453-
454- // "*(p-1)" => "p[-1]" and "*(p-n)" => "p[-n]"
455- ASSERT_EQUALS (" ; x = p [ -1 ] ;" , tok (" ; x = *(p - 1);" ));
456- ASSERT_EQUALS (" ; x = p [ -0xA ] ;" , tok (" ; x = *(p - 0xA);" ));
457- ASSERT_EQUALS (" ; x = p [ - n ] ;" , tok (" ; x = *(p - n);" ));
458- ASSERT_EQUALS (" ; x = y * ( p - 1 ) ;" , tok (" ; x = y * (p - 1);" ));
459- ASSERT_EQUALS (" ; x = 10 * ( p - 1 ) ;" , tok (" ; x = 10 * (p - 1);" ));
460- ASSERT_EQUALS (" ; x = y [ 10 ] * ( p - 1 ) ;" , tok (" ; x = y[10] * (p - 1);" ));
461- ASSERT_EQUALS (" ; x = ( a - m ) * ( p - n ) ;" , tok (" ; x = (a - m) * (p - n);" ));
462-
463- // Test that the array-index simplification is not applied when there's no dereference:
464- // "(x-y)" => "(x-y)" and "(x+y)" => "(x+y)"
465- ASSERT_EQUALS (" ; a = b * ( x - y ) ;" , tok (" ; a = b * (x - y);" ));
466- ASSERT_EQUALS (" ; a = b * x [ - y ] ;" , tok (" ; a = b * *(x - y);" ));
467- ASSERT_EQUALS (" ; a *= ( x - y ) ;" , tok (" ; a *= (x - y);" ));
468- ASSERT_EQUALS (" ; z = a ++ * ( x - y ) ;" , tok (" ; z = a++ * (x - y);" ));
469- ASSERT_EQUALS (" ; z = a ++ * ( x + y ) ;" , tok (" ; z = a++ * (x + y);" ));
470- ASSERT_EQUALS (" ; z = a -- * ( x - y ) ;" , tok (" ; z = a-- * (x - y);" ));
471- ASSERT_EQUALS (" ; z = a -- * ( x + y ) ;" , tok (" ; z = a-- * (x + y);" ));
472- ASSERT_EQUALS (" ; z = 'a' * ( x - y ) ;" , tok (" ; z = 'a' * (x - y);" ));
473- ASSERT_EQUALS (" ; z = \" a\" * ( x - y ) ;" , tok (" ; z = \" a\" * (x - y);" ));
474- ASSERT_EQUALS (" ; z = 'a' * ( x + y ) ;" , tok (" ; z = 'a' * (x + y);" ));
475- ASSERT_EQUALS (" ; z = \" a\" * ( x + y ) ;" , tok (" ; z = \" a\" * (x + y);" ));
476- ASSERT_EQUALS (" ; z = foo ( ) * ( x + y ) ;" , tok (" ; z = foo() * (x + y);" ));
477- }
478-
479-
480-
481426 void simplifyMathFunctions_erfc () {
482427 // verify erfc(), erfcf(), erfcl() - simplifcation
483428 const char code_erfc[] =" void f(int x) {\n "
@@ -4194,25 +4139,6 @@ class TestSimplifyTokens : public TestFixture {
41944139 ASSERT_EQUALS (" void f ( ) { int i ; for ( i = 0 ; i < 0 ; ++ i ) { } return i ; }" , tok (" void f() { int i; for (i=0;i<0;++i){ dostuff(); } return i; }" ));
41954140 }
41964141
4197- void removestd () {
4198- ASSERT_EQUALS (" ; strcpy ( a , b ) ;" , tok (" ; std::strcpy(a,b);" ));
4199- ASSERT_EQUALS (" ; strcat ( a , b ) ;" , tok (" ; std::strcat(a,b);" ));
4200- ASSERT_EQUALS (" ; strncpy ( a , b , 10 ) ;" , tok (" ; std::strncpy(a,b,10);" ));
4201- ASSERT_EQUALS (" ; strncat ( a , b , 10 ) ;" , tok (" ; std::strncat(a,b,10);" ));
4202- ASSERT_EQUALS (" ; free ( p ) ;" , tok (" ; std::free(p);" ));
4203- ASSERT_EQUALS (" ; malloc ( 10 ) ;" , tok (" ; std::malloc(10);" ));
4204- }
4205-
4206- void simplifyReference () {
4207- ASSERT_EQUALS (" void f ( ) { int a ; a ++ ; }" ,
4208- tok (" void f() { int a; int &b(a); b++; }" ));
4209- ASSERT_EQUALS (" void f ( ) { int a ; a ++ ; }" ,
4210- tok (" void f() { int a; int &b = a; b++; }" ));
4211-
4212- ASSERT_EQUALS (" void test ( ) { c . f ( 7 ) ; }" ,
4213- tok (" void test() { c.f(7); T3 &t3 = c; }" )); // #6133
4214- }
4215-
42164142 void simplifyRealloc () {
42174143 ASSERT_EQUALS (" ; free ( p ) ; p = 0 ;" , tok (" ; p = realloc(p, 0);" ));
42184144 ASSERT_EQUALS (" ; p = malloc ( 100 ) ;" , tok (" ; p = realloc(0, 100);" ));
@@ -4838,17 +4764,6 @@ class TestSimplifyTokens : public TestFixture {
48384764 ASSERT_EQUALS (" int x [ 13 ] = { [ 11 ] = 2 , [ 12 ] = 3 } ;" , tok (" int x[] = {[11]=2, [12]=3};" ));
48394765 }
48404766
4841- void simplifyArrayAddress () { // ticket #3304
4842- const char code[] = " void foo() {\n "
4843- " int a[10];\n "
4844- " memset(&a[4], 0, 20*sizeof(int));\n "
4845- " }" ;
4846- ASSERT_EQUALS (" void foo ( ) {"
4847- " int a [ 10 ] ;"
4848- " memset ( a + 4 , 0 , 80 ) ;"
4849- " }" , tok (code, true ));
4850- }
4851-
48524767 void test_4881 () {
48534768 const char code[] = " int evallex() {\n "
48544769 " int c, t;\n "
0 commit comments