Add more ValueFlow info in the xml dumps (#3402)

This commit is contained in:
Paul Fultz II 2021-08-15 01:02:31 -05:00 committed by GitHub
parent 83270a6c52
commit be978b35cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View File

@ -1740,12 +1740,15 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
break;
case ValueFlow::Value::ValueType::LIFETIME:
out << "lifetime=\"" << value.tokvalue << '\"';
out << " lifetime-scope=\"" << ValueFlow::Value::toString(value.lifetimeScope) << "\"";
out << " lifetime-kind=\"" << ValueFlow::Value::toString(value.lifetimeKind) << "\"";
break;
case ValueFlow::Value::ValueType::SYMBOLIC:
out << "tokvalue=\"" << value.tokvalue << '\"';
out << " intvalue=\"" << value.intvalue << '\"';
out << "symbolic=\"" << value.tokvalue << '\"';
out << " symbolic-delta=\"" << value.intvalue << '\"';
break;
}
out << " bound=\"" << ValueFlow::Value::toString(value.bound) << "\"";
if (value.condition)
out << " condition-line=\"" << value.condition->linenr() << '\"';
if (value.isKnown())
@ -1756,6 +1759,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
out << " impossible=\"true\"";
else if (value.isInconclusive())
out << " inconclusive=\"true\"";
out << " path=\"" << value.path << "\"";
out << "/>" << std::endl;
}

View File

@ -7093,6 +7093,31 @@ const char* ValueFlow::Value::toString(LifetimeKind lifetimeKind)
return "";
}
const char* ValueFlow::Value::toString(LifetimeScope lifetimeScope)
{
switch (lifetimeScope) {
case ValueFlow::Value::LifetimeScope::Local:
return "Local";
case ValueFlow::Value::LifetimeScope::Argument:
return "Argument";
case ValueFlow::Value::LifetimeScope::SubFunction:
return "SubFunction";
}
return "";
}
const char* ValueFlow::Value::toString(Bound bound)
{
switch (bound) {
case ValueFlow::Value::Bound::Point:
return "Point";
case ValueFlow::Value::Bound::Upper:
return "Upper";
case ValueFlow::Value::Bound::Lower:
return "Lower";
}
return "";
}
const ValueFlow::Value *ValueFlow::valueFlowConstantFoldAST(Token *expr, const Settings *settings)
{
if (expr && expr->values().empty()) {

View File

@ -366,6 +366,8 @@ namespace ValueFlow {
static const char* toString(MoveKind moveKind);
static const char* toString(LifetimeKind lifetimeKind);
static const char* toString(LifetimeScope lifetimeScope);
static const char* toString(Bound bound);
/** How known is this value */
enum class ValueKind {