diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c34f040de..134403638 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -58,23 +58,20 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end return nullptr; if (tok->str() == "(") tok = tok->link(); - if (Token::Match(tok, ") const| &|&&| [;:{=]")) { + if (Token::Match(tok, ") const| [;{]")) { tok = tok->next(); if (tok->isName()) tok = tok->next(); - if (Token::Match(tok, "&|&&")) - tok = tok->next(); - if (Token::Match(tok, "= 0|default|delete ;")) - tok = tok->tokAt(2); return (endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr; } - if (isCPP() && Token::Match(tok, ") const| throw|noexcept (")) { + if (isCPP() && (Token::Match(tok, ") const| throw|noexcept (") || Token::Match(tok, ") const| &|&&| [;:{=]"))) { tok = tok->next(); while (tok->isName()) tok = tok->next(); - tok = tok->link()->next(); - while (tok && tok->isName()) + if (Token::Match(tok, "&|&&")) tok = tok->next(); + if (tok->str() == "(") + tok = tok->link()->next(); if (Token::Match(tok, "= 0|default|delete ;")) tok = tok->tokAt(2); return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;