From 962f0ee58444a9a8c825a28dc8c79d209d82085c Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 28 Aug 2015 15:27:56 +0300 Subject: [PATCH] Treat matches as mutually exclusive --- lib/valueflow.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 11db0bffc..c85143f52 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -583,20 +583,6 @@ static void valueFlowArray(TokenList *tokenlist) std::map constantArrays; for (Token *tok = tokenlist->front(); tok; tok = tok->next()) { - if (Token::Match(tok, "const %type% %var% [ %num%| ] = {")) { - const Token *vartok = tok->tokAt(2); - const Token *rhstok = vartok->next()->link()->tokAt(2); - constantArrays[vartok->varId()] = rhstok; - tok = rhstok->link(); - } - - if (Token::Match(tok, "const char %var% [ %num%| ] = %str% ;")) { - const Token *vartok = tok->tokAt(2); - const Token *strtok = vartok->next()->link()->tokAt(2); - constantArrays[vartok->varId()] = strtok; - tok = strtok->next(); - } - if (tok->varId() > 0U) { const std::map::const_iterator it = constantArrays.find(tok->varId()); if (it != constantArrays.end()) { @@ -604,6 +590,23 @@ static void valueFlowArray(TokenList *tokenlist) value.tokvalue = it->second; setTokenValue(tok, value); } + continue; + } + + if (Token::Match(tok, "const %type% %var% [ %num%| ] = {")) { + const Token *vartok = tok->tokAt(2); + const Token *rhstok = vartok->next()->link()->tokAt(2); + constantArrays[vartok->varId()] = rhstok; + tok = rhstok->link(); + continue; + } + + if (Token::Match(tok, "const char %var% [ %num%| ] = %str% ;")) { + const Token *vartok = tok->tokAt(2); + const Token *strtok = vartok->next()->link()->tokAt(2); + constantArrays[vartok->varId()] = strtok; + tok = strtok->next(); + continue; } } }