1) Remove some redundant semicolons - part 4 ('typedef' != _tokens.str());
2) Tokenizer: Use Token::eraseTokens instead of using the same instructions as the ones inside such function.
This commit is contained in:
parent
eeb6dc48a5
commit
a363749a17
|
@ -1808,12 +1808,12 @@ void Tokenizer::simplifyTypedef()
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
// remove typedef but leave ;
|
// remove typedef but leave ;
|
||||||
while (typeDef->next() && typeDef->next() != tok)
|
Token::eraseTokens(typeDef, tok);
|
||||||
typeDef->deleteNext();
|
|
||||||
|
|
||||||
if (typeDef != _tokens) {
|
if (typeDef != _tokens) {
|
||||||
tok = typeDef->previous();
|
tok = typeDef->previous();
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
tok->deleteNext();
|
||||||
} else {
|
} else {
|
||||||
_tokens->deleteThis();
|
_tokens->deleteThis();
|
||||||
tok = _tokens;
|
tok = _tokens;
|
||||||
|
@ -8185,9 +8185,7 @@ void Tokenizer::simplifyEnum()
|
||||||
}
|
}
|
||||||
|
|
||||||
tok1 = start;
|
tok1 = start;
|
||||||
while (tok1->next() && tok1->next() != end)
|
Token::eraseTokens(tok1, end->next());
|
||||||
tok1->deleteNext();
|
|
||||||
tok1->deleteNext();
|
|
||||||
if (start != _tokens) {
|
if (start != _tokens) {
|
||||||
tok1 = start->previous();
|
tok1 = start->previous();
|
||||||
tok1->deleteNext();
|
tok1->deleteNext();
|
||||||
|
|
|
@ -3398,7 +3398,7 @@ private:
|
||||||
"class A "
|
"class A "
|
||||||
"{ "
|
"{ "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"void foo ( ) { } "
|
"void foo ( ) { } "
|
||||||
"} ; "
|
"} ; "
|
||||||
"int main ( ) "
|
"int main ( ) "
|
||||||
|
@ -3425,7 +3425,7 @@ private:
|
||||||
"class A "
|
"class A "
|
||||||
"{ "
|
"{ "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"wchar_t foo ( ) { wchar_t b ; return b ; } "
|
"wchar_t foo ( ) { wchar_t b ; return b ; } "
|
||||||
"} ;";
|
"} ;";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
@ -3449,7 +3449,7 @@ private:
|
||||||
"class A { } ; "
|
"class A { } ; "
|
||||||
"wchar_t foo ( ) "
|
"wchar_t foo ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"; "
|
""
|
||||||
"wchar_t b ; "
|
"wchar_t b ; "
|
||||||
"return b ; "
|
"return b ; "
|
||||||
"} "
|
"} "
|
||||||
|
@ -3510,7 +3510,7 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"namespace VL { "
|
"namespace VL { "
|
||||||
"; "
|
""
|
||||||
"float fast_atan2 ( float y , float x ) { } "
|
"float fast_atan2 ( float y , float x ) { } "
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
@ -3838,7 +3838,7 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"; "
|
"; "
|
||||||
"; "
|
""
|
||||||
"void ( * pf ) ( ) ; "
|
"void ( * pf ) ( ) ; "
|
||||||
"void * ( * pfv ) ( void * ) ;";
|
"void * ( * pfv ) ( void * ) ;";
|
||||||
|
|
||||||
|
@ -3855,7 +3855,7 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class Fred { "
|
"class Fred { "
|
||||||
"; "
|
""
|
||||||
"void ( * get ( ) ) ( ) { return test ; } "
|
"void ( * get ( ) ) ( ) { return test ; } "
|
||||||
"static void test ( ) { } "
|
"static void test ( ) { } "
|
||||||
"} ;";
|
"} ;";
|
||||||
|
@ -3872,7 +3872,7 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class Fred { "
|
"class Fred { "
|
||||||
"; "
|
""
|
||||||
"void * ( * get ( ) ) ( void * ) { return test ; } "
|
"void * ( * get ( ) ) ( void * ) { return test ; } "
|
||||||
"static void * test ( void * p ) { return p ; } "
|
"static void * test ( void * p ) { return p ; } "
|
||||||
"} ;";
|
"} ;";
|
||||||
|
@ -3889,7 +3889,7 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class Fred { "
|
"class Fred { "
|
||||||
"; "
|
""
|
||||||
"unsigned int * ( * get ( ) ) ( unsigned int * ) { return test ; } "
|
"unsigned int * ( * get ( ) ) ( unsigned int * ) { return test ; } "
|
||||||
"static unsigned int * test ( unsigned int * p ) { return p ; } "
|
"static unsigned int * test ( unsigned int * p ) { return p ; } "
|
||||||
"} ;";
|
"} ;";
|
||||||
|
@ -3907,7 +3907,7 @@ private:
|
||||||
// static const gets changed to const static
|
// static const gets changed to const static
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class Fred { "
|
"class Fred { "
|
||||||
"; "
|
""
|
||||||
"const unsigned int * ( * get ( ) ) ( const unsigned int * ) { return test ; } "
|
"const unsigned int * ( * get ( ) ) ( const unsigned int * ) { return test ; } "
|
||||||
"const static unsigned int * test ( const unsigned int * p ) { return p ; } "
|
"const static unsigned int * test ( const unsigned int * p ) { return p ; } "
|
||||||
"} ;";
|
"} ;";
|
||||||
|
@ -3924,7 +3924,7 @@ private:
|
||||||
|
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class Fred { "
|
"class Fred { "
|
||||||
"; "
|
""
|
||||||
"void * ( * get ( int i ) ) ( void * ) { return test ; } "
|
"void * ( * get ( int i ) ) ( void * ) { return test ; } "
|
||||||
"static void * test ( void * p ) { return p ; } "
|
"static void * test ( void * p ) { return p ; } "
|
||||||
"} ;";
|
"} ;";
|
||||||
|
@ -4053,7 +4053,7 @@ private:
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"int main ( ) "
|
"int main ( ) "
|
||||||
"{ "
|
"{ "
|
||||||
"; "
|
""
|
||||||
"VERIFY ( is_same < result_of < int ( * ( char , float ) ) ( float , double ) > :: type , int > :: value ) ; "
|
"VERIFY ( is_same < result_of < int ( * ( char , float ) ) ( float , double ) > :: type , int > :: value ) ; "
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
@ -4124,7 +4124,7 @@ private:
|
||||||
|
|
||||||
const char expected[] = "class A { "
|
const char expected[] = "class A { "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"int get ( ) const ; "
|
"int get ( ) const ; "
|
||||||
"void put ( int x ) { a = x ; } "
|
"void put ( int x ) { a = x ; } "
|
||||||
"int a ; "
|
"int a ; "
|
||||||
|
@ -4146,7 +4146,7 @@ private:
|
||||||
"A::INT i = A::a;";
|
"A::INT i = A::a;";
|
||||||
|
|
||||||
const char expected[] = "struct A { "
|
const char expected[] = "struct A { "
|
||||||
"; "
|
""
|
||||||
"int get ( ) const ; "
|
"int get ( ) const ; "
|
||||||
"void put ( int x ) { a = x ; } "
|
"void put ( int x ) { a = x ; } "
|
||||||
"int a ; "
|
"int a ; "
|
||||||
|
@ -4207,18 +4207,18 @@ private:
|
||||||
const char expected[] =
|
const char expected[] =
|
||||||
"class A { "
|
"class A { "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"char funA ( ) ; "
|
"char funA ( ) ; "
|
||||||
"class B { "
|
"class B { "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"short funB ( ) ; "
|
"short funB ( ) ; "
|
||||||
"class C { "
|
"class C { "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"int funC ( ) ; "
|
"int funC ( ) ; "
|
||||||
"struct D { "
|
"struct D { "
|
||||||
"; "
|
""
|
||||||
"long funD ( ) ; "
|
"long funD ( ) ; "
|
||||||
"long d ; "
|
"long d ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
|
@ -4306,7 +4306,7 @@ private:
|
||||||
"class S "
|
"class S "
|
||||||
"{ "
|
"{ "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"float a ; "
|
"float a ; "
|
||||||
"virtual void fun ( float x ) ; "
|
"virtual void fun ( float x ) ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
|
@ -4318,7 +4318,7 @@ private:
|
||||||
"} ; "
|
"} ; "
|
||||||
"struct T "
|
"struct T "
|
||||||
"{ "
|
"{ "
|
||||||
"; "
|
""
|
||||||
"int b ; "
|
"int b ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
"float fun1 ( float A ) { return A ; } "
|
"float fun1 ( float A ) { return A ; } "
|
||||||
|
@ -4705,7 +4705,7 @@ private:
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("class Class2 { "
|
const std::string expected("class Class2 { "
|
||||||
"; "
|
""
|
||||||
"void some_method ( const Class & x ) const { } "
|
"void some_method ( const Class & x ) const { } "
|
||||||
"void another_method ( const Class & x ) const { } "
|
"void another_method ( const Class & x ) const { } "
|
||||||
"}");
|
"}");
|
||||||
|
@ -4840,7 +4840,7 @@ private:
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("struct C { "
|
const std::string expected("struct C { "
|
||||||
"; "
|
""
|
||||||
"const void * pr ; " // this gets simplified to a regular pointer
|
"const void * pr ; " // this gets simplified to a regular pointer
|
||||||
"operatorconstvoid(*)()& ( ) { return pr ; } "
|
"operatorconstvoid(*)()& ( ) { return pr ; } "
|
||||||
"} ;");
|
"} ;");
|
||||||
|
@ -4859,7 +4859,7 @@ private:
|
||||||
|
|
||||||
// The expected result..
|
// The expected result..
|
||||||
const std::string expected("void foo { "
|
const std::string expected("void foo { "
|
||||||
"; "
|
""
|
||||||
"int a ; a = int ( 1 ) * int ( 2 ) ; "
|
"int a ; a = int ( 1 ) * int ( 2 ) ; "
|
||||||
"} ;");
|
"} ;");
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
@ -5109,7 +5109,7 @@ private:
|
||||||
" operator F() const { }\n"
|
" operator F() const { }\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
const std::string expected = "class Fred { "
|
const std::string expected = "class Fred { "
|
||||||
"; "
|
""
|
||||||
"operatorint** ( ) const { } "
|
"operatorint** ( ) const { } "
|
||||||
"} ;";
|
"} ;";
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
@ -5122,7 +5122,7 @@ private:
|
||||||
" void f1() const { INT i; }\n"
|
" void f1() const { INT i; }\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
const std::string expected = "class Fred { "
|
const std::string expected = "class Fred { "
|
||||||
"; "
|
""
|
||||||
"void f1 ( ) const { int i ; } "
|
"void f1 ( ) const { int i ; } "
|
||||||
"} ;";
|
"} ;";
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
@ -5136,7 +5136,7 @@ private:
|
||||||
"};\n"
|
"};\n"
|
||||||
"void Fred::f1() const { INT i; f(i); }\n";
|
"void Fred::f1() const { INT i; f(i); }\n";
|
||||||
const std::string expected = "class Fred { "
|
const std::string expected = "class Fred { "
|
||||||
"; "
|
""
|
||||||
"void f1 ( ) const ; "
|
"void f1 ( ) const ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
"void Fred :: f1 ( ) const { int i ; f ( i ) ; }";
|
"void Fred :: f1 ( ) const { int i ; f ( i ) ; }";
|
||||||
|
@ -5151,7 +5151,7 @@ private:
|
||||||
"};\n"
|
"};\n"
|
||||||
"Fred::operator F() const { }\n";
|
"Fred::operator F() const { }\n";
|
||||||
const std::string expected = "class Fred { "
|
const std::string expected = "class Fred { "
|
||||||
"; "
|
""
|
||||||
"operatorint** ( ) const ; "
|
"operatorint** ( ) const ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
"Fred :: operatorint** ( ) const { }";
|
"Fred :: operatorint** ( ) const { }";
|
||||||
|
@ -5310,7 +5310,7 @@ private:
|
||||||
" safe_bool operator!() const;\n"
|
" safe_bool operator!() const;\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
const char expected[] = "class relational { "
|
const char expected[] = "class relational { "
|
||||||
"; "
|
""
|
||||||
"public: "
|
"public: "
|
||||||
"operatorsafe_bool ( ) const ; "
|
"operatorsafe_bool ( ) const ; "
|
||||||
"safe_bool operator! ( ) const ; "
|
"safe_bool operator! ( ) const ; "
|
||||||
|
@ -5341,7 +5341,7 @@ private:
|
||||||
" typedef void f(int) const;\n"
|
" typedef void f(int) const;\n"
|
||||||
" f func;\n"
|
" f func;\n"
|
||||||
"};\n";
|
"};\n";
|
||||||
const char expected[] = "class Fred { ; void func ( int ) const ; } ;";
|
const char expected[] = "class Fred { void func ( int ) const ; } ;";
|
||||||
checkSimplifyTypedef(code);
|
checkSimplifyTypedef(code);
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
@ -5367,7 +5367,7 @@ private:
|
||||||
" T A::f() {}\n"
|
" T A::f() {}\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
const char expected1[] = "namespace NS { "
|
const char expected1[] = "namespace NS { "
|
||||||
"; "
|
""
|
||||||
"class A { "
|
"class A { "
|
||||||
"int ( * f ( ) ) ( ) ; "
|
"int ( * f ( ) ) ( ) ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
|
@ -5387,7 +5387,7 @@ private:
|
||||||
"}\n"
|
"}\n"
|
||||||
"NS::T NS::A::f() {}\n";
|
"NS::T NS::A::f() {}\n";
|
||||||
const char expected2[] = "namespace NS { "
|
const char expected2[] = "namespace NS { "
|
||||||
"; "
|
""
|
||||||
"class A { "
|
"class A { "
|
||||||
"int ( * f ( ) ) ( ) ; "
|
"int ( * f ( ) ) ( ) ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
|
@ -5412,7 +5412,7 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
const char expected3[] = "namespace NS1 { "
|
const char expected3[] = "namespace NS1 { "
|
||||||
"namespace NS2 { "
|
"namespace NS2 { "
|
||||||
"; "
|
""
|
||||||
"class A { "
|
"class A { "
|
||||||
"int ( * f ( ) ) ( ) ; "
|
"int ( * f ( ) ) ( ) ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
|
@ -5440,7 +5440,7 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
const char expected4[] = "namespace NS1 { "
|
const char expected4[] = "namespace NS1 { "
|
||||||
"namespace NS2 { "
|
"namespace NS2 { "
|
||||||
"; "
|
""
|
||||||
"class A { "
|
"class A { "
|
||||||
"int ( * f ( ) ) ( ) ; "
|
"int ( * f ( ) ) ( ) ; "
|
||||||
"} ; "
|
"} ; "
|
||||||
|
@ -5544,7 +5544,7 @@ private:
|
||||||
"};\n";
|
"};\n";
|
||||||
const char expected[] = "class symbol_table { "
|
const char expected[] = "class symbol_table { "
|
||||||
"public: "
|
"public: "
|
||||||
"; "
|
""
|
||||||
"expression_error :: error_code ( * f ) ( void * cbparam , const char * name , expression_space space ) ; "
|
"expression_error :: error_code ( * f ) ( void * cbparam , const char * name , expression_space space ) ; "
|
||||||
"} ;";
|
"} ;";
|
||||||
|
|
||||||
|
|
|
@ -4979,7 +4979,7 @@ private:
|
||||||
const char expected[] = "\n\n##file 0\n"
|
const char expected[] = "\n\n##file 0\n"
|
||||||
"1: struct S\n"
|
"1: struct S\n"
|
||||||
"2: {\n"
|
"2: {\n"
|
||||||
"3: ;\n"
|
"3:\n"
|
||||||
"4: virtual void ( * getFP ( ) ) ( ) ;\n"
|
"4: virtual void ( * getFP ( ) ) ( ) ;\n"
|
||||||
"5: virtual void execute ( ) ;\n"
|
"5: virtual void execute ( ) ;\n"
|
||||||
"6: } ;\n"
|
"6: } ;\n"
|
||||||
|
|
Loading…
Reference in New Issue