Merge branch 'main' into lifetime-subfunction
This commit is contained in:
commit
8c425790f4
|
@ -412,7 +412,7 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
|||
|
||||
if (value.isContainerSizeValue()) {
|
||||
// .empty, .size, +"abc", +'a'
|
||||
if (parent->str() == "+") {
|
||||
if (parent->str() == "+" && parent->astOperand1() && parent->astOperand2()) {
|
||||
for (const ValueFlow::Value &value1 : parent->astOperand1()->values()) {
|
||||
for (const ValueFlow::Value &value2 : parent->astOperand2()->values()) {
|
||||
if (value1.path != value2.path)
|
||||
|
@ -3098,11 +3098,13 @@ std::vector<LifetimeToken> getLifetimeTokens(const Token* tok, bool escape, Valu
|
|||
for (const ValueFlow::Value &v : vartok->values()) {
|
||||
if (!v.isLocalLifetimeValue())
|
||||
continue;
|
||||
if (v.tokvalue == tok)
|
||||
continue;
|
||||
errorPath.insert(errorPath.end(), v.errorPath.begin(), v.errorPath.end());
|
||||
return getLifetimeTokens(v.tokvalue, escape, std::move(errorPath));
|
||||
return getLifetimeTokens(v.tokvalue, escape, std::move(errorPath), depth - 1);
|
||||
}
|
||||
} else {
|
||||
return LifetimeToken::setAddressOf(getLifetimeTokens(vartok, escape, std::move(errorPath)),
|
||||
return LifetimeToken::setAddressOf(getLifetimeTokens(vartok, escape, std::move(errorPath), depth - 1),
|
||||
!(astIsContainer(vartok) && Token::simpleMatch(vartok->astParent(), "[")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4706,6 +4706,15 @@ private:
|
|||
"}\n";
|
||||
valueOfTok(code, "x");
|
||||
|
||||
code = "void f(){\n"
|
||||
" struct dwarf_data **pp;\n"
|
||||
" for (pp = (struct dwarf_data **) (void *) &state->fileline_data;\n"
|
||||
" *pp != NULL;\n"
|
||||
" pp = &(*pp)->next)\n"
|
||||
" ;\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "x");
|
||||
|
||||
code = "void *foo(void *x);\n"
|
||||
"void *foo(void *x)\n"
|
||||
"{\n"
|
||||
|
@ -4715,6 +4724,15 @@ private:
|
|||
" return x;\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "x");
|
||||
|
||||
code = "void f() {\n"
|
||||
" std::string a = b[c->d()];\n"
|
||||
" if(a.empty()) {\n"
|
||||
" INFO(std::string{\"a\"} + c->d());\n"
|
||||
" INFO(std::string{\"b\"} + a);\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
valueOfTok(code, "a");
|
||||
}
|
||||
|
||||
void valueFlowHang() {
|
||||
|
|
Loading…
Reference in New Issue