From 9dabd17eae6d422ef327f15dcd8a561369c8174c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 3 Jan 2016 08:23:48 +0100 Subject: [PATCH] Tokenizer::isFunctionHead(): Handling of C++ methods only in isCPP() condition. --- lib/tokenize.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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;