diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c896d0030..76fba502b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2967,7 +2967,7 @@ std::list Tokenizer::simplifyTemplatesGetTemplateInstantiations() void Tokenizer::simplifyTemplatesUseDefaultArgumentValues(const std::list &templates, - const std::list &instantiations) + const std::list &templateInstantiations) { for (std::list::const_iterator iter1 = templates.begin(); iter1 != templates.end(); ++iter1) { // template parameters with default value has syntax such as: @@ -3002,7 +3002,7 @@ void Tokenizer::simplifyTemplatesUseDefaultArgumentValues(const std::list::const_iterator iter2 = instantiations.begin(); iter2 != instantiations.end(); ++iter2) { + for (std::list::const_iterator iter2 = templateInstantiations.begin(); iter2 != templateInstantiations.end(); ++iter2) { Token *tok = *iter2; if (!Token::Match(tok, (classname + " < %any%").c_str())) @@ -3122,7 +3122,7 @@ void Tokenizer::simplifyTemplatesExpandTemplate(const Token *tok, std::vector &type, const std::string &newName, std::vector &types2, - std::list &used) + std::list &templateInstantiations) { int _indentlevel = 0; int _parlevel = 0; @@ -3206,7 +3206,7 @@ void Tokenizer::simplifyTemplatesExpandTemplate(const Token *tok, if (Token::Match(tok3, "%type% <")) { //if (!Token::simpleMatch(tok3, (name + " <").c_str())) //done = false; - used.push_back(_tokensBack); + templateInstantiations.push_back(_tokensBack); } // link() newly tokens manually @@ -3238,7 +3238,7 @@ void Tokenizer::simplifyTemplatesExpandTemplate(const Token *tok, } void Tokenizer::simplifyTemplatesInstantiate(const Token *tok, - std::list &used, + std::list &templateInstantiations, std::set &expandedtemplates) { // this variable is not used at the moment. The intention was to @@ -3266,13 +3266,13 @@ void Tokenizer::simplifyTemplatesInstantiate(const Token *tok, const bool isfunc(tok->strAt(namepos + 1) == "("); // locate template usage.. - std::string::size_type sz1 = used.size(); + std::string::size_type sz1 = templateInstantiations.size(); unsigned int recursiveCount = 0; - for (std::list::const_iterator iter2 = used.begin(); iter2 != used.end(); ++iter2) { + for (std::list::const_iterator iter2 = templateInstantiations.begin(); iter2 != templateInstantiations.end(); ++iter2) { // If the size of "used" has changed, simplify calculations - if (sz1 != used.size()) { - sz1 = used.size(); + if (sz1 != templateInstantiations.size()) { + sz1 = templateInstantiations.size(); simplifyCalculations(); ++recursiveCount; if (recursiveCount > 100) { @@ -3355,7 +3355,7 @@ void Tokenizer::simplifyTemplatesInstantiate(const Token *tok, if (expandedtemplates.find(newName) == expandedtemplates.end()) { expandedtemplates.insert(newName); - simplifyTemplatesExpandTemplate(tok,name,type,newName,types2,used); + simplifyTemplatesExpandTemplate(tok,name,type,newName,types2,templateInstantiations); } // Replace all these template usages.. @@ -3388,7 +3388,7 @@ void Tokenizer::simplifyTemplatesInstantiate(const Token *tok, tok4->str(newName); for (Token *tok6 = tok4->next(); tok6 != tok5; tok6 = tok6->next()) { if (tok6->isName()) - used.remove(tok6); + templateInstantiations.remove(tok6); } removeTokens.push_back(std::pair(tok4, tok5->next())); } @@ -3432,16 +3432,16 @@ void Tokenizer::simplifyTemplates() } // Locate possible instantiations of templates.. - std::list used(simplifyTemplatesGetTemplateInstantiations()); + std::list templateInstantiations(simplifyTemplatesGetTemplateInstantiations()); // No template instantiations? Then remove all templates. - if (used.empty()) { + if (templateInstantiations.empty()) { removeTemplates(_tokens); return; } // Template arguments with default values - simplifyTemplatesUseDefaultArgumentValues(templates, used); + simplifyTemplatesUseDefaultArgumentValues(templates, templateInstantiations); // expand templates //bool done = false; @@ -3449,7 +3449,7 @@ void Tokenizer::simplifyTemplates() { //done = true; for (std::list::reverse_iterator iter1 = templates.rbegin(); iter1 != templates.rend(); ++iter1) { - simplifyTemplatesInstantiate(*iter1, used, expandedtemplates); + simplifyTemplatesInstantiate(*iter1, templateInstantiations, expandedtemplates); } } diff --git a/lib/tokenize.h b/lib/tokenize.h index 18c6675dd..503b2d3e2 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -473,20 +473,20 @@ public: /** * simplify template instantiations (use default argument values) * @param templates list of template declarations - * @param instantiations list of template instantiations + * @param templateInstantiations list of template instantiations */ void simplifyTemplatesUseDefaultArgumentValues(const std::list &templates, - const std::list &instantiations); + const std::list &templateInstantiations); /** * Simplify templates : expand all instantiatiations for a template * @todo It seems that inner templates should be instantiated recursively * @param tok token where the template declaration begins - * @param used a list of template usages (not necessarily just for this template) + * @param templateInstantiations a list of template usages (not necessarily just for this template) * @param expandedtemplates all templates that has been expanded so far. The full names are stored. */ void simplifyTemplatesInstantiate(const Token *tok, - std::list &used, + std::list &templateInstantiations, std::set &expandedtemplates); void simplifyTemplatesExpandTemplate(const Token *tok, @@ -494,7 +494,7 @@ public: std::vector &type, const std::string &newName, std::vector &types2, - std::list &used); + std::list &templateInstantiations); /** * Match template declaration/instantiation