ErrorPath: More information about assignments
This commit is contained in:
parent
ecb3f0a934
commit
cd53d10970
|
@ -221,8 +221,12 @@ public:
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
unsigned int fileNumber;
|
unsigned int fileNumber;
|
||||||
|
|
||||||
std::string getinfo() const { return _info; }
|
std::string getinfo() const {
|
||||||
void setinfo(const std::string &i) { _info = i; }
|
return _info;
|
||||||
|
}
|
||||||
|
void setinfo(const std::string &i) {
|
||||||
|
_info = i;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _file;
|
std::string _file;
|
||||||
|
|
|
@ -1971,8 +1971,12 @@ static void valueFlowAfterAssign(TokenList *tokenlist, SymbolDatabase* symboldat
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::list<ValueFlow::Value> values = tok->astOperand2()->values();
|
std::list<ValueFlow::Value> values = tok->astOperand2()->values();
|
||||||
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end(); ++it)
|
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||||
it->errorPath.push_back(ErrorPathItem(tok->astOperand2(),"assignment"));
|
std::string info = "Assignment";
|
||||||
|
if (it->isIntValue())
|
||||||
|
info += ", integer value " + MathLib::toString(it->intvalue);
|
||||||
|
it->errorPath.push_back(ErrorPathItem(tok->astOperand2(), info));
|
||||||
|
}
|
||||||
const bool constValue = tok->astOperand2()->isNumber();
|
const bool constValue = tok->astOperand2()->isNumber();
|
||||||
|
|
||||||
if (tokenlist->isCPP() && Token::Match(var->typeStartToken(), "bool|_Bool")) {
|
if (tokenlist->isCPP() && Token::Match(var->typeStartToken(), "bool|_Bool")) {
|
||||||
|
@ -2926,6 +2930,23 @@ static void valueFlowUninit(TokenList *tokenlist, SymbolDatabase * /*symbolDatab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ValueFlow::Value::Value(const Token *c, long long val)
|
||||||
|
: valueType(INT),
|
||||||
|
intvalue(val),
|
||||||
|
tokvalue(nullptr),
|
||||||
|
floatValue(0.0),
|
||||||
|
moveKind(NonMovedVariable),
|
||||||
|
varvalue(val),
|
||||||
|
condition(c),
|
||||||
|
varId(0U),
|
||||||
|
conditional(false),
|
||||||
|
inconclusive(false),
|
||||||
|
defaultArg(false),
|
||||||
|
valueKind(ValueKind::Possible)
|
||||||
|
{
|
||||||
|
errorPath.push_back(ErrorPathItem(c, "Condition '" + c->expressionString() + "'"));
|
||||||
|
}
|
||||||
|
|
||||||
const ValueFlow::Value *ValueFlow::valueFlowConstantFoldAST(const Token *expr, const Settings *settings)
|
const ValueFlow::Value *ValueFlow::valueFlowConstantFoldAST(const Token *expr, const Settings *settings)
|
||||||
{
|
{
|
||||||
if (expr && expr->values().empty()) {
|
if (expr && expr->values().empty()) {
|
||||||
|
|
|
@ -38,9 +38,7 @@ namespace ValueFlow {
|
||||||
typedef std::list<ErrorPathItem> ErrorPath;
|
typedef std::list<ErrorPathItem> ErrorPath;
|
||||||
|
|
||||||
explicit Value(long long val = 0) : valueType(INT), intvalue(val), tokvalue(nullptr), floatValue(0.0), moveKind(NonMovedVariable), varvalue(val), condition(0), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {}
|
explicit Value(long long val = 0) : valueType(INT), intvalue(val), tokvalue(nullptr), floatValue(0.0), moveKind(NonMovedVariable), varvalue(val), condition(0), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {}
|
||||||
Value(const Token *c, long long val) : valueType(INT), intvalue(val), tokvalue(nullptr), floatValue(0.0), moveKind(NonMovedVariable), varvalue(val), condition(c), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {
|
Value(const Token *c, long long val);
|
||||||
errorPath.push_back(ErrorPathItem(c, "condition"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Value &rhs) const {
|
bool operator==(const Value &rhs) const {
|
||||||
if (valueType != rhs.valueType)
|
if (valueType != rhs.valueType)
|
||||||
|
|
Loading…
Reference in New Issue