--check-headers=no: remove more templates in headers that are not used in the source file

This commit is contained in:
Daniel Marjamäki 2019-03-03 20:18:19 +01:00
parent d84dbf6b5f
commit c5a512338e
1 changed files with 17 additions and 15 deletions

View File

@ -4327,24 +4327,26 @@ void Tokenizer::simplifyHeaders()
Token::eraseTokens(tok, endToken->link()->next());
}
if (Token::simpleMatch(tok->next(), "template <")) {
if (Token::Match(tok->next(), "template < %name%")) {
const Token *tok2 = tok->tokAt(3);
while (Token::Match(tok2, "%name% %name% ,"))
tok2 = tok2->tokAt(3);
if (Token::Match(tok2, "%name% %name% >")) {
tok2 = tok2->tokAt(3);
if (Token::Match(tok2, "class|struct %name% [;:{]") && keep.find(tok2->strAt(1)) == keep.end()) {
const Token *endToken = tok2->tokAt(2);
if (endToken->str() == ":") {
while (Token::Match(tok2, "%name% %name% [,=>]")) {
tok2 = tok2->tokAt(2);
if (Token::Match(tok2, "= %name% [,>]"))
tok2 = tok2->tokAt(2);
if (tok2->str() == ",")
tok2 = tok2->next();
}
if (Token::Match(tok2, "> class|struct %name% [;:{]") && keep.find(tok2->strAt(2)) == keep.end()) {
const Token *endToken = tok2->tokAt(3);
if (endToken->str() == ":") {
endToken = endToken->next();
while (Token::Match(endToken, "%name%|,"))
endToken = endToken->next();
while (Token::Match(endToken, "%name%|,"))
endToken = endToken->next();
}
if (endToken && endToken->str() == "{")
endToken = endToken->link()->next();
if (endToken && endToken->str() == ";")
Token::eraseTokens(tok, endToken);
}
if (endToken && endToken->str() == "{")
endToken = endToken->link()->next();
if (endToken && endToken->str() == ";")
Token::eraseTokens(tok, endToken);
}
}
}