From 960a0c6b115b594eaf1ddaa5e29a7530373cecaa Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sat, 29 Oct 2016 21:37:45 +0200 Subject: [PATCH] Token: Improved const correctness of findsimplematch() and findmatch(). There are no functional changes. --- lib/token.cpp | 8 ++++---- lib/token.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index ec7f1f531..ba8d5c721 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -843,7 +843,7 @@ Token * Token::findClosingBracket() //--------------------------------------------------------------------------- -const Token *Token::findsimplematch(const Token *startTok, const char pattern[]) +const Token *Token::findsimplematch(const Token * const startTok, const char pattern[]) { for (const Token* tok = startTok; tok; tok = tok->next()) { if (Token::simpleMatch(tok, pattern)) @@ -852,7 +852,7 @@ const Token *Token::findsimplematch(const Token *startTok, const char pattern[]) return 0; } -const Token *Token::findsimplematch(const Token *startTok, const char pattern[], const Token *end) +const Token *Token::findsimplematch(const Token * const startTok, const char pattern[], const Token * const end) { for (const Token* tok = startTok; tok && tok != end; tok = tok->next()) { if (Token::simpleMatch(tok, pattern)) @@ -861,7 +861,7 @@ const Token *Token::findsimplematch(const Token *startTok, const char pattern[], return nullptr; } -const Token *Token::findmatch(const Token *startTok, const char pattern[], unsigned int varId) +const Token *Token::findmatch(const Token * const startTok, const char pattern[], const unsigned int varId) { for (const Token* tok = startTok; tok; tok = tok->next()) { if (Token::Match(tok, pattern, varId)) @@ -870,7 +870,7 @@ const Token *Token::findmatch(const Token *startTok, const char pattern[], unsig return nullptr; } -const Token *Token::findmatch(const Token *startTok, const char pattern[], const Token *end, unsigned int varId) +const Token *Token::findmatch(const Token * const startTok, const char pattern[], const Token * const end, const unsigned int varId) { for (const Token* tok = startTok; tok && tok != end; tok = tok->next()) { if (Token::Match(tok, pattern, varId)) diff --git a/lib/token.h b/lib/token.h index 7ab5456b9..998c5d139 100644 --- a/lib/token.h +++ b/lib/token.h @@ -411,20 +411,20 @@ public: setFlag(fIsEnumType, value); } - static const Token *findsimplematch(const Token *startTok, const char pattern[]); - static const Token *findsimplematch(const Token *startTok, const char pattern[], const Token *end); - static const Token *findmatch(const Token *startTok, const char pattern[], unsigned int varId = 0); - static const Token *findmatch(const Token *startTok, const char pattern[], const Token *end, unsigned int varId = 0); - static Token *findsimplematch(Token *startTok, const char pattern[]) { + static const Token *findsimplematch(const Token * const startTok, const char pattern[]); + static const Token *findsimplematch(const Token * const startTok, const char pattern[], const Token * const end); + static const Token *findmatch(const Token * const startTok, const char pattern[], const unsigned int varId = 0U); + static const Token *findmatch(const Token * const startTok, const char pattern[], const Token * const end, const unsigned int varId = 0U); + static Token *findsimplematch(Token * const startTok, const char pattern[]) { return const_cast(findsimplematch(const_cast(startTok), pattern)); } - static Token *findsimplematch(Token *startTok, const char pattern[], const Token *end) { + static Token *findsimplematch(Token * const startTok, const char pattern[], const Token * const end) { return const_cast(findsimplematch(const_cast(startTok), pattern, end)); } - static Token *findmatch(Token *startTok, const char pattern[], unsigned int varId = 0) { + static Token *findmatch(Token * const startTok, const char pattern[], const unsigned int varId = 0U) { return const_cast(findmatch(const_cast(startTok), pattern, varId)); } - static Token *findmatch(Token *startTok, const char pattern[], const Token *end, unsigned int varId = 0) { + static Token *findmatch(Token * const startTok, const char pattern[], const Token * const end, const unsigned int varId = 0U) { return const_cast(findmatch(const_cast(startTok), pattern, end, varId)); }