update debug token list output for templates.

This commit is contained in:
Daniel Marjamäki 2017-12-25 23:16:51 +01:00
parent a80760cb6f
commit eaadfb3910
3 changed files with 133 additions and 128 deletions

View File

@ -988,7 +988,12 @@ void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro)
}
if (macro && isExpandedMacro())
os << "$";
if (_str[0] != '\"' || _str.find('\0') == std::string::npos)
if (isName() && _str.find(' ') != std::string::npos) {
for (std::size_t i = 0U; i < _str.size(); ++i) {
if (_str[i] != ' ')
os << _str[i];
}
} else if (_str[0] != '\"' || _str.find('\0') == std::string::npos)
os << _str;
else {
for (std::size_t i = 0U; i < _str.size(); ++i) {

View File

@ -152,8 +152,8 @@ private:
const char code[] = "template <class T> void f(T val) { T a; }\n"
"f<int>(10);";
const char expected[] = "f < int > ( 10 ) ; "
"void f < int > ( int val ) { }";
const char expected[] = "f<int> ( 10 ) ; "
"void f<int> ( int val ) { }";
ASSERT_EQUALS(expected, tok(code));
}
@ -162,8 +162,8 @@ private:
const char code[] = "template <class T> class Fred { T a; };\n"
"Fred<int> fred;";
const char expected[] = "Fred < int > fred ; "
"class Fred < int > { int a ; } ;";
const char expected[] = "Fred<int> fred ; "
"class Fred<int> { int a ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -172,8 +172,8 @@ private:
const char code[] = "template <class T, int sz> class Fred { T data[sz]; };\n"
"Fred<float,4> fred;";
const char expected[] = "Fred < float , 4 > fred ; "
"class Fred < float , 4 > { float data [ 4 ] ; } ;";
const char expected[] = "Fred<float,4> fred ; "
"class Fred<float,4> { float data [ 4 ] ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -182,8 +182,8 @@ private:
const char code[] = "template <class T> class Fred { Fred(); };\n"
"Fred<float> fred;";
const char expected[] = "Fred < float > fred ; "
"class Fred < float > { Fred < float > ( ) ; } ;";
const char expected[] = "Fred<float> fred ; "
"class Fred<float> { Fred<float> ( ) ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -194,9 +194,9 @@ private:
"Fred<float> fred;";
const char expected[] = "template < class T > Fred < T > :: Fred ( ) { } " // <- TODO: this should be removed
"Fred < float > fred ; "
"class Fred < float > { } ; "
"Fred < float > :: Fred ( ) { }";
"Fred<float> fred ; "
"class Fred<float> { } ; "
"Fred<float> :: Fred ( ) { }";
ASSERT_EQUALS(expected, tok(code));
}
@ -206,9 +206,9 @@ private:
"Fred<float> fred1;\n"
"Fred<float> fred2;";
const char expected[] = "Fred < float > fred1 ; "
"Fred < float > fred2 ; "
"class Fred < float > { } ;";
const char expected[] = "Fred<float> fred1 ; "
"Fred<float> fred2 ; "
"class Fred<float> { } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -320,9 +320,9 @@ private:
"} ;\n";
// The expected result..
const char expected[] = "void f ( ) { A < int > a ; } "
const char expected[] = "void f ( ) { A<int> a ; } "
"template < typename T > class B { void g ( ) { A < T > b ; b = A < T > :: h ( ) ; } } ; "
"class A < int > { } ;";
"class A<int> { } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -339,9 +339,9 @@ private:
// The expected result..
const char expected[] = "void f ( ) "
"{"
" foo < 3 , int > ( ) ; "
" foo<3,int> ( ) ; "
"} "
"int * foo < 3 , int > ( ) { return new int [ 3 ] ; }";
"int * foo<3,int> ( ) { return new int [ 3 ] ; }";
ASSERT_EQUALS(expected, tok(code));
}
@ -357,9 +357,9 @@ private:
// The expected result..
const char expected[] = "void f ( ) "
"{"
" char * p ; p = foo < 3 , char > ( ) ; "
" char * p ; p = foo<3,char> ( ) ; "
"} "
"char * foo < 3 , char > ( ) { return new char [ 3 ] ; }";
"char * foo<3,char> ( ) { return new char [ 3 ] ; }";
ASSERT_EQUALS(expected, tok(code));
}
@ -376,9 +376,9 @@ private:
// The expected result..
const char expected[] = "void f ( ) "
"{"
" A < 12 , 12 , 11 > a ; "
" A<12,12,11> a ; "
"} "
"class A < 12 , 12 , 11 > : public B < 12 , 12 , 0 > "
"class A<12,12,11> : public B < 12 , 12 , 0 > "
"{ } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -422,10 +422,10 @@ private:
"}\n";
// The expected result..
const char expected[] = "void foo < int * > ( ) "
const char expected[] = "void foo<int*> ( ) "
"{ x ( ) ; } "
"int main ( ) "
"{ foo < int * > ( ) ; }";
"{ foo<int*> ( ) ; }";
ASSERT_EQUALS(expected, tok(code));
}
@ -446,11 +446,11 @@ private:
"}\n";
// The expected result..
const char expected[] = "void a < 0 > ( ) { } "
const char expected[] = "void a<0> ( ) { } "
"int main ( ) "
"{ a < 2 > ( ) ; return 0 ; } "
"void a < 2 > ( ) { a < 1 > ( ) ; } "
"void a < 1 > ( ) { a < 0 > ( ) ; }";
"{ a<2> ( ) ; return 0 ; } "
"void a<2> ( ) { a<1> ( ) ; } "
"void a<1> ( ) { a<0> ( ) ; }";
ASSERT_EQUALS(expected, tok(code));
@ -461,10 +461,10 @@ private:
"};\n"
"\n"
"vec<4> v;";
const char expected2[] = "vec < 4 > v ; "
"struct vec < 4 > { "
"vec < 4 > ( ) { } "
"vec < 4 > ( const vec < 4 - 1 > & v ) { } "
const char expected2[] = "vec<4> v ; "
"struct vec<4> { "
"vec<4> ( ) { } "
"vec<4> ( const vec < 4 - 1 > & v ) { } "
"} ;";
ASSERT_EQUALS(expected2, tok(code2));
@ -483,9 +483,9 @@ private:
" return 0;\n"
"}\n";
const char expected[] = "int main ( ) { b < 2 > ( ) ; return 0 ; } "
"void b < 2 > ( ) { a < 2 > ( ) ; } "
"void a < 2 > ( ) { }";
const char expected[] = "int main ( ) { b<2> ( ) ; return 0 ; } "
"void b<2> ( ) { a<2> ( ) ; } "
"void a<2> ( ) { }";
ASSERT_EQUALS(expected, tok(code));
}
@ -510,8 +510,8 @@ private:
const char code[] = "template <class T> class foo { T a; };\n"
"foo<int> *f;";
const char expected[] = "foo < int > * f ; "
"class foo < int > { int a ; } ;";
const char expected[] = "foo<int> * f ; "
"class foo<int> { int a ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -528,9 +528,9 @@ private:
// The expected result..
const char expected[] = "void f ( ) "
"{"
" char p ; p = foo < char > ( ) ; "
" char p ; p = foo<char> ( ) ; "
"} "
"char & foo < char > ( ) { static char temp ; return temp ; }";
"char & foo<char> ( ) { static char temp ; return temp ; }";
ASSERT_EQUALS(expected, tok(code));
}
@ -550,9 +550,9 @@ private:
// The expected result..
const char expected[] = "template < class T > A < T > :: ~ A ( ) { } " // <- TODO: this should be removed
"A < int > a ; "
"class A < int > { public: ~ A < int > ( ) ; } ; "
"A < int > :: ~ A < int > ( ) { }";
"A<int> a ; "
"class A<int> { public: ~ A<int> ( ) ; } ; "
"A<int> :: ~ A<int> ( ) { }";
ASSERT_EQUALS(expected, tok(code));
}
@ -561,8 +561,8 @@ private:
const char code[] = "template <class T> struct Fred { T a; };\n"
"Fred<int> fred;";
const char expected[] = "Fred < int > fred ; "
"struct Fred < int > { int a ; } ;";
const char expected[] = "Fred<int> fred ; "
"struct Fred<int> { int a ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -571,8 +571,8 @@ private:
const char code[] = "template <class T, int sz> struct Fred { T data[sz]; };\n"
"Fred<float,4> fred;";
const char expected[] = "Fred < float , 4 > fred ; "
"struct Fred < float , 4 > { float data [ 4 ] ; } ;";
const char expected[] = "Fred<float,4> fred ; "
"struct Fred<float,4> { float data [ 4 ] ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -581,8 +581,8 @@ private:
const char code[] = "template <class T> struct Fred { Fred(); };\n"
"Fred<float> fred;";
const char expected[] = "Fred < float > fred ; "
"struct Fred < float > { Fred < float > ( ) ; } ;";
const char expected[] = "Fred<float> fred ; "
"struct Fred<float> { Fred<float> ( ) ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -592,9 +592,9 @@ private:
"Fred<float> fred1;\n"
"Fred<float> fred2;";
const char expected[] = "Fred < float > fred1 ; "
"Fred < float > fred2 ; "
"struct Fred < float > { } ;";
const char expected[] = "Fred<float> fred1 ; "
"Fred<float> fred2 ; "
"struct Fred<float> { } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -604,8 +604,8 @@ private:
const char code[] = "template <class T> struct Fred { T a; };\n"
"Fred<std::string> fred;";
const char expected[] = "Fred < std :: string > fred ; "
"struct Fred < std :: string > { std :: string a ; } ;";
const char expected[] = "Fred<std::string> fred ; "
"struct Fred<std::string> { std :: string a ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -617,9 +617,9 @@ private:
"}";
const char expected[] = "void bar ( ) {"
" std :: cout << ( foo < double > ( ) ) ; "
" std :: cout << ( foo<double> ( ) ) ; "
"} "
"void foo < double > ( ) { }";
"void foo<double> ( ) { }";
ASSERT_EQUALS(expected, tok(code));
}
@ -635,9 +635,9 @@ private:
"{};\n"
"\n"
"bitset<1> z;";
const char expected[] = "bitset < 1 > z ; "
"class bitset < 1 > : B < 4 > { } ; "
"struct B < 4 > { int a [ 4 ] ; } ;";
const char expected[] = "bitset<1> z ; "
"class bitset<1> : B<4> { } ; "
"struct B<4> { int a [ 4 ] ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -653,11 +653,11 @@ private:
"bitset<1> z;";
const char actual[] = "template < int n > struct B { int a [ n ] ; } ; "
"bitset < 1 > z ; "
"class bitset < 1 > : B < 4 > { } ;";
"bitset<1> z ; "
"class bitset<1> : B < 4 > { } ;";
const char expected[] = "bitset < 1 > z ; "
"class bitset < 1 > : B < 4 > { } ; "
const char expected[] = "bitset<1> z ; "
"class bitset<1> : B < 4 > { } ; "
"struct B < 4 > { int a [ 4 ] ; } ;";
TODO_ASSERT_EQUALS(expected, actual, tok(code));
@ -674,7 +674,7 @@ private:
"\n"
"C<2> a;\n";
// TODO: expand A also
ASSERT_EQUALS("template < class T > class A { public: T x ; } ; C < 2 > a ; class C < 2 > : public A < char [ 2 ] > { } ;", tok(code));
ASSERT_EQUALS("template < class T > class A { public: T x ; } ; C<2> a ; class C<2> : public A < char [ 2 ] > { } ;", tok(code));
}
void template27() {
@ -687,7 +687,7 @@ private:
// #3226 - inner template
const char code[] = "template<class A, class B> class Fred {};\n"
"Fred<int,Fred<int,int> > x;\n";
ASSERT_EQUALS("Fred < int , Fred < int , int > > x ; class Fred < int , int > { } ; class Fred < int , Fred < int , int > > { } ;", tok(code));
ASSERT_EQUALS("Fred < int , Fred<int,int> > x ; class Fred<int,int> { } ; class Fred<int,Fred<int,int>> { } ;", tok(code));
}
void template30() {
@ -699,11 +699,11 @@ private:
void template31() {
// #4010 - template reference type
const char code[] = "template<class T> struct A{}; A<int&> a;";
ASSERT_EQUALS("A < int & > a ; struct A < int & > { } ;", tok(code));
ASSERT_EQUALS("A<int&> a ; struct A<int&> { } ;", tok(code));
// #7409 - rvalue
const char code2[] = "template<class T> struct A{}; A<int&&> a;";
ASSERT_EQUALS("A < int && > a ; struct A < int && > { } ;", tok(code2));
ASSERT_EQUALS("A<int&&> a ; struct A<int&&> { } ;", tok(code2));
}
void template32() {
@ -719,8 +719,8 @@ private:
"\n"
"B<int> b;\n";
ASSERT_EQUALS("template < class T1 , class T2 , class T3 , class T4 > struct A { } ; "
"B < int > b ; "
"struct B < int > { public: A < int , Pair < int , int > , int > a ; } ;", tok(code));
"B<int> b ; "
"struct B<int> { public: A < int , Pair < int , int > , int > a ; } ;", tok(code));
}
void template33() {
@ -730,10 +730,10 @@ private:
"template<class T> struct B { };\n"
"template<class T> struct C { A<B<X<T> > > ab; };\n"
"C<int> c;";
ASSERT_EQUALS("C < int > c ; "
"struct C < int > { A < B < X < int > > > ab ; } ; "
"struct B < X < int > > { } ; " // <- redundant.. but nevermind
"struct A < B < X < int > > > { } ;", tok(code));
ASSERT_EQUALS("C<int> c ; "
"struct C<int> { A < B<X<int>> > ab ; } ; "
"struct B<X<int>> { } ; " // <- redundant.. but nevermind
"struct A<B<X<int>>> { } ;", tok(code));
}
{
@ -744,7 +744,7 @@ private:
"C< B<A> > c;";
ASSERT_EQUALS("struct A { } ; "
"template < class T > struct B { } ; " // <- redundant.. but nevermind
"C < B < A > > c ; struct C < B < A > > { } ;",
"C<B<A>> c ; struct C<B<A>> { } ;",
tok(code));
}
}
@ -764,16 +764,16 @@ private:
void template35() { // #4074 - "A<'x'> a;" is not recognized as template instantiation
const char code[] = "template <char c> class A {};\n"
"A <'x'> a;";
ASSERT_EQUALS("A < 'x' > a ; class A < 'x' > { } ;", tok(code));
ASSERT_EQUALS("A<'x'> a ; class A<'x'> { } ;", tok(code));
}
void template36() { // #4310 - Passing unknown template instantiation as template argument
const char code[] = "template <class T> struct X { T t; };\n"
"template <class C> struct Y { Foo < X< Bar<C> > > _foo; };\n" // <- Bar is unknown
"Y<int> bar;";
ASSERT_EQUALS("Y < int > bar ; "
"struct Y < int > { Foo < X < Bar < int > > > _foo ; } ; "
"struct X < Bar < int > > { Bar < int > t ; } ;",
ASSERT_EQUALS("Y<int> bar ; "
"struct Y<int> { Foo < X<Bar<int>> > _foo ; } ; "
"struct X<Bar<int>> { Bar < int > t ; } ;",
tok(code));
}
@ -783,7 +783,7 @@ private:
"template<class T> class B {};\n"
"B<class A> b1;\n"
"B<A> b2;";
ASSERT_EQUALS("class A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
ASSERT_EQUALS("class A { } ; B<A> b1 ; B<A> b2 ; class B<A> { } ;",
tok(code));
}
{
@ -791,7 +791,7 @@ private:
"template<class T> class B {};\n"
"B<struct A> b1;\n"
"B<A> b2;";
ASSERT_EQUALS("struct A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
ASSERT_EQUALS("struct A { } ; B<A> b1 ; B<A> b2 ; class B<A> { } ;",
tok(code));
}
{
@ -799,7 +799,7 @@ private:
"template<class T> class B {};\n"
"B<enum A> b1;\n"
"B<A> b2;";
ASSERT_EQUALS("enum A { } ; B < A > b1 ; B < A > b2 ; class B < A > { } ;",
ASSERT_EQUALS("enum A { } ; B<A> b1 ; B<A> b2 ; class B<A> { } ;",
tok(code));
}
}
@ -845,11 +845,11 @@ private:
void template41() { // #4710 - const in template instantiation not handled perfectly
const char code1[] = "template<class T> struct X { };\n"
"void f(const X<int> x) { }";
ASSERT_EQUALS("void f ( const X < int > x ) { } struct X < int > { } ;", tok(code1));
ASSERT_EQUALS("void f ( const X<int> x ) { } struct X<int> { } ;", tok(code1));
const char code2[] = "template<class T> T f(T t) { return t; }\n"
"int x() { return f<int>(123); }";
ASSERT_EQUALS("int x ( ) { return f < int > ( 123 ) ; } int f < int > ( int t ) { return t ; }", tok(code2));
ASSERT_EQUALS("int x ( ) { return f<int> ( 123 ) ; } int f<int> ( int t ) { return t ; }", tok(code2));
}
void template42() { // #4878 cpcheck aborts in ext-blocks.cpp (clang testcode)
@ -938,14 +938,14 @@ private:
const char expected[] = "template < class T > void Fred < T > :: f ( ) { } "
"template < class T > void Fred < T > :: g ( ) { } "
"template void Fred < float > :: f ( ) ; "
"template void Fred < int > :: g ( ) ; "
"class Fred < float > { void f ( ) ; void g ( ) ; } ; "
"Fred < float > :: f ( ) { } "
"Fred < float > :: g ( ) { } "
"class Fred < int > { void f ( ) ; void g ( ) ; } ; "
"Fred < int > :: f ( ) { } "
"Fred < int > :: g ( ) { }";
"template void Fred<float> :: f ( ) ; "
"template void Fred<int> :: g ( ) ; "
"class Fred<float> { void f ( ) ; void g ( ) ; } ; "
"Fred<float> :: f ( ) { } "
"Fred<float> :: g ( ) { } "
"class Fred<int> { void f ( ) ; void g ( ) ; } ; "
"Fred<int> :: f ( ) { } "
"Fred<int> :: g ( ) { }";
ASSERT_EQUALS(expected, tok(code));
}
@ -1020,11 +1020,11 @@ private:
// Similar problem can also happen with ...
ASSERT_EQUALS(
"A < int > a ( 0 ) ; struct A < int > { "
"A < int > ( int * p ) { p ; } "
"A<int> a ( 0 ) ; struct A<int> { "
"A<int> ( int * p ) { p ; } "
"} ; "
"struct A < int . . . > { "
"A < int . . . > ( int * p ) { "
"struct A<int...> { "
"A<int...> ( int * p ) { "
"p ; "
"} } ;",
tok("template <typename... T> struct A\n"
@ -1049,8 +1049,8 @@ private:
void template57() { // #7891
const char code[] = "template<class T> struct Test { Test(T); };\n"
"Test<unsigned long> test( 0 );";
const char exp [] = "Test < unsigned long > test ( 0 ) ; "
"struct Test < unsigned long > { Test < unsigned long > ( long ) ; } ;";
const char exp [] = "Test<unsignedlong> test ( 0 ) ; "
"struct Test<unsignedlong> { Test<unsignedlong> ( long ) ; } ;";
ASSERT_EQUALS(exp, tok(code));
}
@ -1063,9 +1063,9 @@ private:
" TestArithmetic<int>();\n"
"}";
const char exp[] = "void foo ( ) {"
" TestArithmetic < int > ( ) ; "
" TestArithmetic<int> ( ) ; "
"} "
"void TestArithmetic < int > ( ) {"
"void TestArithmetic<int> ( ) {"
" x ( CheckedNumeric < int > ( ) ) ; "
"}";
ASSERT_EQUALS(exp, tok(code));
@ -1087,13 +1087,13 @@ private:
"int main () {\n"
" return diagonalGroupTest<4>();\n"
"}";
const char exp[] = "struct Factorial < 0 > { enum FacHelper { value = 1 } ; } ; "
"int main ( ) { return diagonalGroupTest < 4 > ( ) ; } "
"int diagonalGroupTest < 4 > ( ) { return Factorial < 4 > :: value ; } "
"struct Factorial < 4 > { enum FacHelper { value = 4 * Factorial < 3 > :: value } ; } ; "
"struct Factorial < 3 > { enum FacHelper { value = 3 * Factorial < 2 > :: value } ; } ; "
"struct Factorial < 2 > { enum FacHelper { value = 2 * Factorial < 1 > :: value } ; } ; "
"struct Factorial < 1 > { enum FacHelper { value = Factorial < 0 > :: value } ; } ;";
const char exp[] = "struct Factorial<0> { enum FacHelper { value = 1 } ; } ; "
"int main ( ) { return diagonalGroupTest<4> ( ) ; } "
"int diagonalGroupTest<4> ( ) { return Factorial<4> :: value ; } "
"struct Factorial<4> { enum FacHelper { value = 4 * Factorial<3> :: value } ; } ; "
"struct Factorial<3> { enum FacHelper { value = 3 * Factorial<2> :: value } ; } ; "
"struct Factorial<2> { enum FacHelper { value = 2 * Factorial<1> :: value } ; } ; "
"struct Factorial<1> { enum FacHelper { value = Factorial < 0 > :: value } ; } ;";
ASSERT_EQUALS(exp, tok(code));
}
@ -1104,9 +1104,9 @@ private:
"\n"
"void j() { h<int>(); }";
const char exp[] = "template < typename T > void f ( ) { } " // <- TODO: This template is not expanded
"void j ( ) { h < int > ( ) ; } "
"void h < int > ( ) { f < S < int > :: type ( 0 ) > ( ) ; } "
"struct S < int > { } ;";
"void j ( ) { h<int> ( ) ; } "
"void h<int> ( ) { f < S<int> :: type ( 0 ) > ( ) ; } "
"struct S<int> { } ;";
ASSERT_EQUALS(exp, tok(code));
}
@ -1165,12 +1165,12 @@ private:
// The expected result..
const char expected[] = "void f ( ) "
"{"
" A < int , 2 > a1 ;"
" A < int , 3 > a2 ; "
" A<int,2> a1 ;"
" A<int,3> a2 ; "
"} "
"class A < int , 2 > "
"class A<int,2> "
"{ int ar [ 2 ] ; } ; "
"class A < int , 3 > "
"class A<int,3> "
"{ int ar [ 3 ] ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -1188,10 +1188,10 @@ private:
// The expected result..
const char expected[] = "void f ( ) "
"{"
" A < int , 3 , 2 > a1 ;"
" A < int , 3 , 2 > a2 ; "
" A<int,3,2> a1 ;"
" A<int,3,2> a2 ; "
"} "
"class A < int , 3 , 2 > "
"class A<int,3,2> "
"{ int ar [ 5 ] ; } ;";
ASSERT_EQUALS(expected, tok(code));
}
@ -1222,9 +1222,9 @@ private:
const char current[] = "void f ( ) "
"{ "
"A < int , ( int ) 2 > a1 ; "
"A < int , 3 > a2 ; "
"A<int,3> a2 ; "
"} "
"class A < int , 3 > "
"class A<int,3> "
"{ int ar [ 3 ] ; } ;";
TODO_ASSERT_EQUALS(wanted, current, tok(code));
}
@ -1247,8 +1247,8 @@ private:
"thv_table_c<void * , void * , DefaultMemory < void * , void *>> id_table_m ; "
"class thv_table_c<void * , void * , DefaultMemory < void * , void * >> { } ;";
const char curr[] = "template < class T , class U > class DefaultMemory { } ; "
"thv_table_c < void * , void * , DefaultMemory < Key , Val > > id_table_m ; "
"class thv_table_c < void * , void * , DefaultMemory < Key , Val > > { } ;";
"thv_table_c<void*,void*,DefaultMemory<Key,Val>> id_table_m ; "
"class thv_table_c<void*,void*,DefaultMemory<Key,Val>> { } ;";
TODO_ASSERT_EQUALS(exp, curr, tok(code));
}
}
@ -1399,8 +1399,8 @@ private:
"}\n"
"Fred<int>(123);";
ASSERT_EQUALS("namespace { } "
"Fred < int > ( 123 ) ; "
"void Fred < int > ( int value ) { }", tok(code));
"Fred<int> ( 123 ) ; "
"void Fred<int> ( int value ) { }", tok(code));
}
unsigned int templateParameters(const char code[]) {
@ -1487,8 +1487,8 @@ private:
}
void expandSpecialized() {
ASSERT_EQUALS("class A < int > { } ;", tok("template<> class A<int> {};"));
ASSERT_EQUALS("class A < int > : public B { } ;", tok("template<> class A<int> : public B {};"));
ASSERT_EQUALS("class A<int> { } ;", tok("template<> class A<int> {};"));
ASSERT_EQUALS("class A<int> : public B { } ;", tok("template<> class A<int> : public B {};"));
}
unsigned int instantiateMatch(const char code[], const std::string& name, const std::size_t numberOfArguments, const char patternAfter[]) {

View File

@ -830,11 +830,11 @@ private:
"template <class T> Containter<T>::Containter() : mElements(nullptr) {}\n"
"Containter<int> intContainer;";
const char exp [] = "5: template < class T > Containter < T > :: Containter ( ) : mElements ( nullptr ) { }\n"
"6: Containter < int > intContainer@1 ; struct Containter < int > {\n"
"2: Containter < int > ( ) ;\n"
"6: Containter<int> intContainer@1 ; struct Containter<int> {\n"
"2: Containter<int> ( ) ;\n"
"3: int * mElements@2 ;\n"
"4: } ;\n"
"5: Containter < int > :: Containter ( ) : mElements@2 ( nullptr ) { }\n";
"5: Containter<int> :: Containter ( ) : mElements@2 ( nullptr ) { }\n";
ASSERT_EQUALS(exp, tokenizeDebugListing(code, /*simplify=*/true));
}
}
@ -4965,7 +4965,7 @@ private:
"{\n"
" fn2<int>();\n"
"}\n";
ASSERT_EQUALS("int main ( )\n{\nfn2 < int > ( ) ;\n} void fn2 < int > ( int t = [ ] { return 1 ; } ( ) )\n{ }", tokenizeAndStringify(code));
ASSERT_EQUALS("int main ( )\n{\nfn2<int> ( ) ;\n} void fn2<int> ( int t = [ ] { return 1 ; } ( ) )\n{ }", tokenizeAndStringify(code));
}
void cpp0xtemplate2() {