| 3765 | } |
| 3766 | |
| 3767 | static std::set<MathLib::bigint> getSwitchValues(const Token *startbrace, bool &hasDefault) |
| 3768 | { |
| 3769 | std::set<MathLib::bigint> values; |
| 3770 | const Token *endbrace = startbrace->link(); |
| 3771 | if (!endbrace) |
| 3772 | return values; |
| 3773 | |
| 3774 | hasDefault = false; |
| 3775 | for (const Token *tok = startbrace->next(); tok && tok != endbrace; tok = tok->next()) { |
| 3776 | if (Token::simpleMatch(tok, "{") && tok->scope()->type == ScopeType::eSwitch) { |
| 3777 | tok = tok->link(); |
| 3778 | continue; |
| 3779 | } |
| 3780 | if (Token::simpleMatch(tok, "default")) { |
| 3781 | hasDefault = true; |
| 3782 | break; |
| 3783 | } |
| 3784 | if (Token::simpleMatch(tok, "case")) { |
| 3785 | const Token *valueTok = tok->astOperand1(); |
| 3786 | if (const ValueFlow::Value* v = valueTok->getKnownValue(ValueFlow::Value::ValueType::INT)) |
| 3787 | values.insert(v->intvalue); |
| 3788 | continue; |
| 3789 | } |
| 3790 | } |
| 3791 | |
| 3792 | return values; |
| 3793 | } |
| 3794 | |
| 3795 | bool isExhaustiveSwitch(const Token *startbrace) |
| 3796 | { |
no test coverage detected