@@ -635,7 +635,7 @@ static bool isConditionKnown(const Token* tok, bool then)
635635 while (parent && (parent->str () == op || parent->str () == " !" || parent->isCast ()))
636636 parent = parent->astParent ();
637637 const Token* top = tok->astTop ();
638- if (top && Token::Match (top->previous (), " if|while|for (" ))
638+ if (Token::Match (top->previous (), " if|while|for (" ))
639639 return parent == top || Token::simpleMatch (parent, " ;" );
640640 return parent && parent->str () != op;
641641}
@@ -2372,7 +2372,7 @@ const Token* ValueFlow::getEndOfExprScope(const Token* tok, const Scope* default
23722372 end = varEnd;
23732373
23742374 const Token* top = var->nameToken ()->astTop ();
2375- if (top && Token::simpleMatch (top->tokAt (-1 ), " if (" )) { // variable declared in if (...)
2375+ if (Token::simpleMatch (top->tokAt (-1 ), " if (" )) { // variable declared in if (...)
23762376 const Token* elseTok = top->link ()->linkAt (1 );
23772377 if (Token::simpleMatch (elseTok, " } else {" ) && tok->scope ()->isNestedIn (elseTok->tokAt (2 )->scope ()))
23782378 end = tok->scope ()->bodyEnd ;
@@ -4753,8 +4753,6 @@ struct ConditionHandler {
47534753 continue ;
47544754
47554755 const Token* top = tok->astTop ();
4756- if (!top)
4757- continue ;
47584756
47594757 if (!Token::Match (top->previous (), " if|while|for (" ) && !Token::Match (tok->astParent (), " &&|%oror%|?|!" ))
47604758 continue ;
@@ -4929,8 +4927,6 @@ struct ConditionHandler {
49294927 const Settings& settings,
49304928 const std::set<const Scope*>& skippedFunctions) const {
49314929 traverseCondition (symboldatabase, settings, skippedFunctions, [&](const Condition& cond, Token* condTok, const Scope* scope) {
4932- Token* top = condTok->astTop ();
4933-
49344930 const MathLib::bigint path = cond.getPath ();
49354931 const bool allowKnown = path == 0 ;
49364932
@@ -5005,8 +5001,7 @@ struct ConditionHandler {
50055001 }
50065002 }
50075003
5008- if (!top)
5009- return ;
5004+ Token* top = condTok->astTop ();
50105005
50115006 if (top->previous ()->isExpandedMacro ()) {
50125007 for (std::list<ValueFlow::Value>* values : {&thenValues, &elseValues}) {
@@ -7088,7 +7083,7 @@ static void valueFlowContainerSize(const TokenList& tokenlist,
70887083 !Token::Match (nameToken, " %name% (" ))
70897084 continue ;
70907085 }
7091- if (nameToken-> astTop () && Token::Match (nameToken->astTop ()->previous (), " for|while" ))
7086+ if (Token::Match (nameToken->astTop ()->previous (), " for|while" ))
70927087 known = !isVariableChanged (var, settings);
70937088 std::vector<ValueFlow::Value> values{ValueFlow::Value{size}};
70947089 values.back ().valueType = ValueFlow::Value::ValueType::CONTAINER_SIZE;
0 commit comments