From 1be1af4afb26a832153fd3fd015e31f5f3060a8b Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Thu, 27 Oct 2011 01:24:35 +0200 Subject: [PATCH] Move the simplification of 'strlen' in simplifyTokenList. This way it's possible to omit the call to simplifyKnownVariables before 'strlen'. --- lib/tokenize.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 779dde147..4a03f4069 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3992,19 +3992,6 @@ bool Tokenizer::simplifyTokenList() simplifySizeof(); - // replace strlen(str) - simplifyKnownVariables(); - for (Token *tok = _tokens; tok; tok = tok->next()) { - if (Token::Match(tok, "strlen ( %str% )")) { - std::ostringstream ostr; - ostr << Token::getStrLength(tok->tokAt(2)); - tok->str(ostr.str()); - tok->deleteNext(); - tok->deleteNext(); - tok->deleteNext(); - } - } - // change array to pointer.. for (Token *tok = _tokens; tok; tok = tok->next()) { if (Token::Match(tok, "%type% %var% [ ] [,;=]")) { @@ -4155,6 +4142,18 @@ bool Tokenizer::simplifyTokenList() modified |= simplifyCalculations(); } + // replace strlen(str) + for (Token *tok = _tokens; tok; tok = tok->next()) { + if (Token::Match(tok, "strlen ( %str% )")) { + std::ostringstream ostr; + ostr << Token::getStrLength(tok->tokAt(2)); + tok->str(ostr.str()); + tok->deleteNext(); + tok->deleteNext(); + tok->deleteNext(); + } + } + // simplify redundant for removeRedundantFor();