From 25ba399a50bcc6cff1ef570ee2dddfec3f35ce1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 24 Jan 2010 13:45:56 +0100 Subject: [PATCH] const class functions: refactorings --- lib/checkclass.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 6f5219073..6e127b06c 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1406,7 +1406,7 @@ void CheckClass::checkConst() for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { - if (Token::Match(tok, "class|struct %var% :|{")) + if (Token::Match(tok, "class|struct %var% {")) { // get class name.. const std::string classname(tok->strAt(1)); @@ -1425,9 +1425,17 @@ void CheckClass::checkConst() else if (tok2->str() == "}") break; + // start of statement? + if (!Token::Match(tok2->previous(), "[;{}]")) + continue; + + // skip private: public: etc + if (tok2->isName() && tok2->str().find(":") != std::string::npos) + tok2 = tok2->next(); + // member function? - if (Token::Match(tok2, "[;}] %type% %var% (") || - Token::Match(tok2, "[;}] %type% operator %any% (")) + if (Token::Match(tok2, "%type% %var% (") || + Token::Match(tok2, "%type% operator %any% (")) { // goto function name.. while (tok2->next()->str() != "(")