template simplifier: also remove forward declarations when removing expanded templates (#1536)
This commit is contained in:
parent
becc6f112a
commit
d528934139
|
@ -2237,8 +2237,13 @@ void TemplateSimplifier::simplifyTemplates(
|
|||
Token * tok = it->token;
|
||||
tok->deleteNext(2);
|
||||
tok->deleteThis();
|
||||
} else
|
||||
} else {
|
||||
// remove forward declaration if found
|
||||
auto it1 = mTemplateForwardDeclarationsMap.find(it->token);
|
||||
if (it1 != mTemplateForwardDeclarationsMap.end())
|
||||
removeTemplate(it1->second);
|
||||
removeTemplate(it->token);
|
||||
}
|
||||
mTemplateDeclarations.erase(decl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1843,7 +1843,7 @@ private:
|
|||
" A<int> a2;\n"
|
||||
"}\n";
|
||||
|
||||
const char wanted[] = "class A<int,2> ; "
|
||||
const char exp[] = "class A<int,2> ; "
|
||||
"class A<int,3> ; "
|
||||
"void f ( ) "
|
||||
"{"
|
||||
|
@ -1854,19 +1854,7 @@ private:
|
|||
"{ int ar [ 2 ] ; } ; "
|
||||
"class A<int,3> "
|
||||
"{ int ar [ 3 ] ; } ;";
|
||||
const char current[] = "template < class T , int n = 3 > class A ; "
|
||||
"class A<int,2> ; "
|
||||
"class A<int,3> ; "
|
||||
"void f ( ) "
|
||||
"{"
|
||||
" A<int,2> a1 ;"
|
||||
" A<int,3> a2 ; "
|
||||
"} "
|
||||
"class A<int,2> "
|
||||
"{ int ar [ 2 ] ; } ; "
|
||||
"class A<int,3> "
|
||||
"{ int ar [ 3 ] ; } ;";
|
||||
TODO_ASSERT_EQUALS(wanted, current, tok(code));
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
{
|
||||
const char code[] = "template <class, int = 3> class A;\n"
|
||||
|
@ -1880,7 +1868,7 @@ private:
|
|||
" A<int> a2;\n"
|
||||
"}\n";
|
||||
|
||||
const char wanted[] = "class A<int,2> ; "
|
||||
const char exp[] = "class A<int,2> ; "
|
||||
"class A<int,3> ; "
|
||||
"void f ( ) "
|
||||
"{"
|
||||
|
@ -1891,19 +1879,7 @@ private:
|
|||
"{ int ar [ 2 ] ; } ; "
|
||||
"class A<int,3> "
|
||||
"{ int ar [ 3 ] ; } ;";
|
||||
const char current[] = "template < class , int = 3 > class A ; "
|
||||
"class A<int,2> ; "
|
||||
"class A<int,3> ; "
|
||||
"void f ( ) "
|
||||
"{"
|
||||
" A<int,2> a1 ;"
|
||||
" A<int,3> a2 ; "
|
||||
"} "
|
||||
"class A<int,2> "
|
||||
"{ int ar [ 2 ] ; } ; "
|
||||
"class A<int,3> "
|
||||
"{ int ar [ 3 ] ; } ;";
|
||||
TODO_ASSERT_EQUALS(wanted, current, tok(code));
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2291,7 +2267,6 @@ private:
|
|||
"void SomeFunction ( ) { } "
|
||||
"private: "
|
||||
"int TemplatedMethod<int> ( int ) ; "
|
||||
"template < typename T > T TemplatedMethod ( T ) ; " // this should be removed
|
||||
"} ; "
|
||||
"} int MyNamespace :: TestClass :: TemplatedMethod<int> ( int t ) { return t ; }", tok(code));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue