renamed _tokensFrontBack to mTokensFrontBack

This commit is contained in:
Daniel Marjamäki 2018-06-16 16:22:35 +02:00
parent 26d58ddbb9
commit cc521bef99
4 changed files with 52 additions and 52 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), mTokensFrontBack(tokensFrontBack),
mNext(nullptr), mNext(nullptr),
mPrevious(nullptr), mPrevious(nullptr),
_link(nullptr), _link(nullptr),
@ -219,8 +219,8 @@ void Token::deleteNext(unsigned long index)
if (mNext) if (mNext)
mNext->previous(this); mNext->previous(this);
else if (_tokensFrontBack) else if (mTokensFrontBack)
_tokensFrontBack->back = this; mTokensFrontBack->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 (mPrevious) if (mPrevious)
mPrevious->next(this); mPrevious->next(this);
else if (_tokensFrontBack) else if (mTokensFrontBack)
_tokensFrontBack->front = this; mTokensFrontBack->front = this;
} }
void Token::swapWithNext() void Token::swapWithNext()
@ -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->mTokensFrontBack && end->mTokensFrontBack->back == end) {
while (end->next()) while (end->next())
end = end->next(); end = end->next();
end->_tokensFrontBack->back = end; end->mTokensFrontBack->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(mTokensFrontBack);
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 (mTokensFrontBack) {
_tokensFrontBack->back = newToken; mTokensFrontBack->back = newToken;
} }
this->next(newToken); this->next(newToken);
newToken->previous(this); newToken->previous(this);

View File

@ -62,7 +62,7 @@ struct TokensFrontBack {
*/ */
class CPPCHECKLIB Token { class CPPCHECKLIB Token {
private: private:
TokensFrontBack* _tokensFrontBack; TokensFrontBack* mTokensFrontBack;
// Not implemented.. // Not implemented..
Token(const Token &); Token(const Token &);

View File

@ -38,7 +38,7 @@ static const unsigned int AST_MAX_DEPTH = 50U;
TokenList::TokenList(const Settings* settings) : TokenList::TokenList(const Settings* settings) :
_tokensFrontBack(), mTokensFrontBack(),
mSettings(settings), mSettings(settings),
_isC(false), _isC(false),
_isCPP(false) _isCPP(false)
@ -65,9 +65,9 @@ const std::string& TokenList::getSourceFilePath() const
// Deallocate lists.. // Deallocate lists..
void TokenList::deallocateTokens() void TokenList::deallocateTokens()
{ {
deleteTokens(_tokensFrontBack.front); deleteTokens(mTokensFrontBack.front);
_tokensFrontBack.front = nullptr; mTokensFrontBack.front = nullptr;
_tokensFrontBack.back = nullptr; mTokensFrontBack.back = nullptr;
_files.clear(); _files.clear();
} }
@ -141,18 +141,18 @@ void TokenList::addtoken(std::string str, const unsigned int lineno, const unsig
str = MathLib::value(str).str() + suffix; str = MathLib::value(str).str() + suffix;
} }
if (_tokensFrontBack.back) { if (mTokensFrontBack.back) {
_tokensFrontBack.back->insertToken(str); mTokensFrontBack.back->insertToken(str);
} else { } else {
_tokensFrontBack.front = new Token(&_tokensFrontBack); mTokensFrontBack.front = new Token(&mTokensFrontBack);
_tokensFrontBack.back = _tokensFrontBack.front; mTokensFrontBack.back = mTokensFrontBack.front;
_tokensFrontBack.back->str(str); mTokensFrontBack.back->str(str);
} }
if (isCPP() && str == "delete") if (isCPP() && str == "delete")
_tokensFrontBack.back->isKeyword(true); mTokensFrontBack.back->isKeyword(true);
_tokensFrontBack.back->linenr(lineno); mTokensFrontBack.back->linenr(lineno);
_tokensFrontBack.back->fileIndex(fileno); mTokensFrontBack.back->fileIndex(fileno);
} }
void TokenList::addtoken(const Token * tok, const unsigned int lineno, const unsigned int fileno) void TokenList::addtoken(const Token * tok, const unsigned int lineno, const unsigned int fileno)
@ -160,19 +160,19 @@ void TokenList::addtoken(const Token * tok, const unsigned int lineno, const uns
if (tok == nullptr) if (tok == nullptr)
return; return;
if (_tokensFrontBack.back) { if (mTokensFrontBack.back) {
_tokensFrontBack.back->insertToken(tok->str(), tok->originalName()); mTokensFrontBack.back->insertToken(tok->str(), tok->originalName());
} else { } else {
_tokensFrontBack.front = new Token(&_tokensFrontBack); mTokensFrontBack.front = new Token(&mTokensFrontBack);
_tokensFrontBack.back = _tokensFrontBack.front; mTokensFrontBack.back = mTokensFrontBack.front;
_tokensFrontBack.back->str(tok->str()); mTokensFrontBack.back->str(tok->str());
if (!tok->originalName().empty()) if (!tok->originalName().empty())
_tokensFrontBack.back->originalName(tok->originalName()); mTokensFrontBack.back->originalName(tok->originalName());
} }
_tokensFrontBack.back->linenr(lineno); mTokensFrontBack.back->linenr(lineno);
_tokensFrontBack.back->fileIndex(fileno); mTokensFrontBack.back->fileIndex(fileno);
_tokensFrontBack.back->flags(tok->flags()); mTokensFrontBack.back->flags(tok->flags());
} }
@ -304,20 +304,20 @@ void TokenList::createTokens(const simplecpp::TokenList *tokenList)
if (str.size() > 1 && str[0] == '.' && std::isdigit(str[1])) if (str.size() > 1 && str[0] == '.' && std::isdigit(str[1]))
str = '0' + str; str = '0' + str;
if (_tokensFrontBack.back) { if (mTokensFrontBack.back) {
_tokensFrontBack.back->insertToken(str); mTokensFrontBack.back->insertToken(str);
} else { } else {
_tokensFrontBack.front = new Token(&_tokensFrontBack); mTokensFrontBack.front = new Token(&mTokensFrontBack);
_tokensFrontBack.back = _tokensFrontBack.front; mTokensFrontBack.back = mTokensFrontBack.front;
_tokensFrontBack.back->str(str); mTokensFrontBack.back->str(str);
} }
if (isCPP() && _tokensFrontBack.back->str() == "delete") if (isCPP() && mTokensFrontBack.back->str() == "delete")
_tokensFrontBack.back->isKeyword(true); mTokensFrontBack.back->isKeyword(true);
_tokensFrontBack.back->fileIndex(tok->location.fileIndex); mTokensFrontBack.back->fileIndex(tok->location.fileIndex);
_tokensFrontBack.back->linenr(tok->location.line); mTokensFrontBack.back->linenr(tok->location.line);
_tokensFrontBack.back->col(tok->location.col); mTokensFrontBack.back->col(tok->location.col);
_tokensFrontBack.back->isExpandedMacro(!tok->macro.empty()); mTokensFrontBack.back->isExpandedMacro(!tok->macro.empty());
} }
if (mSettings && mSettings->relativePaths) { if (mSettings && mSettings->relativePaths) {
@ -325,7 +325,7 @@ void TokenList::createTokens(const simplecpp::TokenList *tokenList)
_files[i] = Path::getRelativePath(_files[i], mSettings->basePaths); _files[i] = Path::getRelativePath(_files[i], mSettings->basePaths);
} }
Token::assignProgressValues(_tokensFrontBack.front); Token::assignProgressValues(mTokensFrontBack.front);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1163,7 +1163,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
void TokenList::createAst() void TokenList::createAst()
{ {
for (Token *tok = _tokensFrontBack.front; tok; tok = tok ? tok->next() : nullptr) { for (Token *tok = mTokensFrontBack.front; tok; tok = tok ? tok->next() : nullptr) {
tok = createAstAtToken(tok, isCPP()); tok = createAstAtToken(tok, isCPP());
} }
} }
@ -1172,7 +1172,7 @@ void TokenList::validateAst() const
{ {
// Check for some known issues in AST to avoid crash/hang later on // Check for some known issues in AST to avoid crash/hang later on
std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion
for (const Token *tok = _tokensFrontBack.front; tok; tok = tok->next()) { for (const Token *tok = mTokensFrontBack.front; tok; tok = tok->next()) {
// Syntax error if binary operator only has 1 operand // Syntax error if binary operator only has 1 operand
if ((tok->isAssignmentOp() || tok->isComparisonOp() || Token::Match(tok,"[|^/%]")) && tok->astOperand1() && !tok->astOperand2()) if ((tok->isAssignmentOp() || tok->isComparisonOp() || Token::Match(tok,"[|^/%]")) && tok->astOperand1() && !tok->astOperand2())
throw InternalError(tok, "Syntax Error: AST broken, binary operator has only one operand.", InternalError::AST); throw InternalError(tok, "Syntax Error: AST broken, binary operator has only one operand.", InternalError::AST);
@ -1216,7 +1216,7 @@ bool TokenList::validateToken(const Token* tok) const
{ {
if (!tok) if (!tok)
return true; return true;
for (const Token *t = _tokensFrontBack.front; t; t = t->next()) { for (const Token *t = mTokensFrontBack.front; t; t = t->next()) {
if (tok==t) if (tok==t)
return true; return true;
} }

View File

@ -105,18 +105,18 @@ public:
/** get first token of list */ /** get first token of list */
const Token *front() const { const Token *front() const {
return _tokensFrontBack.front; return mTokensFrontBack.front;
} }
Token *front() { Token *front() {
return _tokensFrontBack.front; return mTokensFrontBack.front;
} }
/** get last token of list */ /** get last token of list */
const Token *back() const { const Token *back() const {
return _tokensFrontBack.back; return mTokensFrontBack.back;
} }
Token *back() { Token *back() {
return _tokensFrontBack.back; return mTokensFrontBack.back;
} }
/** /**
@ -182,7 +182,7 @@ private:
TokenList &operator=(const TokenList &); TokenList &operator=(const TokenList &);
/** Token list */ /** Token list */
TokensFrontBack _tokensFrontBack; TokensFrontBack mTokensFrontBack;
/** filenames for the tokenized source code (source + included) */ /** filenames for the tokenized source code (source + included) */
std::vector<std::string> _files; std::vector<std::string> _files;