Tokenizer::simplifyTemplates: Broke out the functionality that extract a list of template instantiations
This commit is contained in:
parent
25d6bfe3c4
commit
00bdf618f2
|
@ -2646,37 +2646,10 @@ std::list<Token *> Tokenizer::simplifyTemplatesGetTemplateDeclarations()
|
|||
return templates;
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyTemplates()
|
||||
std::list<Token *> Tokenizer::simplifyTemplatesGetTemplateInstantiations()
|
||||
{
|
||||
std::set<std::string> expandedtemplates(simplifyTemplatesExpandSpecialized());
|
||||
|
||||
// Locate templates..
|
||||
std::list<Token *> templates(simplifyTemplatesGetTemplateDeclarations());
|
||||
|
||||
if (templates.empty())
|
||||
{
|
||||
removeTemplates(_tokens);
|
||||
return;
|
||||
}
|
||||
|
||||
// There are templates..
|
||||
// Remove "typename" unless used in template arguments..
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() == "typename")
|
||||
tok->deleteThis();
|
||||
|
||||
if (Token::simpleMatch(tok, "template <"))
|
||||
{
|
||||
while (tok && tok->str() != ">")
|
||||
tok = tok->next();
|
||||
if (!tok)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Locate possible instantiations of templates..
|
||||
std::list<Token *> used;
|
||||
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
// template definition.. skip it
|
||||
|
@ -2717,6 +2690,41 @@ void Tokenizer::simplifyTemplates()
|
|||
}
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyTemplates()
|
||||
{
|
||||
std::set<std::string> expandedtemplates(simplifyTemplatesExpandSpecialized());
|
||||
|
||||
// Locate templates..
|
||||
std::list<Token *> templates(simplifyTemplatesGetTemplateDeclarations());
|
||||
|
||||
if (templates.empty())
|
||||
{
|
||||
removeTemplates(_tokens);
|
||||
return;
|
||||
}
|
||||
|
||||
// There are templates..
|
||||
// Remove "typename" unless used in template arguments..
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (tok->str() == "typename")
|
||||
tok->deleteThis();
|
||||
|
||||
if (Token::simpleMatch(tok, "template <"))
|
||||
{
|
||||
while (tok && tok->str() != ">")
|
||||
tok = tok->next();
|
||||
if (!tok)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Locate possible instantiations of templates..
|
||||
std::list<Token *> used(simplifyTemplatesGetTemplateInstantiations());
|
||||
|
||||
// No template instantiations? Then remove all templates.
|
||||
if (used.empty())
|
||||
{
|
||||
|
|
|
@ -409,6 +409,12 @@ public:
|
|||
*/
|
||||
std::list<Token *> simplifyTemplatesGetTemplateDeclarations();
|
||||
|
||||
/**
|
||||
* Get template instantiations
|
||||
* @return list of template instantiations
|
||||
*/
|
||||
std::list<Token *> simplifyTemplatesGetTemplateInstantiations();
|
||||
|
||||
/**
|
||||
* Used after simplifyTemplates to perform a little cleanup.
|
||||
* Sometimes the simplifyTemplates isn't fully successful and then
|
||||
|
|
Loading…
Reference in New Issue