ValueFlow: function arguments only has 'possible' values

This commit is contained in:
Daniel Marjamäki 2015-07-16 20:49:14 +02:00
parent fa13179c68
commit 38214b6907
2 changed files with 14 additions and 0 deletions

View File

@ -1878,6 +1878,13 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger,
continue;
}
}
// passed values are not "known"..
for (std::list<ValueFlow::Value>::iterator it = argvalues.begin(); it != argvalues.end(); ++it) {
if (it->valueKind == ValueFlow::Value::Known)
it->valueKind = ValueFlow::Value::Possible;
}
valueFlowInjectParameter(tokenlist, errorLogger, settings, arg, functionScope, argvalues);
}
}

View File

@ -1556,6 +1556,13 @@ private:
value = valueOfTok(code, "+");
ASSERT_EQUALS(5, value.intvalue);
ASSERT_EQUALS(ValueFlow::Value::ValueKind::Possible, value.valueKind);
// function
code = "int f(int x) { return x + 1; }\n" // <- possible value
"void a() { f(12); }\b";
value = valueOfTok(code, "+");
ASSERT_EQUALS(13, value.intvalue);
ASSERT_EQUALS(ValueFlow::Value::ValueKind::Possible, value.valueKind);
}
};