Skip to content

Commit cf5d8fa

Browse files
committed
Use Token::link() instead of Token::findClosingBracket() whereever possible
1 parent fdac502 commit cf5d8fa

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,8 @@ void Variable::evaluate()
998998
setFlag(fIsReference, true); // Set also fIsReference
999999
}
10001000

1001-
if (tok->str() == "<")
1002-
tok->findClosingBracket(tok);
1001+
if (tok->str() == "<" && tok->link())
1002+
tok = tok->link();
10031003
else
10041004
tok = tok->next();
10051005
}
@@ -1373,7 +1373,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
13731373
while (tok2 && tok2->str() != "{") {
13741374
// skip unsupported templates
13751375
if (tok2->str() == "<")
1376-
tok2->findClosingBracket(tok2);
1376+
tok2 = tok2->link();
13771377

13781378
// check for base classes
13791379
else if (Token::Match(tok2, ":|,")) {
@@ -1828,8 +1828,8 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
18281828
while (tok->next()->str() == "[")
18291829
tok = tok->next()->link();
18301830
} else if (tok->str() == "<") {
1831-
bool success = tok->findClosingBracket(tok);
1832-
if (!tok || !success) // something is wrong so just bail out
1831+
tok = tok->link();
1832+
if (!tok) // something is wrong so just bail out
18331833
return;
18341834
}
18351835

@@ -2297,9 +2297,8 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const
22972297
const Token* localVarTok = NULL;
22982298

22992299
if (Token::Match(localTypeTok, "%type% <")) {
2300-
const Token* closeTok = NULL;
2301-
bool found = localTypeTok->next()->findClosingBracket(closeTok);
2302-
if (found) {
2300+
const Token* closeTok = localTypeTok->next()->link();
2301+
if (closeTok) {
23032302
localVarTok = skipPointers(closeTok->next());
23042303

23052304
if (Token::Match(localVarTok, ":: %type% %var% ;|=|(")) {

lib/tokenize.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4637,8 +4637,7 @@ void Tokenizer::simplifyCasts()
46374637
}
46384638

46394639
while (Token::Match(tok->next(), "dynamic_cast|reinterpret_cast|const_cast|static_cast <")) {
4640-
Token *tok2 = tok->next();
4641-
tok2->next()->findClosingBracket(tok2);
4640+
Token *tok2 = tok->linkAt(2);
46424641

46434642
if (Token::simpleMatch(tok2, "> (")) {
46444643
Token *closeBracket = tok2->next()->link();
@@ -7930,8 +7929,7 @@ void Tokenizer::simplifyComma()
79307929

79317930
// Skip unhandled template specifiers..
79327931
if (Token::Match(tok, "%var% <")) {
7933-
Token* tok2;
7934-
tok->next()->findClosingBracket(tok2);
7932+
Token* tok2 = tok->next()->link();
79357933
if (tok2)
79367934
tok = tok2;
79377935
}

0 commit comments

Comments
 (0)