@@ -6711,23 +6711,25 @@ static void valueFlowContainerSize(const TokenList& tokenlist,
67116711 for (const ValueFlow::Value& value : values)
67126712 setTokenValue (tok, value, settings);
67136713 }
6714- else if (Token::Match (tok->previous (), " ,|( {|%str%" )) {
6715- int nArg{};
6716- if (const Token* funcTok = getTokenArgumentFunction (tok, nArg)) {
6717- if (const Function* func = funcTok->function ()) {
6718- if (const Variable* var = func->getArgumentVar (nArg)) {
6719- if (var->valueType () && var->valueType ()->container && var->valueType ()->container ->size_templateArgNo < 0 ) {
6720- auto values = tok->tokType () == Token::Type::eString
6721- ? std::vector<ValueFlow::Value>{makeContainerSizeValue (Token::getStrLength (tok))}
6722- : getInitListSize (tok, var->valueType (), settings, true );
6723- ValueFlow::Value tokValue;
6724- tokValue.valueType = ValueFlow::Value::ValueType::TOK;
6725- tokValue.tokvalue = tok;
6726- tokValue.setKnown ();
6727- values.push_back (std::move (tokValue));
6728-
6729- for (const ValueFlow::Value &value : values)
6730- setTokenValue (tok, value, settings);
6714+ else if (Token::Match (tok->previous (), " ,|(" ) && (Token::Match (tok, " {|%str%" ) || settings.library .detectContainer (tok))) {
6715+ if (Token* argTok = tok->previous ()->astOperand2 ()) {
6716+ int nArg{};
6717+ if (const Token* funcTok = getTokenArgumentFunction (argTok, nArg)) {
6718+ if (const Function* func = funcTok->function ()) {
6719+ if (const Variable* var = func->getArgumentVar (nArg)) {
6720+ if (var->valueType () && var->valueType ()->container && var->valueType ()->container ->size_templateArgNo < 0 ) {
6721+ auto values = argTok->tokType () == Token::Type::eString
6722+ ? std::vector<ValueFlow::Value>{makeContainerSizeValue (Token::getStrLength (argTok))}
6723+ : getInitListSize (argTok, var->valueType (), settings, true );
6724+ ValueFlow::Value tokValue;
6725+ tokValue.valueType = ValueFlow::Value::ValueType::TOK;
6726+ tokValue.tokvalue = argTok;
6727+ tokValue.setKnown ();
6728+ values.push_back (std::move (tokValue));
6729+
6730+ for (const ValueFlow::Value& value : values)
6731+ setTokenValue (argTok, value, settings);
6732+ }
67316733 }
67326734 }
67336735 }
0 commit comments