@@ -459,7 +459,7 @@ void combineValueProperties(const ValueFlow::Value &value1, const ValueFlow::Val
459459 result->path = value1.path ;
460460}
461461
462- static const Token *getCastTypeStartToken (const Token *parent)
462+ static const Token *getCastTypeStartToken (const Token *parent, const Settings* settings )
463463{
464464 // TODO: This might be a generic utility function?
465465 if (!Token::Match (parent, " {|(" ))
@@ -470,7 +470,8 @@ static const Token *getCastTypeStartToken(const Token *parent)
470470 return parent->astOperand1 ();
471471 if (parent->str () != " (" )
472472 return nullptr ;
473- if (!parent->astOperand2 () && Token::Match (parent," ( %name%" ))
473+ if (!parent->astOperand2 () && Token::Match (parent, " ( %name%" ) &&
474+ (parent->next ()->isStandardType () || settings->library .isNotLibraryFunction (parent->next ())))
474475 return parent->next ();
475476 if (parent->astOperand2 () && Token::Match (parent->astOperand1 (), " const_cast|dynamic_cast|reinterpret_cast|static_cast <" ))
476477 return parent->astOperand1 ()->tokAt (2 );
@@ -603,7 +604,8 @@ static void setTokenValue(Token* tok,
603604 return !Token::simpleMatch (p, " ," );
604605 });
605606 // Ensure that the comma isn't a function call
606- if (!callParent || (!Token::Match (callParent->previous (), " %name%|> (" ) && !Token::simpleMatch (callParent, " {" ))) {
607+ if (!callParent || (!Token::Match (callParent->previous (), " %name%|> (" ) && !Token::simpleMatch (callParent, " {" ) &&
608+ (!Token::Match (callParent, " ( %name%" ) || settings->library .isNotLibraryFunction (callParent->next ())))) {
607609 setTokenValue (parent, std::move (value), settings);
608610 return ;
609611 }
@@ -729,7 +731,7 @@ static void setTokenValue(Token* tok,
729731 }
730732
731733 // cast..
732- if (const Token *castType = getCastTypeStartToken (parent)) {
734+ if (const Token *castType = getCastTypeStartToken (parent, settings )) {
733735 if (contains ({ValueFlow::Value::ValueType::INT, ValueFlow::Value::ValueType::SYMBOLIC}, value.valueType ) &&
734736 Token::simpleMatch (parent->astOperand1 (), " dynamic_cast" ))
735737 return ;
0 commit comments