parent
7621fee3d4
commit
428144c53c
|
@ -2356,6 +2356,11 @@ int getArgumentPos(const Variable* var, const Function* f)
|
|||
return std::distance(f->argumentList.begin(), arg_it);
|
||||
}
|
||||
|
||||
bool isIteratorPair(std::vector<const Token*> args)
|
||||
{
|
||||
return args.size() == 2 && ((astIsIterator(args[0]) && astIsIterator(args[1])) || (astIsPointer(args[0]) && astIsPointer(args[1])));
|
||||
}
|
||||
|
||||
const Token *findLambdaStartToken(const Token *last)
|
||||
{
|
||||
if (!last || last->str() != "}")
|
||||
|
|
|
@ -274,6 +274,11 @@ std::vector<const Token *> getArguments(const Token *ftok);
|
|||
|
||||
int getArgumentPos(const Variable* var, const Function* f);
|
||||
|
||||
/**
|
||||
* Are the arguments a pair of iterators/pointers?
|
||||
*/
|
||||
bool isIteratorPair(std::vector<const Token*> args);
|
||||
|
||||
const Token *findLambdaStartToken(const Token *last);
|
||||
|
||||
/**
|
||||
|
|
|
@ -6972,7 +6972,7 @@ static std::vector<ValueFlow::Value> getInitListSize(const Token* tok,
|
|||
}
|
||||
return {};
|
||||
} else if ((args.size() == 1 && astIsContainer(args[0]) && args[0]->valueType()->container == container) ||
|
||||
(args.size() == 2 && astIsIterator(args[0]) && astIsIterator(args[1]))) {
|
||||
isIteratorPair(args)) {
|
||||
return getContainerValues(args[0]);
|
||||
}
|
||||
return {makeContainerSizeValue(args.size(), known)};
|
||||
|
|
|
@ -5177,6 +5177,13 @@ private:
|
|||
"}";
|
||||
ASSERT(tokenValues(code, "s . size").empty());
|
||||
|
||||
code = "void f() {\n"
|
||||
" const uint8_t data[] = { 1, 2, 3 };\n"
|
||||
" std::vector<uint8_t> v{ data, data + sizeof(data) };\n"
|
||||
" v.size();\n"
|
||||
"}";
|
||||
TODO_ASSERT_EQUALS("", "ContainerSizeValue", isKnownContainerSizeValue(tokenValues(code, "v . size"), 3)); // TODO: extract container size
|
||||
|
||||
// valueFlowContainerForward, loop
|
||||
code = "void f() {\n"
|
||||
" std::stack<Token *> links;\n"
|
||||
|
|
Loading…
Reference in New Issue