Tokenizer: Remove redundant semi colons
This commit is contained in:
parent
79583ee45d
commit
a38b14d582
|
@ -2128,6 +2128,15 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
|
|
||||||
_tokens->assignProgressValues();
|
_tokens->assignProgressValues();
|
||||||
|
|
||||||
|
// remove redundant semicolon:
|
||||||
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
|
{
|
||||||
|
if (tok->str() == "(")
|
||||||
|
tok = tok->link();
|
||||||
|
while (Token::simpleMatch(tok, "; ;"))
|
||||||
|
tok->deleteNext();
|
||||||
|
}
|
||||||
|
|
||||||
return validate();
|
return validate();
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -3945,6 +3954,16 @@ bool Tokenizer::simplifyTokenList()
|
||||||
|
|
||||||
_tokens->assignProgressValues();
|
_tokens->assignProgressValues();
|
||||||
|
|
||||||
|
// remove redundant semicolon:
|
||||||
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
|
{
|
||||||
|
if (tok->str() == "(")
|
||||||
|
tok = tok->link();
|
||||||
|
while (Token::simpleMatch(tok, "; ;"))
|
||||||
|
tok->deleteNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return validate();
|
return validate();
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -289,6 +289,8 @@ private:
|
||||||
TEST_CASE(simplifyCallingConvention);
|
TEST_CASE(simplifyCallingConvention);
|
||||||
|
|
||||||
TEST_CASE(simplifyFunctorCall);
|
TEST_CASE(simplifyFunctorCall);
|
||||||
|
|
||||||
|
TEST_CASE(redundant_semicolon);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tok(const char code[], bool simplify = true)
|
std::string tok(const char code[], bool simplify = true)
|
||||||
|
@ -414,7 +416,7 @@ private:
|
||||||
|
|
||||||
{
|
{
|
||||||
const char code1[] = "void f() { int a; bool use = true; if( use ) a=0; else if( bb ) a=1; else if( cc ) a=33; else { gg = 0; } int c=1; }";
|
const char code1[] = "void f() { int a; bool use = true; if( use ) a=0; else if( bb ) a=1; else if( cc ) a=33; else { gg = 0; } int c=1; }";
|
||||||
const char code2[] = "void f ( ) { ; ; ; { ; } ; ; }";
|
const char code2[] = "void f ( ) { ; { ; } ; }";
|
||||||
ASSERT_EQUALS(code2, tok(code1));
|
ASSERT_EQUALS(code2, tok(code1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,8 +673,8 @@ private:
|
||||||
" if (c>0) { c++; }\n"
|
" if (c>0) { c++; }\n"
|
||||||
" c++;\n"
|
" c++;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
TODO_ASSERT_EQUALS("void f ( int & c ) { c = 3 ; ; { ; } ; }", tok(code));
|
TODO_ASSERT_EQUALS("void f ( int & c ) { c = 3 ; { ; } ; }", tok(code));
|
||||||
ASSERT_EQUALS("void f ( int & c ) { c = 1 ; ; { c ++ ; } c ++ ; }", tok(code));
|
ASSERT_EQUALS("void f ( int & c ) { c = 1 ; { c ++ ; } c ++ ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -686,8 +688,8 @@ private:
|
||||||
" if (c>0) { ++c; }\n"
|
" if (c>0) { ++c; }\n"
|
||||||
" ++c;\n"
|
" ++c;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
TODO_ASSERT_EQUALS("void f ( int & c ) { c = 3 ; ; { ; } ; }", tok(code));
|
TODO_ASSERT_EQUALS("void f ( int & c ) { c = 3 ; { ; } ; }", tok(code));
|
||||||
ASSERT_EQUALS("void f ( int & c ) { c = 1 ; ; { ++ c ; } ++ c ; }", tok(code));
|
ASSERT_EQUALS("void f ( int & c ) { c = 1 ; { ++ c ; } ++ c ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1457,7 +1459,7 @@ private:
|
||||||
const char code[] = "template <classname T> class Fred { T a; };\n"
|
const char code[] = "template <classname T> class Fred { T a; };\n"
|
||||||
"Fred<int> fred;";
|
"Fred<int> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"Fred<int> fred ; "
|
"Fred<int> fred ; "
|
||||||
"class Fred<int> { int a ; }");
|
"class Fred<int> { int a ; }");
|
||||||
|
|
||||||
|
@ -1469,7 +1471,7 @@ private:
|
||||||
const char code[] = "template <classname T, int sz> class Fred { T data[sz]; };\n"
|
const char code[] = "template <classname T, int sz> class Fred { T data[sz]; };\n"
|
||||||
"Fred<float,4> fred;";
|
"Fred<float,4> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"Fred<float,4> fred ; "
|
"Fred<float,4> fred ; "
|
||||||
"class Fred<float,4> { float data [ 4 ] ; }");
|
"class Fred<float,4> { float data [ 4 ] ; }");
|
||||||
|
|
||||||
|
@ -1481,7 +1483,7 @@ private:
|
||||||
const char code[] = "template <classname T> class Fred { Fred(); };\n"
|
const char code[] = "template <classname T> class Fred { Fred(); };\n"
|
||||||
"Fred<float> fred;";
|
"Fred<float> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"Fred<float> fred ; "
|
"Fred<float> fred ; "
|
||||||
"class Fred<float> { Fred<float> ( ) ; }");
|
"class Fred<float> { Fred<float> ( ) ; }");
|
||||||
|
|
||||||
|
@ -1494,8 +1496,7 @@ private:
|
||||||
"template <classname T> Fred<T>::Fred() { }\n"
|
"template <classname T> Fred<T>::Fred() { }\n"
|
||||||
"Fred<float> fred;";
|
"Fred<float> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"; "
|
|
||||||
"Fred<float> fred ; "
|
"Fred<float> fred ; "
|
||||||
"class Fred<float> { } "
|
"class Fred<float> { } "
|
||||||
"Fred<float> :: Fred<float> ( ) { }");
|
"Fred<float> :: Fred<float> ( ) { }");
|
||||||
|
@ -1509,7 +1510,7 @@ private:
|
||||||
"Fred<float> fred1;\n"
|
"Fred<float> fred1;\n"
|
||||||
"Fred<float> fred2;";
|
"Fred<float> fred2;";
|
||||||
|
|
||||||
const std::string expected("; ;"
|
const std::string expected(";"
|
||||||
" Fred<float> fred1 ;"
|
" Fred<float> fred1 ;"
|
||||||
" Fred<float> fred2 ;"
|
" Fred<float> fred2 ;"
|
||||||
" class Fred<float> { }");
|
" class Fred<float> { }");
|
||||||
|
@ -1529,7 +1530,7 @@ private:
|
||||||
"\n"
|
"\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
|
|
||||||
const std::string expected("; ;");
|
const std::string expected(";");
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
@ -1545,7 +1546,7 @@ private:
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"int main ( ) { "
|
"int main ( ) { "
|
||||||
"std :: vector < int > v ; "
|
"std :: vector < int > v ; "
|
||||||
"v . push_back ( 4 ) ; "
|
"v . push_back ( 4 ) ; "
|
||||||
|
@ -1566,7 +1567,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
|
|
||||||
const std::string expected("; ;");
|
const std::string expected(";");
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
@ -1592,7 +1593,7 @@ private:
|
||||||
"\n"
|
"\n"
|
||||||
"template<typename T> inline B<T> h() { return B<T>(); }\n";
|
"template<typename T> inline B<T> h() { return B<T>(); }\n";
|
||||||
|
|
||||||
ASSERT_EQUALS("; ; ; ; ; ; ;", sizeof_(code));
|
ASSERT_EQUALS(";", sizeof_(code));
|
||||||
|
|
||||||
ASSERT_EQUALS("class A { ; } ;", sizeof_("class A{ template<typename T> int foo(T d);};"));
|
ASSERT_EQUALS("class A { ; } ;", sizeof_("class A{ template<typename T> int foo(T d);};"));
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1614,7 @@ private:
|
||||||
"} ;\n";
|
"} ;\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
std::string expected("; ; void f ( ) { A<int> a ; } ; ; class A<int> { }");
|
std::string expected("; void f ( ) { A<int> a ; } ; class A<int> { }");
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
@ -1670,7 +1671,7 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"void f ( ) "
|
"void f ( ) "
|
||||||
"{"
|
"{"
|
||||||
" A<12,12,11> a ; "
|
" A<12,12,11> a ; "
|
||||||
|
@ -1799,7 +1800,7 @@ private:
|
||||||
const char code[] = "template <class T> class foo { T a; };\n"
|
const char code[] = "template <class T> class foo { T a; };\n"
|
||||||
"foo<int> *f;";
|
"foo<int> *f;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"foo<int> * f ; "
|
"foo<int> * f ; "
|
||||||
"class foo<int> { int a ; }");
|
"class foo<int> { int a ; }");
|
||||||
|
|
||||||
|
@ -1842,7 +1843,7 @@ private:
|
||||||
"A<int> a;\n";
|
"A<int> a;\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; A<int> a ; "
|
const std::string expected("; A<int> a ; "
|
||||||
"class A<int> { public: ~ A<int> ( ) ; } "
|
"class A<int> { public: ~ A<int> ( ) ; } "
|
||||||
"A<int> :: ~ A<int> ( ) { }");
|
"A<int> :: ~ A<int> ( ) { }");
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
@ -1854,7 +1855,7 @@ private:
|
||||||
const char code[] = "template <classname T> struct Fred { T a; };\n"
|
const char code[] = "template <classname T> struct Fred { T a; };\n"
|
||||||
"Fred<int> fred;";
|
"Fred<int> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"Fred<int> fred ; "
|
"Fred<int> fred ; "
|
||||||
"struct Fred<int> { int a ; }");
|
"struct Fred<int> { int a ; }");
|
||||||
|
|
||||||
|
@ -1865,7 +1866,7 @@ private:
|
||||||
const char code[] = "template <classname T, int sz> struct Fred { T data[sz]; };\n"
|
const char code[] = "template <classname T, int sz> struct Fred { T data[sz]; };\n"
|
||||||
"Fred<float,4> fred;";
|
"Fred<float,4> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"Fred<float,4> fred ; "
|
"Fred<float,4> fred ; "
|
||||||
"struct Fred<float,4> { float data [ 4 ] ; }");
|
"struct Fred<float,4> { float data [ 4 ] ; }");
|
||||||
|
|
||||||
|
@ -1876,7 +1877,7 @@ private:
|
||||||
const char code[] = "template <classname T> struct Fred { Fred(); };\n"
|
const char code[] = "template <classname T> struct Fred { Fred(); };\n"
|
||||||
"Fred<float> fred;";
|
"Fred<float> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"Fred<float> fred ; "
|
"Fred<float> fred ; "
|
||||||
"struct Fred<float> { Fred<float> ( ) ; }");
|
"struct Fred<float> { Fred<float> ( ) ; }");
|
||||||
|
|
||||||
|
@ -1888,8 +1889,7 @@ private:
|
||||||
"template <classname T> Fred<T>::Fred() { }\n"
|
"template <classname T> Fred<T>::Fred() { }\n"
|
||||||
"Fred<float> fred;";
|
"Fred<float> fred;";
|
||||||
|
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"; "
|
|
||||||
"Fred<float> fred ; "
|
"Fred<float> fred ; "
|
||||||
"struct Fred<float> { } "
|
"struct Fred<float> { } "
|
||||||
"Fred<float> :: Fred<float> ( ) { }");
|
"Fred<float> :: Fred<float> ( ) { }");
|
||||||
|
@ -1902,7 +1902,7 @@ private:
|
||||||
"Fred<float> fred1;\n"
|
"Fred<float> fred1;\n"
|
||||||
"Fred<float> fred2;";
|
"Fred<float> fred2;";
|
||||||
|
|
||||||
const std::string expected("; ;"
|
const std::string expected(";"
|
||||||
" Fred<float> fred1 ;"
|
" Fred<float> fred1 ;"
|
||||||
" Fred<float> fred2 ;"
|
" Fred<float> fred2 ;"
|
||||||
" struct Fred<float> { }");
|
" struct Fred<float> { }");
|
||||||
|
@ -1931,7 +1931,7 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"void f ( ) "
|
"void f ( ) "
|
||||||
"{"
|
"{"
|
||||||
" A<int,2> a1 ;"
|
" A<int,2> a1 ;"
|
||||||
|
@ -1955,7 +1955,7 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; "
|
const std::string expected("; "
|
||||||
"void f ( ) "
|
"void f ( ) "
|
||||||
"{"
|
"{"
|
||||||
" A<int,3,2> a1 ;"
|
" A<int,3,2> a1 ;"
|
||||||
|
@ -2453,7 +2453,7 @@ private:
|
||||||
" bool x = false;\n"
|
" bool x = false;\n"
|
||||||
" int b = x ? 44 : 3;\n"
|
" int b = x ? 44 : 3;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS("void f ( ) { ; ; ; ; }", tok(code));
|
ASSERT_EQUALS("void f ( ) { ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2843,7 +2843,6 @@ private:
|
||||||
"; "
|
"; "
|
||||||
"void foo ( ) { } "
|
"void foo ( ) { } "
|
||||||
"} ; "
|
"} ; "
|
||||||
"; "
|
|
||||||
"int main ( ) "
|
"int main ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"A a ; "
|
"A a ; "
|
||||||
|
@ -2866,7 +2865,6 @@ private:
|
||||||
|
|
||||||
const std::string expected =
|
const std::string expected =
|
||||||
"class A ; "
|
"class A ; "
|
||||||
"; "
|
|
||||||
"class A "
|
"class A "
|
||||||
"{ "
|
"{ "
|
||||||
"public: "
|
"public: "
|
||||||
|
@ -2893,7 +2891,6 @@ private:
|
||||||
|
|
||||||
const std::string expected =
|
const std::string expected =
|
||||||
"class A { } ; "
|
"class A { } ; "
|
||||||
"; "
|
|
||||||
"wchar_t foo ( ) "
|
"wchar_t foo ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"; "
|
"; "
|
||||||
|
@ -2919,7 +2916,6 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
const std::string expected =
|
const std::string expected =
|
||||||
"; "
|
|
||||||
"; "
|
"; "
|
||||||
"void f ( ) "
|
"void f ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
|
@ -2998,13 +2994,6 @@ private:
|
||||||
"RCUINT trcui;";
|
"RCUINT trcui;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
"; "
|
||||||
"int ti ; "
|
"int ti ; "
|
||||||
"unsigned int tui ; "
|
"unsigned int tui ; "
|
||||||
|
@ -3033,9 +3022,9 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
"; "
|
||||||
"struct t { int a ; } ; ; "
|
"struct t { int a ; } ; "
|
||||||
"struct U { int a ; } ; ; "
|
"struct U { int a ; } ; "
|
||||||
"struct Unnamed0 { int a ; } ; ; "
|
"struct Unnamed0 { int a ; } ; "
|
||||||
"struct s s ; "
|
"struct s s ; "
|
||||||
"struct s * ps ; "
|
"struct s * ps ; "
|
||||||
"struct t t ; "
|
"struct t t ; "
|
||||||
|
@ -3061,9 +3050,9 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
"; "
|
||||||
"union t { int a ; float b ; } ; ; "
|
"union t { int a ; float b ; } ; "
|
||||||
"union U { int a ; float b ; } ; ; "
|
"union U { int a ; float b ; } ; "
|
||||||
"union Unnamed1 { int a ; float b ; } ; ; "
|
"union Unnamed1 { int a ; float b ; } ; "
|
||||||
"union s s ; "
|
"union s s ; "
|
||||||
"union s * ps ; "
|
"union s * ps ; "
|
||||||
"union t t ; "
|
"union t t ; "
|
||||||
|
@ -3082,8 +3071,7 @@ private:
|
||||||
"XYZ e2;";
|
"XYZ e2;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; ; "
|
"; "
|
||||||
"; ; "
|
|
||||||
"int e1 ; "
|
"int e1 ; "
|
||||||
"int e2 ;";
|
"int e2 ;";
|
||||||
|
|
||||||
|
@ -3102,9 +3090,6 @@ private:
|
||||||
"IntListIterator iter;";
|
"IntListIterator iter;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
"; "
|
||||||
"vector < int > v1 ; "
|
"vector < int > v1 ; "
|
||||||
"std :: vector < int > v2 ; "
|
"std :: vector < int > v2 ; "
|
||||||
|
@ -3247,7 +3232,7 @@ private:
|
||||||
"C c;";
|
"C c;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"struct A { } ; ; "
|
"struct A { } ; "
|
||||||
"struct A a ; "
|
"struct A a ; "
|
||||||
"struct A * b ; "
|
"struct A * b ; "
|
||||||
"struct A * * c ;";
|
"struct A * * c ;";
|
||||||
|
@ -3261,7 +3246,7 @@ private:
|
||||||
"B b;";
|
"B b;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"struct A { } ; ; "
|
"struct A { } ; "
|
||||||
"struct A a ; "
|
"struct A a ; "
|
||||||
"struct A * * * * * * * * * b ;";
|
"struct A * * * * * * * * * b ;";
|
||||||
|
|
||||||
|
@ -3275,7 +3260,7 @@ private:
|
||||||
"C c;";
|
"C c;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"struct Unnamed2 { } ; ; "
|
"struct Unnamed2 { } ; "
|
||||||
"struct Unnamed2 * * * * * * * * * * a ; "
|
"struct Unnamed2 * * * * * * * * * * a ; "
|
||||||
"struct Unnamed2 * b ; "
|
"struct Unnamed2 * b ; "
|
||||||
"struct Unnamed2 c ;";
|
"struct Unnamed2 c ;";
|
||||||
|
@ -3573,9 +3558,6 @@ private:
|
||||||
"int_array ia;";
|
"int_array ia;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
"; "
|
||||||
"int a [ ice_or < is_int < int > :: value , is_int < UDT > :: value > :: value ? 1 : - 1 ] ; "
|
"int a [ ice_or < is_int < int > :: value , is_int < UDT > :: value > :: value ? 1 : - 1 ] ; "
|
||||||
"int a1 [ N ] ; "
|
"int a1 [ N ] ; "
|
||||||
|
@ -3596,8 +3578,6 @@ private:
|
||||||
"int_list_array ila;";
|
"int_list_array ila;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
"; "
|
||||||
":: std :: list < int > il ; "
|
":: std :: list < int > il ; "
|
||||||
":: std :: list < int > :: iterator ili ; "
|
":: std :: list < int > :: iterator ili ; "
|
||||||
|
@ -3665,8 +3645,6 @@ private:
|
||||||
"LPCSTR ccp;";
|
"LPCSTR ccp;";
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
|
||||||
"; "
|
|
||||||
"; "
|
"; "
|
||||||
"char c ; "
|
"char c ; "
|
||||||
"char * cp ; "
|
"char * cp ; "
|
||||||
|
@ -3748,7 +3726,6 @@ private:
|
||||||
"}";
|
"}";
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class X { } ; "
|
"class X { } ; "
|
||||||
"; "
|
|
||||||
"int main ( ) "
|
"int main ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"X ( * * Foo ) ( const X & ) = new X ( * ) ( const X & ) [ 2 ] ; "
|
"X ( * * Foo ) ( const X & ) = new X ( * ) ( const X & ) [ 2 ] ; "
|
||||||
|
@ -3830,7 +3807,7 @@ private:
|
||||||
"float fun2 ( float a ) { float A ; A = a ++ ; return A ; } "
|
"float fun2 ( float a ) { float A ; A = a ++ ; return A ; } "
|
||||||
"float fun3 ( int a ) "
|
"float fun3 ( int a ) "
|
||||||
"{ "
|
"{ "
|
||||||
"struct A { int a ; } ; ; "
|
"struct A { int a ; } ; "
|
||||||
"struct A s ; s . a = a ; "
|
"struct A s ; s . a = a ; "
|
||||||
"return s . a ; "
|
"return s . a ; "
|
||||||
"} "
|
"} "
|
||||||
|
@ -3911,7 +3888,7 @@ private:
|
||||||
{
|
{
|
||||||
const char code[] = "typedef int A;\n"
|
const char code[] = "typedef int A;\n"
|
||||||
"template <const A, volatile A>::value;";
|
"template <const A, volatile A>::value;";
|
||||||
const char expected[] = "; ;";
|
const char expected[] = ";";
|
||||||
ASSERT_EQUALS(expected, tok(code, false));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
|
|
||||||
checkSimplifyTypedef(code);
|
checkSimplifyTypedef(code);
|
||||||
|
@ -3923,7 +3900,7 @@ private:
|
||||||
const char code[] = "typedef int A;\n"
|
const char code[] = "typedef int A;\n"
|
||||||
"typedef int B;\n"
|
"typedef int B;\n"
|
||||||
"template <class A, class B> class C { };";
|
"template <class A, class B> class C { };";
|
||||||
const char expected[] = "; ; ; ;";
|
const char expected[] = ";";
|
||||||
ASSERT_EQUALS(expected, tok(code, false));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
|
|
||||||
checkSimplifyTypedef(code);
|
checkSimplifyTypedef(code);
|
||||||
|
@ -4123,7 +4100,7 @@ private:
|
||||||
"};\n";
|
"};\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("struct foo { } ; ; "
|
const std::string expected("struct foo { } ; "
|
||||||
"struct MyA : public foo "
|
"struct MyA : public foo "
|
||||||
"{ "
|
"{ "
|
||||||
"} ;");
|
"} ;");
|
||||||
|
@ -4140,7 +4117,7 @@ private:
|
||||||
"};\n";
|
"};\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("class foo { } ; ; "
|
const std::string expected("class foo { } ; "
|
||||||
"class MyA : public foo "
|
"class MyA : public foo "
|
||||||
"{ "
|
"{ "
|
||||||
"} ;");
|
"} ;");
|
||||||
|
@ -4169,7 +4146,7 @@ private:
|
||||||
"AP ap;\n";
|
"AP ap;\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("struct A { int a ; } ; ; "
|
const std::string expected("struct A { int a ; } ; "
|
||||||
"const struct A * ap ;");
|
"const struct A * ap ;");
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
@ -4206,7 +4183,7 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("struct string { } ; ; "
|
const std::string expected("struct string { } ; "
|
||||||
"void foo ( LIST * module_name ) "
|
"void foo ( LIST * module_name ) "
|
||||||
"{ "
|
"{ "
|
||||||
"bar ( module_name ? module_name . string : 0 ) ; "
|
"bar ( module_name ? module_name . string : 0 ) ; "
|
||||||
|
@ -4244,7 +4221,7 @@ private:
|
||||||
"type4 t4;";
|
"type4 t4;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; ; "
|
const std::string expected("; "
|
||||||
"char ( * t1 ) [ 10 ] ; "
|
"char ( * t1 ) [ 10 ] ; "
|
||||||
"char ( * ( * tp1 ) [ 2 ] ) [ 10 ] ; "
|
"char ( * ( * tp1 ) [ 2 ] ) [ 10 ] ; "
|
||||||
"char ( & t2 ) [ 10 ] ; "
|
"char ( & t2 ) [ 10 ] ; "
|
||||||
|
@ -4260,7 +4237,7 @@ private:
|
||||||
"type1 t1 = &A::i;";
|
"type1 t1 = &A::i;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("class A { public: int i ; } ; ; "
|
const std::string expected("class A { public: int i ; } ; "
|
||||||
"const char ( A :: * t1 ) = & A :: i ;");
|
"const char ( A :: * t1 ) = & A :: i ;");
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
@ -4345,7 +4322,7 @@ private:
|
||||||
"_Iterator v3;\n";
|
"_Iterator v3;\n";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; "
|
const std::string expected("; "
|
||||||
"long * v1 ; "
|
"long * v1 ; "
|
||||||
"void * v2 [ 2 ] ; "
|
"void * v2 [ 2 ] ; "
|
||||||
"int * * v3 ;");
|
"int * * v3 ;");
|
||||||
|
@ -4433,7 +4410,7 @@ private:
|
||||||
" typedef void (SomeTemplateClass<DISPATCHER>::*MessageDispatcherFunc)(SerialInputMessage&);\n"
|
" typedef void (SomeTemplateClass<DISPATCHER>::*MessageDispatcherFunc)(SerialInputMessage&);\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ;");
|
const std::string expected(";");
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
|
||||||
// Check for output..
|
// Check for output..
|
||||||
|
@ -4451,7 +4428,7 @@ private:
|
||||||
" localEntitiyAddFunc_t f;\n"
|
" localEntitiyAddFunc_t f;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; void f ( ) { int b ; int * f ; }");
|
const std::string expected("; void f ( ) { int b ; int * f ; }");
|
||||||
ASSERT_EQUALS(expected, sizeof_(code, false));
|
ASSERT_EQUALS(expected, sizeof_(code, false));
|
||||||
|
|
||||||
// Check for output..
|
// Check for output..
|
||||||
|
@ -4852,7 +4829,7 @@ private:
|
||||||
"func7 f7;";
|
"func7 f7;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"C f1 ( ) ; "
|
"C f1 ( ) ; "
|
||||||
"C * f2 ; " // this gets simplified to a regular pointer
|
"C * f2 ; " // this gets simplified to a regular pointer
|
||||||
"C ( & f3 ) ( ) ; "
|
"C ( & f3 ) ( ) ; "
|
||||||
|
@ -4884,7 +4861,7 @@ private:
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
// C const -> const C
|
// C const -> const C
|
||||||
const std::string expected("; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"const C f1 ( ) ; "
|
"const C f1 ( ) ; "
|
||||||
"const C * f2 ; " // this gets simplified to a regular pointer
|
"const C * f2 ; " // this gets simplified to a regular pointer
|
||||||
"const C ( & f3 ) ( ) ; "
|
"const C ( & f3 ) ( ) ; "
|
||||||
|
@ -4915,7 +4892,7 @@ private:
|
||||||
"func7 f7;";
|
"func7 f7;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"const C f1 ( ) ; "
|
"const C f1 ( ) ; "
|
||||||
"const C * f2 ; " // this gets simplified to a regular pointer
|
"const C * f2 ; " // this gets simplified to a regular pointer
|
||||||
"const C ( & f3 ) ( ) ; "
|
"const C ( & f3 ) ( ) ; "
|
||||||
|
@ -4946,7 +4923,7 @@ private:
|
||||||
"func7 f7;";
|
"func7 f7;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"C * f1 ( ) ; "
|
"C * f1 ( ) ; "
|
||||||
"C * * f2 ; " // this gets simplified to a regular pointer
|
"C * * f2 ; " // this gets simplified to a regular pointer
|
||||||
"C * ( & f3 ) ( ) ; "
|
"C * ( & f3 ) ( ) ; "
|
||||||
|
@ -4977,7 +4954,7 @@ private:
|
||||||
"func7 f7;";
|
"func7 f7;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"const C * f1 ( ) ; "
|
"const C * f1 ( ) ; "
|
||||||
"const C * * f2 ; " // this gets simplified to a regular pointer
|
"const C * * f2 ; " // this gets simplified to a regular pointer
|
||||||
"const C * ( & f3 ) ( ) ; "
|
"const C * ( & f3 ) ( ) ; "
|
||||||
|
@ -5009,7 +4986,7 @@ private:
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
// C const -> const C
|
// C const -> const C
|
||||||
const std::string expected("; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"const C * f1 ( ) ; "
|
"const C * f1 ( ) ; "
|
||||||
"const C * * f2 ; " // this gets simplified to a regular pointer
|
"const C * * f2 ; " // this gets simplified to a regular pointer
|
||||||
"const C * ( & f3 ) ( ) ; "
|
"const C * ( & f3 ) ( ) ; "
|
||||||
|
@ -5034,7 +5011,7 @@ private:
|
||||||
"type3 t3;";
|
"type3 t3;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; "
|
const std::string expected("; "
|
||||||
"int ( * ( * t1 ) ( bool ) ) ( int , int ) ; "
|
"int ( * ( * t1 ) ( bool ) ) ( int , int ) ; "
|
||||||
"int ( * t2 ( bool ) ) ( int , int ) ; "
|
"int ( * t2 ( bool ) ) ( int , int ) ; "
|
||||||
"int ( * t3 ( bool ) ) ( int , int ) ;");
|
"int ( * t3 ( bool ) ) ( int , int ) ;");
|
||||||
|
@ -5072,7 +5049,7 @@ private:
|
||||||
"type12 t12;";
|
"type12 t12;";
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("; ; ; ; ; ; ; ; ; ; ; ; "
|
const std::string expected("; "
|
||||||
"int * t1 ; " // simplified to regular pointer
|
"int * t1 ; " // simplified to regular pointer
|
||||||
"int ( * const t2 ) ( float ) ; "
|
"int ( * const t2 ) ( float ) ; "
|
||||||
"int * t3 ; " // volatile removed, gets simplified to regular pointer
|
"int * t3 ; " // volatile removed, gets simplified to regular pointer
|
||||||
|
@ -5108,7 +5085,7 @@ private:
|
||||||
"}\n"
|
"}\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( ) { ; ; { g ( ) ; } }", tok(code));
|
ASSERT_EQUALS("void f ( ) { ; { g ( ) ; } }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5121,7 +5098,7 @@ private:
|
||||||
"}\n"
|
"}\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( ) { ; ; }", tok(code));
|
ASSERT_EQUALS("void f ( ) { ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5134,7 +5111,7 @@ private:
|
||||||
"}\n"
|
"}\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( ) { ; ; }", tok(code));
|
ASSERT_EQUALS("void f ( ) { ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5147,7 +5124,7 @@ private:
|
||||||
"}\n"
|
"}\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( ) { ; ; { g ( ) ; } }", tok(code));
|
ASSERT_EQUALS("void f ( ) { ; { g ( ) ; } }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -5201,7 +5178,6 @@ private:
|
||||||
const char expected[] = "void f ( ) "
|
const char expected[] = "void f ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"char buf [ 100 ] ; "
|
"char buf [ 100 ] ; "
|
||||||
"; ; "
|
|
||||||
"free ( buf ) ; "
|
"free ( buf ) ; "
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
@ -5253,7 +5229,6 @@ private:
|
||||||
const char expected[] = "int * foo ( ) "
|
const char expected[] = "int * foo ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"int a [ 10 ] ; "
|
"int a [ 10 ] ; "
|
||||||
"; ; "
|
|
||||||
"return a ; "
|
"return a ; "
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
@ -5284,7 +5259,6 @@ private:
|
||||||
const char expected[] = "void f ( ) "
|
const char expected[] = "void f ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"int i ; "
|
"int i ; "
|
||||||
"; ; "
|
|
||||||
"return i ; "
|
"return i ; "
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
@ -5353,7 +5327,7 @@ private:
|
||||||
|
|
||||||
void while0()
|
void while0()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("; x = 1 ; ;", tok("; do { x = 1 ; } while (0);"));
|
ASSERT_EQUALS("; x = 1 ;", tok("; do { x = 1 ; } while (0);"));
|
||||||
ASSERT_EQUALS("; do { continue ; } while ( false ) ;", tok("; do { continue ; } while (0);"));
|
ASSERT_EQUALS("; do { continue ; } while ( false ) ;", tok("; do { continue ; } while (0);"));
|
||||||
ASSERT_EQUALS("; do { break ; } while ( false ) ;", tok("; do { break; } while (0);"));
|
ASSERT_EQUALS("; do { break ; } while ( false ) ;", tok("; do { break; } while (0);"));
|
||||||
}
|
}
|
||||||
|
@ -5703,23 +5677,23 @@ private:
|
||||||
// ticket #1005 - int *p(0); => int *p = 0;
|
// ticket #1005 - int *p(0); => int *p = 0;
|
||||||
{
|
{
|
||||||
const char code[] = "void foo() { int *p(0); }";
|
const char code[] = "void foo() { int *p(0); }";
|
||||||
ASSERT_EQUALS("void foo ( ) { ; ; }", tok(code));
|
ASSERT_EQUALS("void foo ( ) { ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char code[] = "void foo() { int p(0); }";
|
const char code[] = "void foo() { int p(0); }";
|
||||||
ASSERT_EQUALS("void foo ( ) { ; ; }", tok(code));
|
ASSERT_EQUALS("void foo ( ) { ; }", tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const char code[] = "void a() { foo *p(0); }";
|
const char code[] = "void a() { foo *p(0); }";
|
||||||
ASSERT_EQUALS("void a ( ) { ; ; }", tok(code));
|
ASSERT_EQUALS("void a ( ) { ; }", tok(code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplifyReference()
|
void simplifyReference()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("void f ( ) { int a ; ; a ++ ; }",
|
ASSERT_EQUALS("void f ( ) { int a ; a ++ ; }",
|
||||||
tok("void f() { int a; int &b(a); b++; }"));
|
tok("void f() { int a; int &b(a); b++; }"));
|
||||||
ASSERT_EQUALS("void f ( ) { int a ; a ++ ; }",
|
ASSERT_EQUALS("void f ( ) { int a ; a ++ ; }",
|
||||||
tok("void f() { int a; int &b = a; b++; }"));
|
tok("void f() { int a; int &b = a; b++; }"));
|
||||||
|
@ -5890,7 +5864,7 @@ private:
|
||||||
|
|
||||||
{
|
{
|
||||||
const char code[] = "struct { int x; };";
|
const char code[] = "struct { int x; };";
|
||||||
const char expected[] = "int x ; ;";
|
const char expected[] = "int x ;";
|
||||||
ASSERT_EQUALS(expected, tok(code, false));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5951,6 +5925,12 @@ private:
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("IncrementFunctor ( ) ( a ) ;", tok("IncrementFunctor()(a);", true));
|
ASSERT_EQUALS("IncrementFunctor ( ) ( a ) ;", tok("IncrementFunctor()(a);", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void redundant_semicolon()
|
||||||
|
{
|
||||||
|
ASSERT_EQUALS("void f ( ) { ; }", tok("void f() { ; }", false));
|
||||||
|
ASSERT_EQUALS("void f ( ) { ; }", tok("void f() { do { ; } while (0); }", true));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestSimplifyTokens)
|
REGISTER_TEST(TestSimplifyTokens)
|
||||||
|
|
|
@ -704,7 +704,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
" char *str = malloc(10);\n"
|
" char *str = malloc(10);\n"
|
||||||
" if (somecondition)\n"
|
" if (somecondition)\n"
|
||||||
" for ( ; ; )\n"
|
" for ( ; )\n"
|
||||||
" { }\n"
|
" { }\n"
|
||||||
" return str;\n"
|
" return str;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
@ -712,7 +712,7 @@ private:
|
||||||
"{\n"
|
"{\n"
|
||||||
"char * str ; str = malloc ( 10 ) ;\n"
|
"char * str ; str = malloc ( 10 ) ;\n"
|
||||||
"if ( somecondition ) {\n"
|
"if ( somecondition ) {\n"
|
||||||
"for ( ; ; )\n"
|
"for ( ; )\n"
|
||||||
"{ } }\n"
|
"{ } }\n"
|
||||||
"return str ;\n"
|
"return str ;\n"
|
||||||
"}", tokenizeAndStringify(code, true));
|
"}", tokenizeAndStringify(code, true));
|
||||||
|
@ -1513,8 +1513,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 + v@2 ;\n"
|
"5: return u@1 + v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1530,8 +1530,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 - v@2 ;\n"
|
"5: return u@1 - v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1547,8 +1547,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 * v@2 ;\n"
|
"5: return u@1 * v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1564,8 +1564,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 / v@2 ;\n"
|
"5: return u@1 / v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1581,8 +1581,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 & v@2 ;\n"
|
"5: return u@1 & v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1598,8 +1598,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 | v@2 ;\n"
|
"5: return u@1 | v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1615,8 +1615,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 ^ v@2 ;\n"
|
"5: return u@1 ^ v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1632,8 +1632,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 % v@2 ;\n"
|
"5: return u@1 % v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1649,8 +1649,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 >> v@2 ;\n"
|
"5: return u@1 >> v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1666,8 +1666,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: int foo ( int u@1 , int v@2 )\n"
|
"1: int foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4:\n"
|
||||||
"5: return u@1 << v@2 ;\n"
|
"5: return u@1 << v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1683,8 +1683,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 == v@2 ;\n"
|
"5: return u@1 == v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1700,8 +1700,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 != v@2 ;\n"
|
"5: return u@1 != v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1717,8 +1717,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 > v@2 ;\n"
|
"5: return u@1 > v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1734,8 +1734,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 >= v@2 ;\n"
|
"5: return u@1 >= v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1751,8 +1751,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 < v@2 ;\n"
|
"5: return u@1 < v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1768,8 +1768,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 <= v@2 ;\n"
|
"5: return u@1 <= v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1785,8 +1785,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 && v@2 ;\n"
|
"5: return u@1 && v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1802,8 +1802,8 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: bool foo ( int u@1 , int v@2 )\n"
|
"1: bool foo ( int u@1 , int v@2 )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: ; ;\n"
|
"4: ;\n"
|
||||||
"5: return u@1 || v@2 ;\n"
|
"5: return u@1 || v@2 ;\n"
|
||||||
"6: }\n";
|
"6: }\n";
|
||||||
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
TODO_ASSERT_EQUALS(expected, tokenizeDebugListing(code, true));
|
||||||
|
@ -1963,7 +1963,7 @@ private:
|
||||||
const std::string expected("\n\n##file 0\n"
|
const std::string expected("\n\n##file 0\n"
|
||||||
"1: void f ( )\n"
|
"1: void f ( )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ; ;\n"
|
"3: ;\n"
|
||||||
"4: }\n");
|
"4: }\n");
|
||||||
|
|
||||||
ASSERT_EQUALS(expected, actual);
|
ASSERT_EQUALS(expected, actual);
|
||||||
|
@ -2138,7 +2138,7 @@ private:
|
||||||
const std::string expected("\n\n##file 0\n"
|
const std::string expected("\n\n##file 0\n"
|
||||||
"1: void f ( )\n"
|
"1: void f ( )\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: int a@1 ; ;\n"
|
"3: int a@1 ;\n"
|
||||||
"4: a@1 = a@1 ;\n"
|
"4: a@1 = a@1 ;\n"
|
||||||
"5: }\n");
|
"5: }\n");
|
||||||
|
|
||||||
|
@ -3323,7 +3323,7 @@ private:
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
|
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
|
||||||
ostr << " " << tok->str();
|
ostr << " " << tok->str();
|
||||||
ASSERT_EQUALS(" void f ( ) { const int a = 45 ; { ; ; } } void g ( ) { ; ; }", ostr.str());
|
ASSERT_EQUALS(" void f ( ) { const int a = 45 ; { ; } } void g ( ) { ; }", ostr.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void simplify_constants2()
|
void simplify_constants2()
|
||||||
|
@ -4051,8 +4051,8 @@ private:
|
||||||
|
|
||||||
void removeRedundantAssignment()
|
void removeRedundantAssignment()
|
||||||
{
|
{
|
||||||
ASSERT_EQUALS("void f ( ) { ; int * q ; ; }", tokenizeAndStringify("void f() { int *p, *q; p = q; }", true));
|
ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p, *q; p = q; }", true));
|
||||||
ASSERT_EQUALS("void f ( ) { ; ; int * q ; ; }", tokenizeAndStringify("void f() { int *p = 0, *q; p = q; }", true));
|
ASSERT_EQUALS("void f ( ) { ; int * q ; }", tokenizeAndStringify("void f() { int *p = 0, *q; p = q; }", true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void removedeclspec()
|
void removedeclspec()
|
||||||
|
|
Loading…
Reference in New Issue