fixed tests, unused templates are removed by default
This commit is contained in:
parent
9947774ab7
commit
f6527fcd9b
|
@ -4784,7 +4784,7 @@ void Tokenizer::simplifyHeaders()
|
|||
// Maybe if --dump is used we want to have _everything_.
|
||||
|
||||
if (mSettings->checkHeaders && mSettings->checkUnusedTemplates)
|
||||
// Default=full analysis. All information in the headers are kept.
|
||||
// Full analysis. All information in the headers are kept.
|
||||
return;
|
||||
|
||||
const bool checkHeaders = mSettings->checkHeaders;
|
||||
|
@ -4824,7 +4824,7 @@ void Tokenizer::simplifyHeaders()
|
|||
const bool isIncluded = (tok->fileIndex() != 0);
|
||||
|
||||
// Remove executable code
|
||||
if (isIncluded && mSettings->checkHeaders && tok->str() == "{") {
|
||||
if (isIncluded && !mSettings->checkHeaders && tok->str() == "{") {
|
||||
// TODO: We probably need to keep the executable code if this function is called from the source file.
|
||||
const Token *prev = tok->previous();
|
||||
while (prev && prev->isName())
|
||||
|
|
|
@ -386,8 +386,7 @@ private:
|
|||
|
||||
// The expected result..
|
||||
const char expected[] = "class A<int> ; "
|
||||
"void f ( ) { A<int> a ; } "
|
||||
"template < typename T > class B { void g ( ) { A < T > b ; b = A < T > :: h ( ) ; } } ; "
|
||||
"void f ( ) { A<int> a ; } ; "
|
||||
"class A<int> { } ;";
|
||||
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
|
@ -1386,7 +1385,6 @@ private:
|
|||
"template <class T, unsigned S> C3<T, S>::C3(const C3<T, S> &v) { C1<T *> c1; }\n"
|
||||
"C3<int,6> c3;";
|
||||
const char exp[] = "struct C1<int*> ; "
|
||||
"template < class T > void f ( ) { x = y ? ( C1 < int > :: allocate ( 1 ) ) : 0 ; } "
|
||||
"class C3<int,6> ; "
|
||||
"C3<int,6> c3 ; "
|
||||
"class C3<int,6> { } ; "
|
||||
|
@ -2394,7 +2392,6 @@ private:
|
|||
"template <typename T> class Fred {};\n"
|
||||
"ObjectCache<Fred> _cache;";
|
||||
const char exp[] = "class ObjectCache<Fred> ; "
|
||||
"template < typename T > class Fred { } ; "
|
||||
"ObjectCache<Fred> _cache ; "
|
||||
"class ObjectCache<Fred> { } ;";
|
||||
ASSERT_EQUALS(exp, tok(code));
|
||||
|
@ -2502,8 +2499,7 @@ private:
|
|||
"template < class T > struct Unconst < const T & > { } ; "
|
||||
"template < class T > struct Unconst < T * const > { } ; "
|
||||
"template < class T1 , class T2 > struct type_equal { enum Anonymous0 { value = 0 } ; } ; "
|
||||
"template < class T > struct type_equal < T , T > { enum Anonymous1 { value = 1 } ; } ; "
|
||||
"template < class T > struct template_is_const { enum Anonymous2 { value = ! type_equal < T , Unconst < T > :: type > :: value } ; } ;";
|
||||
"template < class T > struct type_equal < T , T > { enum Anonymous1 { value = 1 } ; } ;";
|
||||
ASSERT_EQUALS(exp1, tok(code1));
|
||||
}
|
||||
|
||||
|
@ -2743,7 +2739,7 @@ private:
|
|||
const char code[] = "class Fred {\n"
|
||||
" template<class T> explicit Fred(T t) { }\n"
|
||||
"}";
|
||||
ASSERT_EQUALS("class Fred { template < class T > explicit Fred ( T t ) { } }", tok(code));
|
||||
ASSERT_EQUALS("class Fred { }", tok(code));
|
||||
|
||||
// #3532
|
||||
const char code2[] = "class Fred {\n"
|
||||
|
|
|
@ -80,8 +80,6 @@ private:
|
|||
TEST_CASE(simplifyTypedef36); // ticket #1434
|
||||
TEST_CASE(simplifyTypedef37); // ticket #1449
|
||||
TEST_CASE(simplifyTypedef38);
|
||||
TEST_CASE(simplifyTypedef39);
|
||||
TEST_CASE(simplifyTypedef40);
|
||||
TEST_CASE(simplifyTypedef43); // ticket #1588
|
||||
TEST_CASE(simplifyTypedef44);
|
||||
TEST_CASE(simplifyTypedef45); // ticket #1613
|
||||
|
@ -1190,23 +1188,6 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef39() {
|
||||
const char code[] = "typedef int A;\n"
|
||||
"template <const A, volatile A> struct S{};";
|
||||
const char expected[] = "template < const int , volatile int > struct S { } ;";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef40() {
|
||||
const char code[] = "typedef int A;\n"
|
||||
"typedef int B;\n"
|
||||
"template <class A, class B> class C { };";
|
||||
const char expected[] = "template < class A , class B > class C { } ;";
|
||||
ASSERT_EQUALS(expected, tok(code, false));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef43() {
|
||||
// ticket #1588
|
||||
{
|
||||
|
@ -2546,8 +2527,7 @@ private:
|
|||
"template <long, class> struct c; "
|
||||
"template <int g> struct d { enum { e = c<g, b>::f }; };";
|
||||
const char exp [] = "class a ; "
|
||||
"template < long , class > struct c ; "
|
||||
"template < int g > struct d { enum Anonymous0 { e = c < g , int ( a :: * ) > :: f } ; } ;";
|
||||
"template < long , class > struct c ;";
|
||||
ASSERT_EQUALS(exp, tok(code, false));
|
||||
}
|
||||
|
||||
|
|
|
@ -489,9 +489,7 @@ private:
|
|||
"class c { "
|
||||
"int i ; i = 0 ; "
|
||||
"c ( ) { i -- ; } "
|
||||
"} ; "
|
||||
"template < class T > "
|
||||
"class s { } ;";
|
||||
"} ;";
|
||||
|
||||
ASSERT_EQUALS(exp, tok(code, true, Settings::Win64));
|
||||
}
|
||||
|
|
|
@ -211,7 +211,9 @@ private:
|
|||
"template<class T> void g()\n"
|
||||
"{\n"
|
||||
" f();\n"
|
||||
"}");
|
||||
"}\n"
|
||||
"\n"
|
||||
"void h() { g<int>(); h(); }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue