diff --git a/lib/token.cpp b/lib/token.cpp index b488afb4b..ce30afae8 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -42,7 +42,7 @@ Token::Token(TokensFrontBack *tokensFrontBack) : _link(nullptr), _scope(nullptr), _function(nullptr), // Initialize whole union - _varId(0), + mVarId(0), _fileIndex(0), _linenr(0), _col(0), @@ -88,7 +88,7 @@ void Token::update_property_info() if (_str == "true" || _str == "false") tokType(eBoolean); else if (std::isalpha((unsigned char)_str[0]) || _str[0] == '_' || _str[0] == '$') { // Name - if (_varId) + if (mVarId) tokType(eVariable); else if (_tokType != eVariable && _tokType != eFunction && _tokType != eType && _tokType != eKeyword) tokType(eName); @@ -249,7 +249,7 @@ void Token::swapWithNext() std::swap(_str, mNext->_str); std::swap(_tokType, mNext->_tokType); std::swap(mFlags, mNext->mFlags); - std::swap(_varId, mNext->_varId); + std::swap(mVarId, mNext->mVarId); std::swap(_fileIndex, mNext->_fileIndex); std::swap(_linenr, mNext->_linenr); if (mNext->_link) @@ -271,7 +271,7 @@ void Token::takeData(Token *fromToken) _str = fromToken->_str; tokType(fromToken->_tokType); mFlags = fromToken->mFlags; - _varId = fromToken->_varId; + mVarId = fromToken->mVarId; _fileIndex = fromToken->_fileIndex; _linenr = fromToken->_linenr; _link = fromToken->_link; @@ -1024,8 +1024,8 @@ void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) os << _str[i]; } } - if (varid && _varId != 0) - os << '@' << _varId; + if (varid && mVarId != 0) + os << '@' << mVarId; } std::string Token::stringifyList(bool varid, bool attributes, bool linenumbers, bool linebreaks, bool files, const std::vector* fileNames, const Token* end) const @@ -1621,7 +1621,7 @@ bool Token::addValue(const ValueFlow::Value &value) if (it->isInconclusive() && !value.isInconclusive()) { *it = value; if (it->varId == 0) - it->varId = _varId; + it->varId = mVarId; break; } @@ -1633,13 +1633,13 @@ bool Token::addValue(const ValueFlow::Value &value) if (it == _values->end()) { ValueFlow::Value v(value); if (v.varId == 0) - v.varId = _varId; + v.varId = mVarId; _values->push_back(v); } } else { ValueFlow::Value v(value); if (v.varId == 0) - v.varId = _varId; + v.varId = mVarId; _values = new std::list(1, v); } diff --git a/lib/token.h b/lib/token.h index 39c1d567a..3956c5d0c 100644 --- a/lib/token.h +++ b/lib/token.h @@ -84,7 +84,7 @@ public: template void str(T&& s) { _str = s; - _varId = 0; + mVarId = 0; update_property_info(); } @@ -559,10 +559,10 @@ public: unsigned int varId() const { - return _varId; + return mVarId; } void varId(unsigned int id) { - _varId = id; + mVarId = id; if (id != 0) { tokType(eVariable); isStandardType(false); @@ -696,7 +696,7 @@ public: */ void variable(const Variable *v) { _variable = v; - if (v || _varId) + if (v || mVarId) tokType(eVariable); else if (_tokType == eVariable) tokType(eName); @@ -918,7 +918,7 @@ private: const Enumerator *_enumerator; }; - unsigned int _varId; + unsigned int mVarId; unsigned int _fileIndex; unsigned int _linenr; unsigned int _col; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c93281a46..a084fe12e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -143,7 +143,7 @@ Tokenizer::Tokenizer() : mSettings(nullptr), mErrorLogger(nullptr), mSymbolDatabase(nullptr), - _varId(0), + mVarId(0), _unnamedCount(0), _codeWithTemplates(false), //is there any templates? _timerResults(nullptr) @@ -158,7 +158,7 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) : mSettings(settings), mErrorLogger(errorLogger), mSymbolDatabase(nullptr), - _varId(0), + mVarId(0), _unnamedCount(0), _codeWithTemplates(false), //is there any templates? _timerResults(nullptr) @@ -2525,7 +2525,7 @@ static void setVarIdClassFunction(const std::string &classname, const Token * const endToken, const std::map &varlist, std::map >& structMembers, - unsigned int *_varId) + unsigned int *varId_) { for (Token *tok2 = startToken; tok2 && tok2 != endToken; tok2 = tok2->next()) { if (tok2->varId() != 0 || !tok2->isName()) @@ -2540,7 +2540,7 @@ static void setVarIdClassFunction(const std::string &classname, const std::map::const_iterator it = varlist.find(tok2->str()); if (it != varlist.end()) { tok2->varId(it->second); - setVarIdStructMembers(&tok2, structMembers, _varId); + setVarIdStructMembers(&tok2, structMembers, varId_); } } } @@ -2842,7 +2842,7 @@ void Tokenizer::setVarIdPass1() } } - _varId = *variableMap.getVarId(); + mVarId = *variableMap.getVarId(); } namespace { @@ -3057,7 +3057,7 @@ void Tokenizer::setVarIdPass2() if (tok2->link()) { if (tok2->str() == "{") { if (tok2->strAt(-1) == ")" || tok2->strAt(-2) == ")") - setVarIdClassFunction(scopeName2 + classname, tok2, tok2->link(), thisClassVars, structMembers, &_varId); + setVarIdClassFunction(scopeName2 + classname, tok2, tok2->link(), thisClassVars, structMembers, &mVarId); tok2 = tok2->link(); } else if (tok2->str() == "(" && tok2->link()->strAt(1) != "(") tok2 = tok2->link(); @@ -3097,7 +3097,7 @@ void Tokenizer::setVarIdPass2() // If this is a function implementation.. add it to funclist Token * start = const_cast(isFunctionHead(tok2, "{")); if (start) { - setVarIdClassFunction(classname, start, start->link(), thisClassVars, structMembers, &_varId); + setVarIdClassFunction(classname, start, start->link(), thisClassVars, structMembers, &mVarId); } if (Token::Match(tok2, ") %name% (")) @@ -3131,7 +3131,7 @@ void Tokenizer::setVarIdPass2() tok3 = tok3->linkAt(1); } if (Token::Match(tok3, ")|} {")) { - setVarIdClassFunction(classname, tok2, tok3->next()->link(), thisClassVars, structMembers, &_varId); + setVarIdClassFunction(classname, tok2, tok3->next()->link(), thisClassVars, structMembers, &mVarId); } } } @@ -8658,7 +8658,7 @@ void Tokenizer::simplifyFuncInWhile() Token *var = tok->tokAt(4); Token *end = tok->next()->link()->next()->link(); - const unsigned int varid = ++_varId; // Create new variable + const unsigned int varid = ++mVarId; // Create new variable const std::string varname("cppcheck:r" + MathLib::toString(++count)); tok->str("int"); tok->next()->insertToken(varname); @@ -9937,7 +9937,7 @@ void Tokenizer::printUnknownTypes() const std::multimap unknowns; - for (unsigned int i = 1; i <= _varId; ++i) { + for (unsigned int i = 1; i <= mVarId; ++i) { const Variable *var = mSymbolDatabase->getVariableFromVarId(i); if (!var) continue; diff --git a/lib/tokenize.h b/lib/tokenize.h index d21fb6542..dd505140d 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -795,7 +795,7 @@ public: * @return number of variables */ unsigned int varIdCount() const { - return _varId; + return mVarId; } /** @@ -859,7 +859,7 @@ private: * @return new variable id */ unsigned int newVarId() { - return ++_varId; + return ++mVarId; } /** Set pod types */ @@ -882,7 +882,7 @@ private: std::map _typeSize; /** variable count */ - unsigned int _varId; + unsigned int mVarId; /** unnamed count "Unnamed0", "Unnamed1", "Unnamed2", ... */ unsigned int _unnamedCount;