Skip to content

Commit 3649446

Browse files
Update valueflow.cpp
1 parent e43606c commit 3649446

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/valueflow.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6504,10 +6504,12 @@ static std::vector<ValueFlow::Value> getContainerSizeFromConstructorArgs(const s
65046504
return {};
65056505
}
65066506

6507-
static bool valueFlowIsSameContainerType(const ValueType& contType, const Token* tok, const Settings& settings)
6507+
static bool valueFlowIsSameContainerType(const ValueType& contType, const Token* tok, bool isView, const Settings& settings)
65086508
{
6509-
if (!tok || !tok->valueType() || !tok->valueType()->containerTypeToken)
6509+
if (!tok || !tok->valueType())
65106510
return true;
6511+
if (!tok->valueType()->containerTypeToken)
6512+
return !isView;
65116513

65126514
const ValueType tokType = ValueType::parseDecl(tok->valueType()->containerTypeToken, settings);
65136515
return contType.isTypeEqual(&tokType) || tokType.type == ValueType::Type::UNKNOWN_TYPE;
@@ -6536,7 +6538,7 @@ static std::vector<ValueFlow::Value> getInitListSize(const Token* tok,
65366538
initList = true;
65376539
else if (vt.isIntegral() && astIsIntegral(args[0], false))
65386540
initList = true;
6539-
else if (args.size() == 1 && valueFlowIsSameContainerType(vt, tok->astOperand2(), settings))
6541+
else if (args.size() == 1 && valueFlowIsSameContainerType(vt, tok->astOperand2(), valueType->container->view, settings))
65406542
initList = false; // copy ctor
65416543
else if (args.size() == 2 && (!args[0]->valueType() || !args[1]->valueType())) // might be unknown iterators
65426544
initList = false;

0 commit comments

Comments
 (0)