| 706 | } |
| 707 | |
| 708 | static void valueFlowArrayBool(TokenList& tokenlist, const Settings& settings) |
| 709 | { |
| 710 | for (Token* tok = tokenlist.front(); tok; tok = tok->next()) { |
| 711 | if (tok->hasKnownIntValue()) |
| 712 | continue; |
| 713 | const Variable* var = nullptr; |
| 714 | bool known = false; |
| 715 | const auto val = |
| 716 | std::find_if(tok->values().cbegin(), tok->values().cend(), std::mem_fn(&ValueFlow::Value::isTokValue)); |
| 717 | if (val == tok->values().end()) { |
| 718 | var = tok->variable(); |
| 719 | known = true; |
| 720 | } else { |
| 721 | var = val->tokvalue->variable(); |
| 722 | known = val->isKnown(); |
| 723 | } |
| 724 | if (!var) |
| 725 | continue; |
| 726 | if (!var->isArray() || var->isArgument() || var->isStlType()) |
| 727 | continue; |
| 728 | if (isNonZero(getOtherOperand(tok)) && Token::Match(tok->astParent(), "%comp%")) |
| 729 | continue; |
| 730 | // TODO: Check for function argument |
| 731 | if ((astIsBool(tok->astParent()) && !Token::Match(tok->astParent(), "(|%name%")) || |
| 732 | (tok->astParent() && Token::Match(tok->astParent()->previous(), "if|while|for ("))) { |
| 733 | ValueFlow::Value value{1}; |
| 734 | if (known) |
| 735 | value.setKnown(); |
| 736 | setTokenValue(tok, std::move(value), settings); |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | static void valueFlowArrayElement(TokenList& tokenlist, const Settings& settings) |
| 742 | { |
no test coverage detected