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