Refactoring: Add _ prefix to Token member variables (#1280)

This commit is contained in:
amai2012 2018-06-09 08:14:24 +02:00 committed by Daniel Marjamäki
parent 8d53bcfd63
commit db7d267c02
2 changed files with 25 additions and 25 deletions

View File

@ -36,7 +36,7 @@
const std::list<ValueFlow::Value> Token::emptyValueList; const std::list<ValueFlow::Value> Token::emptyValueList;
Token::Token(TokensFrontBack *tokensFrontBack) : Token::Token(TokensFrontBack *tokensFrontBack) :
tokensFrontBack(tokensFrontBack), _tokensFrontBack(tokensFrontBack),
_next(nullptr), _next(nullptr),
_previous(nullptr), _previous(nullptr),
_link(nullptr), _link(nullptr),
@ -54,7 +54,7 @@ Token::Token(TokensFrontBack *tokensFrontBack) :
_astOperand2(nullptr), _astOperand2(nullptr),
_astParent(nullptr), _astParent(nullptr),
_originalName(nullptr), _originalName(nullptr),
valuetype(nullptr), _valuetype(nullptr),
_values(nullptr) _values(nullptr)
{ {
} }
@ -62,7 +62,7 @@ Token::Token(TokensFrontBack *tokensFrontBack) :
Token::~Token() Token::~Token()
{ {
delete _originalName; delete _originalName;
delete valuetype; delete _valuetype;
delete _values; delete _values;
} }
@ -219,8 +219,8 @@ void Token::deleteNext(unsigned long index)
if (_next) if (_next)
_next->previous(this); _next->previous(this);
else if (tokensFrontBack) else if (_tokensFrontBack)
tokensFrontBack->back = this; _tokensFrontBack->back = this;
} }
void Token::deletePrevious(unsigned long index) void Token::deletePrevious(unsigned long index)
@ -239,8 +239,8 @@ void Token::deletePrevious(unsigned long index)
if (_previous) if (_previous)
_previous->next(this); _previous->next(this);
else if (tokensFrontBack) else if (_tokensFrontBack)
tokensFrontBack->front = this; _tokensFrontBack->front = this;
} }
void Token::swapWithNext() void Token::swapWithNext()
@ -261,7 +261,7 @@ void Token::swapWithNext()
std::swap(_function, _next->_function); std::swap(_function, _next->_function);
std::swap(_originalName, _next->_originalName); std::swap(_originalName, _next->_originalName);
std::swap(_values, _next->_values); std::swap(_values, _next->_values);
std::swap(valuetype, _next->valuetype); std::swap(_valuetype, _next->_valuetype);
std::swap(_progressValue, _next->_progressValue); std::swap(_progressValue, _next->_progressValue);
} }
} }
@ -285,9 +285,9 @@ void Token::takeData(Token *fromToken)
delete _values; delete _values;
_values = fromToken->_values; _values = fromToken->_values;
fromToken->_values = nullptr; fromToken->_values = nullptr;
delete valuetype; delete _valuetype;
valuetype = fromToken->valuetype; _valuetype = fromToken->_valuetype;
fromToken->valuetype = nullptr; fromToken->_valuetype = nullptr;
if (_link) if (_link)
_link->link(this); _link->link(this);
} }
@ -332,10 +332,10 @@ void Token::replace(Token *replaceThis, Token *start, Token *end)
start->previous(replaceThis->previous()); start->previous(replaceThis->previous());
end->next(replaceThis->next()); end->next(replaceThis->next());
if (end->tokensFrontBack && end->tokensFrontBack->back == end) { if (end->_tokensFrontBack && end->_tokensFrontBack->back == end) {
while (end->next()) while (end->next())
end = end->next(); end = end->next();
end->tokensFrontBack->back = end; end->_tokensFrontBack->back = end;
} }
// Update _progressValue, fileIndex and linenr // Update _progressValue, fileIndex and linenr
@ -926,7 +926,7 @@ void Token::insertToken(const std::string &tokenStr, const std::string &original
if (_str.empty()) if (_str.empty())
newToken = this; newToken = this;
else else
newToken = new Token(tokensFrontBack); newToken = new Token(_tokensFrontBack);
newToken->str(tokenStr); newToken->str(tokenStr);
if (!originalNameStr.empty()) if (!originalNameStr.empty())
newToken->originalName(originalNameStr); newToken->originalName(originalNameStr);
@ -949,8 +949,8 @@ void Token::insertToken(const std::string &tokenStr, const std::string &original
if (this->next()) { if (this->next()) {
newToken->next(this->next()); newToken->next(this->next());
newToken->next()->previous(newToken); newToken->next()->previous(newToken);
} else if (tokensFrontBack) { } else if (_tokensFrontBack) {
tokensFrontBack->back = newToken; _tokensFrontBack->back = newToken;
} }
this->next(newToken); this->next(newToken);
newToken->previous(this); newToken->previous(this);
@ -1334,8 +1334,8 @@ std::string Token::astStringVerbose(const unsigned int indent1, const unsigned i
if (isExpandedMacro()) if (isExpandedMacro())
ret += '$'; ret += '$';
ret += _str; ret += _str;
if (valuetype) if (_valuetype)
ret += " \'" + valuetype->str() + '\''; ret += " \'" + _valuetype->str() + '\'';
ret += '\n'; ret += '\n';
if (_astOperand1) { if (_astOperand1) {
@ -1658,9 +1658,9 @@ void Token::assignProgressValues(Token *tok)
void Token::setValueType(ValueType *vt) void Token::setValueType(ValueType *vt)
{ {
if (vt != valuetype) { if (vt != _valuetype) {
delete valuetype; delete _valuetype;
valuetype = vt; _valuetype = vt;
} }
} }

View File

@ -62,7 +62,7 @@ struct TokensFrontBack {
*/ */
class CPPCHECKLIB Token { class CPPCHECKLIB Token {
private: private:
TokensFrontBack* tokensFrontBack; TokensFrontBack* _tokensFrontBack;
// Not implemented.. // Not implemented..
Token(const Token &); Token(const Token &);
@ -234,7 +234,7 @@ public:
static std::string getCharAt(const Token *tok, std::size_t index); static std::string getCharAt(const Token *tok, std::size_t index);
const ValueType *valueType() const { const ValueType *valueType() const {
return valuetype; return _valuetype;
} }
void setValueType(ValueType *vt); void setValueType(ValueType *vt);
@ -242,7 +242,7 @@ public:
const Token *top = this; const Token *top = this;
while (top && !Token::Match(top->astParent(), ",|(")) while (top && !Token::Match(top->astParent(), ",|("))
top = top->astParent(); top = top->astParent();
return top ? top->valuetype : nullptr; return top ? top->_valuetype : nullptr;
} }
Token::Type tokType() const { Token::Type tokType() const {
@ -997,7 +997,7 @@ private:
std::string* _originalName; std::string* _originalName;
// ValueType // ValueType
ValueType *valuetype; ValueType *_valuetype;
// ValueFlow // ValueFlow
std::list<ValueFlow::Value>* _values; std::list<ValueFlow::Value>* _values;