Skip to content

Commit 5050327

Browse files
authored
fixed some Tokenizer::isFunctionHead() parameters (danmar#7353)
The function is supposed to take a simple list of characters to look for but some callers were providing a `Token::Match()`-like expression.
1 parent 1cedd12 commit 5050327

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/templatesimplifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,14 @@ bool TemplateSimplifier::getTemplateNamePositionTemplateFunction(const Token *to
14421442
} else if (Token::Match(tok->next(), "%type% <")) {
14431443
const Token *closing = tok->tokAt(2)->findClosingBracket();
14441444
if (closing) {
1445-
if (closing->strAt(1) == "(" && TokenList::isFunctionHead(closing->next(), ";|{|:"))
1445+
if (closing->strAt(1) == "(" && TokenList::isFunctionHead(closing->next(), ";{:"))
14461446
return true;
14471447
while (tok->next() && tok->next() != closing) {
14481448
tok = tok->next();
14491449
namepos++;
14501450
}
14511451
}
1452-
} else if (Token::Match(tok->next(), "%type% (") && TokenList::isFunctionHead(tok->tokAt(2), ";|{|:")) {
1452+
} else if (Token::Match(tok->next(), "%type% (") && TokenList::isFunctionHead(tok->tokAt(2), ";{:")) {
14531453
return true;
14541454
}
14551455
tok = tok->next();

lib/tokenize.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,7 +2790,7 @@ bool Tokenizer::isMemberFunction(const Token *openParen)
27902790
{
27912791
return (Token::Match(openParen->tokAt(-2), ":: %name% (") ||
27922792
Token::Match(openParen->tokAt(-3), ":: ~ %name% (")) &&
2793-
TokenList::isFunctionHead(openParen, "{|:");
2793+
TokenList::isFunctionHead(openParen, "{:");
27942794
}
27952795

27962796
static bool scopesMatch(const std::string &scope1, const std::string &scope2, const ScopeInfo3 *globalScope)
@@ -4356,7 +4356,7 @@ static void setVarIdStructMembers(Token *&tok1,
43564356
while (Token::Match(tok->next(), ")| . %name% !!(")) {
43574357
// Don't set varid for trailing return type
43584358
if (tok->strAt(1) == ")" && Token::Match(tok->linkAt(1)->tokAt(-1), "%name%|]") && !tok->linkAt(1)->tokAt(-1)->isKeyword() &&
4359-
TokenList::isFunctionHead(tok->linkAt(1), "{|;")) {
4359+
TokenList::isFunctionHead(tok->linkAt(1), "{;")) {
43604360
tok = tok->tokAt(3);
43614361
continue;
43624362
}
@@ -8976,7 +8976,7 @@ void Tokenizer::simplifyFunctionTryCatch()
89768976
for (Token * tok = list.front(); tok; tok = tok->next()) {
89778977
if (!Token::Match(tok, "try {|:"))
89788978
continue;
8979-
if (!TokenList::isFunctionHead(tok->previous(), "try"))
8979+
if (!TokenList::isFunctionHead(tok->previous(), "try")) // TODO: this is supposed to a list of characters and not strings
89808980
continue;
89818981

89828982
Token* tryStartToken = skipInitializerList(tok->next());
@@ -9418,7 +9418,7 @@ void Tokenizer::simplifyCPPAttribute()
94189418
head = skipCPPOrAlignAttribute(head)->next();
94199419
while (Token::Match(head, "%name%|::|*|&|<|>|,")) // skip return type
94209420
head = head->next();
9421-
if (head && head->str() == "(" && TokenList::isFunctionHead(head, "{|;")) {
9421+
if (head && head->str() == "(" && TokenList::isFunctionHead(head, "{;")) {
94229422
head->previous()->isAttributeNoreturn(true);
94239423
}
94249424
} else if (Token::findsimplematch(tok->tokAt(2), "nodiscard", tok->link())) {
@@ -9427,7 +9427,7 @@ void Tokenizer::simplifyCPPAttribute()
94279427
head = skipCPPOrAlignAttribute(head)->next();
94289428
while (Token::Match(head, "%name%|::|*|&|<|>|,"))
94299429
head = head->next();
9430-
if (head && head->str() == "(" && TokenList::isFunctionHead(head, "{|;")) {
9430+
if (head && head->str() == "(" && TokenList::isFunctionHead(head, "{;")) {
94319431
head->previous()->isAttributeNodiscard(true);
94329432
}
94339433
} else if ((hasMaybeUnusedUnderscores && Token::findsimplematch(tok->tokAt(2), "__maybe_unused__", tok->link()))
@@ -10226,7 +10226,7 @@ void Tokenizer::createSymbolDatabase()
1022610226
bool Tokenizer::operatorEnd(const Token * tok)
1022710227
{
1022810228
if (tok && tok->str() == ")") {
10229-
if (TokenList::isFunctionHead(tok, "{|;|?|:|["))
10229+
if (TokenList::isFunctionHead(tok, "{;?:["))
1023010230
return true;
1023110231

1023210232
tok = tok->next();

0 commit comments

Comments
 (0)