@@ -57,11 +57,7 @@ namespace {
5757
5858const std::list<ValueFlow::Value> TokenImpl::mEmptyValueList ;
5959
60- Token::Token ()
61- : Token(static_cast <TokensFrontBack*>(nullptr ))
62- {}
63-
64- Token::Token (TokensFrontBack *tokensFrontBack) :
60+ Token::Token (TokensFrontBack &tokensFrontBack) :
6561 mTokensFrontBack(tokensFrontBack)
6662{
6763 mImpl = new TokenImpl ();
@@ -150,7 +146,7 @@ void Token::update_property_info()
150146 else if (std::isalpha ((unsigned char )mStr [0 ]) || mStr [0 ] == ' _' || mStr [0 ] == ' $' ) { // Name
151147 if (mImpl ->mVarId )
152148 tokType (eVariable);
153- else if (mTokensFrontBack && mTokensFrontBack -> list .isKeyword (mStr ))
149+ else if (mTokensFrontBack . list .isKeyword (mStr ))
154150 tokType (eKeyword);
155151 else if (baseKeywords.count (mStr ) > 0 )
156152 tokType (eKeyword);
@@ -296,8 +292,8 @@ void Token::deleteNext(nonneg int count)
296292
297293 if (mNext )
298294 mNext ->previous (this );
299- else if ( mTokensFrontBack )
300- mTokensFrontBack -> back = this ;
295+ else
296+ mTokensFrontBack . back = this ;
301297}
302298
303299void Token::deletePrevious (nonneg int count)
@@ -316,8 +312,8 @@ void Token::deletePrevious(nonneg int count)
316312
317313 if (mPrevious )
318314 mPrevious ->next (this );
319- else if ( mTokensFrontBack )
320- mTokensFrontBack -> front = this ;
315+ else
316+ mTokensFrontBack . front = this ;
321317}
322318
323319void Token::swapWithNext ()
@@ -400,10 +396,10 @@ void Token::replace(Token *replaceThis, Token *start, Token *end)
400396 start->previous (replaceThis->previous ());
401397 end->next (replaceThis->next ());
402398
403- if (end->mTokensFrontBack && end-> mTokensFrontBack -> back == end) {
399+ if (end->mTokensFrontBack . back == end) {
404400 while (end->next ())
405401 end = end->next ();
406- end->mTokensFrontBack -> back = end;
402+ end->mTokensFrontBack . back = end;
407403 }
408404
409405 // Update mProgressValue, fileIndex and linenr
@@ -1160,17 +1156,17 @@ Token* Token::insertToken(const std::string& tokenStr, const std::string& origin
11601156 if (this ->previous ()) {
11611157 newToken->previous (this ->previous ());
11621158 newToken->previous ()->next (newToken);
1163- } else if ( mTokensFrontBack ) {
1164- mTokensFrontBack -> front = newToken;
1159+ } else {
1160+ mTokensFrontBack . front = newToken;
11651161 }
11661162 this ->previous (newToken);
11671163 newToken->next (this );
11681164 } else {
11691165 if (this ->next ()) {
11701166 newToken->next (this ->next ());
11711167 newToken->next ()->previous (newToken);
1172- } else if ( mTokensFrontBack ) {
1173- mTokensFrontBack -> back = newToken;
1168+ } else {
1169+ mTokensFrontBack . back = newToken;
11741170 }
11751171 this ->next (newToken);
11761172 newToken->previous (this );
@@ -1820,7 +1816,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
18201816 else {
18211817 if (fileIndex != tok->fileIndex ()) {
18221818 outs += " File " ;
1823- outs += tok->mTokensFrontBack -> list .getFiles ()[tok->fileIndex ()];
1819+ outs += tok->mTokensFrontBack . list .getFiles ()[tok->fileIndex ()];
18241820 outs += ' \n ' ;
18251821 line = 0 ;
18261822 }
@@ -2749,8 +2745,5 @@ const Token* findLambdaEndScope(const Token* tok) {
27492745
27502746bool Token::isCpp () const
27512747{
2752- if (mTokensFrontBack ) {
2753- return mTokensFrontBack ->list .isCPP ();
2754- }
2755- return true ; // assume C++ by default
2748+ return mTokensFrontBack .list .isCPP ();
27562749}
0 commit comments