File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -6494,7 +6494,7 @@ static std::vector<ValueFlow::Value> getContainerSizeFromConstructorArgs(const s
64946494 if (args.size () == 1 && args[0 ]->tokType () == Token::Type::eString)
64956495 return {makeContainerSizeValue (Token::getStrLength (args[0 ]), known)};
64966496 if (args.size () == 1 && args[0 ]->variable () && args[0 ]->variable ()->isArray () &&
6497- args[0 ]->variable ()->isConst () && args[0 ]->variable ()->dimensions ().size () == 1 )
6497+ args[0 ]->variable ()->isConst () && args[0 ]->variable ()->dimensions ().size () == 1 && args[ 0 ]-> variable ()-> dimensions ()[ 0 ]. known )
64986498 return {makeContainerSizeValue (args[0 ]->variable ()->dimensions ()[0 ].num , known)};
64996499 if (args.size () == 2 && astIsIntegral (args[1 ], false )) // { char*, count }
65006500 return {makeContainerSizeValue (args[1 ], known)};
Original file line number Diff line number Diff line change @@ -7406,6 +7406,12 @@ class TestValueFlow : public TestFixture {
74067406 " return a[0];\n "
74077407 " }" ;
74087408 ASSERT (!isKnownContainerSizeValue (tokenValues (code, " a [" ), 6 ).empty ());
7409+
7410+ code = " void f(const char a[]) {\n " // #14518
7411+ " std::string s(a);\n "
7412+ " if (s.empty()) {}\n "
7413+ " }" ;
7414+ ASSERT (!isKnownContainerSizeValue (tokenValues (code, " s ." ), 0 ).empty ());
74097415 }
74107416
74117417 void valueFlowContainerElement ()
You can’t perform that action at this time.
0 commit comments