From 1492d8990f42035dba825f6207a87524e420818b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 19 Apr 2012 20:58:52 +0200 Subject: [PATCH] Tokenizer::setVarId: better C++ handling --- lib/tokenize.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6077a93f0..00076f5d4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2921,12 +2921,17 @@ void Tokenizer::setVarIdNew() (Token::Match(tok,"[(,]") && (!executableScope.top() || Token::simpleMatch(tok->link(), ") {")))) { // locate the variable name.. const Token *tok2 = (tok->isName()) ? tok : tok->next(); + + // private: protected: public: etc + while (tok2 && tok2->str()[tok2->str().size() - 1U] == ':') { + tok2 = tok2->next(); + } if (!tok2) break; // Variable declaration can't start with "return", etc if (tok2->str() == "return" || tok2->str() == "NOT" || tok2->str() == "goto" || - (!isC() && (tok2->str() == "delete" || tok2->str() == "throw" || tok2->str() == "using"))) + (!isC() && (tok2->str() == "delete" || tok2->str() == "friend" || tok2->str() == "throw" || tok2->str() == "using" || tok2->str() == "virtual"))) continue; const bool decl = setVarIdParseDeclaration(&tok2, variableId, executableScope.top()); @@ -2946,6 +2951,13 @@ void Tokenizer::setVarIdNew() } if (tok->isName()) { + if (!isC()) { + if (tok->previous() && tok->previous()->str() == "::") + continue; + if (tok->next() && tok->next()->str() == "::") + continue; + } + const std::map::const_iterator it = variableId.find(tok->str()); if (it != variableId.end()) { tok->varId(it->second);