From 5d8f506d6b0aacab872eb03885a16feb76dec9fd Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Tue, 20 Jan 2009 21:21:12 +0000 Subject: [PATCH] Tokenizer: Remove 'unlikely' keyword in simplifyTokenList; Don't check for it in CheckMemoryLeak. --- src/checkmemoryleak.cpp | 2 -- src/tokenize.cpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index ad9f5c4ad..6432ef442 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -333,8 +333,6 @@ bool CheckMemoryLeakClass::notvar(const Token *tok, const char *varnames[]) return bool(Token::Match(tok, std::string("! " + varname + " [;)&|]").c_str()) || Token::simpleMatch(tok, std::string("! ( " + varname + " )").c_str()) || - Token::simpleMatch(tok, std::string("unlikely ( ! " + varname + " )").c_str()) || - Token::simpleMatch(tok, std::string("unlikely ( " + varname + " == 0 )").c_str()) || Token::Match(tok, std::string("0 == " + varname + " [;)&|]").c_str()) || Token::simpleMatch(tok, std::string(varname + " == 0").c_str())); } diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 9465abc78..4437fe495 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -541,13 +541,17 @@ void Tokenizer::setVarId() void Tokenizer::simplifyTokenList() { - - // Remove the keyword 'unsigned' + // Remove unwanted keywords + static const char* unwantedWords[] = { "unsigned", "unlikely" }; for (Token *tok = _tokens; tok; tok = tok->next()) { - if (tok->next() && (tok->next()->str() == "unsigned")) + for (unsigned ui = 0; ui < sizeof(unwantedWords) / sizeof(unwantedWords[0]) && tok->next(); ui++) { - tok->deleteNext(); + if (tok->next()->str() == unwantedWords[ui]) + { + tok->deleteNext(); + break; + } } }