From be8fc0f89f4564d72773d45066d58b97236a590b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 3 Jan 2016 00:01:29 +0100 Subject: [PATCH] SymbolDatabase: Better handling of default and delete when reusing Tokenizer::isFunctionHead() --- lib/symboldatabase.cpp | 16 +++------------- lib/tokenize.cpp | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 54cb477ab..2ed7af2c4 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -466,26 +466,16 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti tok = tok->linkAt(1)->next(); } - if (Token::Match(tok, "= 0|default ;")) { + if (Token::Match(tok, "= %any% ;")) { function.isPure(tok->strAt(1) == "0"); + function.isDefault(tok->strAt(1) == "default"); + function.isDelete(tok->strAt(1) == "delete"); tok = tok->tokAt(2); } scope->addFunction(function); } - // default or delete - else if (Token::Match(end, ") = default|delete ;")) { - if (end->strAt(2) == "default") - function.isDefault(true); - else - function.isDelete(true); - - tok = end->tokAt(3); - - scope->addFunction(function); - } - // noexcept; // noexcept = 0; // const noexcept; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4b95cc11a..c34f040de 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -64,7 +64,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end tok = tok->next(); if (Token::Match(tok, "&|&&")) tok = tok->next(); - if (Token::Match(tok, "= 0|default ;")) + if (Token::Match(tok, "= 0|default|delete ;")) tok = tok->tokAt(2); return (endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr; } @@ -75,7 +75,7 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end tok = tok->link()->next(); while (tok && tok->isName()) tok = tok->next(); - if (Token::Match(tok, "= 0|default ;")) + if (Token::Match(tok, "= 0|default|delete ;")) tok = tok->tokAt(2); return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr; }