Treat matches as mutually exclusive
This commit is contained in:
parent
248f468c67
commit
962f0ee584
|
@ -583,20 +583,6 @@ static void valueFlowArray(TokenList *tokenlist)
|
||||||
std::map<unsigned int, const Token *> constantArrays;
|
std::map<unsigned int, const Token *> constantArrays;
|
||||||
|
|
||||||
for (Token *tok = tokenlist->front(); tok; tok = tok->next()) {
|
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) {
|
if (tok->varId() > 0U) {
|
||||||
const std::map<unsigned int, const Token *>::const_iterator it = constantArrays.find(tok->varId());
|
const std::map<unsigned int, const Token *>::const_iterator it = constantArrays.find(tok->varId());
|
||||||
if (it != constantArrays.end()) {
|
if (it != constantArrays.end()) {
|
||||||
|
@ -604,6 +590,23 @@ static void valueFlowArray(TokenList *tokenlist)
|
||||||
value.tokvalue = it->second;
|
value.tokvalue = it->second;
|
||||||
setTokenValue(tok, value);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue