Tokenizer: Improved removal of unused template (#9588)
This commit is contained in:
parent
7921aa891a
commit
bda73600e0
|
@ -96,7 +96,7 @@ public:
|
||||||
* be turned off to save CPU */
|
* be turned off to save CPU */
|
||||||
bool checkHeaders;
|
bool checkHeaders;
|
||||||
|
|
||||||
/** Check unused templates */
|
/** Check unused/uninstantiated templates */
|
||||||
bool checkUnusedTemplates;
|
bool checkUnusedTemplates;
|
||||||
|
|
||||||
/** Use Clang */
|
/** Use Clang */
|
||||||
|
|
|
@ -5072,8 +5072,8 @@ void Tokenizer::simplifyHeaders()
|
||||||
if (removeUnusedTemplates || (isIncluded && removeUnusedIncludedTemplates)) {
|
if (removeUnusedTemplates || (isIncluded && removeUnusedIncludedTemplates)) {
|
||||||
if (Token::Match(tok->next(), "template < %name%")) {
|
if (Token::Match(tok->next(), "template < %name%")) {
|
||||||
const Token *tok2 = tok->tokAt(3);
|
const Token *tok2 = tok->tokAt(3);
|
||||||
while (Token::Match(tok2, "%name% %name% [,=>]") || Token::Match(tok2, "typename ... %name% [,>]")) {
|
while (Token::Match(tok2, "%name% %name% [,=>]") || Token::Match(tok2, "typename|class ... %name% [,>]")) {
|
||||||
if (Token::simpleMatch(tok2, "typename ..."))
|
if (Token::Match(tok2, "typename|class ..."))
|
||||||
tok2 = tok2->tokAt(3);
|
tok2 = tok2->tokAt(3);
|
||||||
else
|
else
|
||||||
tok2 = tok2->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
|
|
|
@ -994,6 +994,12 @@ private:
|
||||||
" std::tuple<a...> c{std::move(d)};\n"
|
" std::tuple<a...> c{std::move(d)};\n"
|
||||||
" return std::get<0>(c);\n"
|
" return std::get<0>(c);\n"
|
||||||
"}", s));
|
"}", s));
|
||||||
|
ASSERT_EQUALS("int g ( int ) ;",
|
||||||
|
tokenizeAndStringify("int g(int);\n"
|
||||||
|
"template <class F, class... Ts> auto h(F f, Ts... xs) {\n"
|
||||||
|
" auto e = f(g(xs)...);\n"
|
||||||
|
" return e;\n"
|
||||||
|
"}", s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue