Skip to content

Commit 7b22594

Browse files
authored
Replaced 'tok->next()->link()' by 'tok->linkAt(1)' (#6476)
Fixes from #6472
1 parent eeef6b8 commit 7b22594

22 files changed

Lines changed: 107 additions & 107 deletions

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static bool isFunctionCall(const Token* tok)
484484
{
485485
if (Token::Match(tok, "%name% ("))
486486
return true;
487-
if (Token::Match(tok, "%name% <") && Token::simpleMatch(tok->next()->link(), "> ("))
487+
if (Token::Match(tok, "%name% <") && Token::simpleMatch(tok->linkAt(1), "> ("))
488488
return true;
489489
if (Token::Match(tok, "%name% ::"))
490490
return isFunctionCall(tok->tokAt(2));

lib/checkassert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void CheckAssert::assertWithSideEffects()
5555
if (!Token::simpleMatch(tok, "assert ("))
5656
continue;
5757

58-
const Token *endTok = tok->next()->link();
58+
const Token *endTok = tok->linkAt(1);
5959
for (const Token* tmp = tok->next(); tmp != endTok; tmp = tmp->next()) {
6060
if (Token::simpleMatch(tmp, "sizeof ("))
6161
tmp = tmp->linkAt(1);

lib/checkboost.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void CheckBoost::checkBoostForeachModification()
4040
if (!Token::simpleMatch(tok, "BOOST_FOREACH ("))
4141
continue;
4242

43-
const Token *containerTok = tok->next()->link()->previous();
43+
const Token *containerTok = tok->linkAt(1)->previous();
4444
if (!Token::Match(containerTok, "%var% ) {"))
4545
continue;
4646

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ void CheckBufferOverrun::stringNotZeroTerminated()
787787
}
788788
// Is the buffer zero terminated after the call?
789789
bool isZeroTerminated = false;
790-
for (const Token *tok2 = tok->next()->link(); tok2 != scope->bodyEnd; tok2 = tok2->next()) {
790+
for (const Token *tok2 = tok->linkAt(1); tok2 != scope->bodyEnd; tok2 = tok2->next()) {
791791
if (!Token::simpleMatch(tok2, "] ="))
792792
continue;
793793
const Token *rhs = tok2->next()->astOperand2();

lib/checkclass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
949949
ftok = ftok->next();
950950

951951
// Passing "this" => assume that everything is initialized
952-
for (const Token *tok2 = ftok->next()->link(); tok2 && tok2 != ftok; tok2 = tok2->previous()) {
952+
for (const Token *tok2 = ftok->linkAt(1); tok2 && tok2 != ftok; tok2 = tok2->previous()) {
953953
if (tok2->str() == "this") {
954954
assignAllVar(usage);
955955
return;
@@ -1020,7 +1020,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
10201020
// the function is external and it's neither friend nor inherited virtual function.
10211021
// assume all variables that are passed to it are initialized..
10221022
else {
1023-
for (const Token *tok = ftok->tokAt(2); tok && tok != ftok->next()->link(); tok = tok->next()) {
1023+
for (const Token *tok = ftok->tokAt(2); tok && tok != ftok->linkAt(1); tok = tok->next()) {
10241024
if (tok->isName()) {
10251025
assignVar(usage, tok->varId());
10261026
}

lib/checkcondition.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,9 +1803,9 @@ void CheckCondition::checkDuplicateConditionalAssign()
18031803
for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
18041804
if (!Token::simpleMatch(tok, "if ("))
18051805
continue;
1806-
if (!Token::simpleMatch(tok->next()->link(), ") {"))
1806+
if (!Token::simpleMatch(tok->linkAt(1), ") {"))
18071807
continue;
1808-
const Token *blockTok = tok->next()->link()->next();
1808+
const Token *blockTok = tok->linkAt(1)->next();
18091809
const Token *condTok = tok->next()->astOperand2();
18101810
const bool isBoolVar = Token::Match(condTok, "!| %var%");
18111811
if (!isBoolVar && !Token::Match(condTok, "==|!="))

lib/checkexceptionsafety.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ void CheckExceptionSafety::destructors()
6363
for (const Token *tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) {
6464
// Skip try blocks
6565
if (Token::simpleMatch(tok, "try {")) {
66-
tok = tok->next()->link();
66+
tok = tok->linkAt(1);
6767
}
6868

6969
// Skip uncaught exceptions
7070
else if (Token::simpleMatch(tok, "if ( ! std :: uncaught_exception ( ) ) {")) {
71-
tok = tok->next()->link(); // end of if ( ... )
72-
tok = tok->next()->link(); // end of { ... }
71+
tok = tok->linkAt(1); // end of if ( ... )
72+
tok = tok->linkAt(1); // end of { ... }
7373
}
7474

7575
// throw found within a destructor
@@ -183,8 +183,8 @@ void CheckExceptionSafety::checkRethrowCopy()
183183
const unsigned int varid = scope.bodyStart->tokAt(-2)->varId();
184184
if (varid) {
185185
for (const Token* tok = scope.bodyStart->next(); tok && tok != scope.bodyEnd; tok = tok->next()) {
186-
if (Token::simpleMatch(tok, "catch (") && tok->next()->link() && tok->next()->link()->next()) { // Don't check inner catch - it is handled in another iteration of outer loop.
187-
tok = tok->next()->link()->next()->link();
186+
if (Token::simpleMatch(tok, "catch (") && tok->linkAt(1) && tok->linkAt(1)->next()) { // Don't check inner catch - it is handled in another iteration of outer loop.
187+
tok = tok->linkAt(1)->next()->link();
188188
if (!tok)
189189
break;
190190
} else if (Token::Match(tok, "%varid% .", varid)) {

lib/checkleakautovar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
701701
continue;
702702
functionCall(ftok, openingPar, varInfo, allocation, af);
703703

704-
tok = ftok->next()->link();
704+
tok = ftok->linkAt(1);
705705

706706
// Handle scopes that might be noreturn
707707
if (allocation.status == VarInfo::NOALLOC && Token::simpleMatch(tok, ") ; }")) {

lib/checkmemoryleak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ void CheckMemoryLeakNoVar::checkForUnsafeArgAlloc(const Scope *scope)
11031103

11041104
for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
11051105
if (Token::Match(tok, "%name% (")) {
1106-
const Token *endParamToken = tok->next()->link();
1106+
const Token *endParamToken = tok->linkAt(1);
11071107
const Token* pointerType = nullptr;
11081108
const Token* functionCalled = nullptr;
11091109

lib/checknullpointer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
285285

286286
for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) {
287287
if (isUnevaluated(tok)) {
288-
tok = tok->next()->link();
288+
tok = tok->linkAt(1);
289289
continue;
290290
}
291291

@@ -347,15 +347,15 @@ void CheckNullPointer::nullConstantDereference()
347347

348348
for (; tok != scope->bodyEnd; tok = tok->next()) {
349349
if (isUnevaluated(tok))
350-
tok = tok->next()->link();
350+
tok = tok->linkAt(1);
351351

352352
else if (Token::simpleMatch(tok, "* 0")) {
353353
if (Token::Match(tok->previous(), "return|throw|;|{|}|:|[|(|,") || tok->previous()->isOp()) {
354354
nullPointerError(tok);
355355
}
356356
}
357357

358-
else if (Token::Match(tok, "0 [") && (tok->previous()->str() != "&" || !Token::Match(tok->next()->link()->next(), "[.(]")))
358+
else if (Token::Match(tok, "0 [") && (tok->previous()->str() != "&" || !Token::Match(tok->linkAt(1)->next(), "[.(]")))
359359
nullPointerError(tok);
360360

361361
else if (Token::Match(tok->previous(), "!!. %name% (|{") && (tok->previous()->str() != "::" || tok->strAt(-2) == "std")) {

0 commit comments

Comments
 (0)