Refactoring; enum class
This commit is contained in:
parent
1cb90f925e
commit
95d65c8c34
|
@ -388,7 +388,7 @@ void CheckType::checkFloatToIntegerOverflow()
|
|||
continue;
|
||||
|
||||
for (const ValueFlow::Value &f : *floatValues) {
|
||||
if (f.valueType != ValueFlow::Value::FLOAT)
|
||||
if (f.valueType != ValueFlow::Value::ValueType::FLOAT)
|
||||
continue;
|
||||
if (!mSettings->isEnabled(&f, false))
|
||||
continue;
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
c.longCastAssignError(nullptr);
|
||||
c.longCastReturnError(nullptr);
|
||||
ValueFlow::Value f;
|
||||
f.valueType = ValueFlow::Value::FLOAT;
|
||||
f.valueType = ValueFlow::Value::ValueType::FLOAT;
|
||||
f.floatValue = 1E100;
|
||||
c.floatToIntegerOverflowError(nullptr, f);
|
||||
}
|
||||
|
|
|
@ -1292,7 +1292,7 @@ void CheckUninitVar::valueFlowUninit()
|
|||
if (!tok->variable() || tok->values().size() != 1U)
|
||||
continue;
|
||||
const ValueFlow::Value &v = tok->values().front();
|
||||
if (v.valueType != ValueFlow::Value::UNINIT || v.isInconclusive())
|
||||
if (v.valueType != ValueFlow::Value::ValueType::UNINIT || v.isInconclusive())
|
||||
continue;
|
||||
if (!isVariableUsage(tok, tok->variable()->isPointer(), NO_ALLOC))
|
||||
continue;
|
||||
|
|
10
lib/ctu.cpp
10
lib/ctu.cpp
|
@ -369,9 +369,9 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer)
|
|||
if (argtok->values().size() != 1U)
|
||||
continue;
|
||||
const ValueFlow::Value &v = argtok->values().front();
|
||||
if (v.valueType == ValueFlow::Value::UNINIT && !v.isInconclusive()) {
|
||||
if (v.valueType == ValueFlow::Value::ValueType::UNINIT && !v.isInconclusive()) {
|
||||
FileInfo::FunctionCall functionCall;
|
||||
functionCall.callValueType = ValueFlow::Value::UNINIT;
|
||||
functionCall.callValueType = ValueFlow::Value::ValueType::UNINIT;
|
||||
functionCall.callId = getFunctionId(tokenizer, tok->astOperand1()->function());
|
||||
functionCall.callFunctionName = tok->astOperand1()->expressionString();
|
||||
functionCall.location.fileName = tokenizer->list.file(tok);
|
||||
|
@ -482,15 +482,15 @@ static bool findPath(const std::string &callId,
|
|||
continue;
|
||||
switch (invalidValue) {
|
||||
case CTU::FileInfo::InvalidValueType::null:
|
||||
if (functionCall->callValueType != ValueFlow::Value::INT || functionCall->callArgValue != 0)
|
||||
if (functionCall->callValueType != ValueFlow::Value::ValueType::INT || functionCall->callArgValue != 0)
|
||||
continue;
|
||||
break;
|
||||
case CTU::FileInfo::InvalidValueType::uninit:
|
||||
if (functionCall->callValueType != ValueFlow::Value::UNINIT)
|
||||
if (functionCall->callValueType != ValueFlow::Value::ValueType::UNINIT)
|
||||
continue;
|
||||
break;
|
||||
case CTU::FileInfo::InvalidValueType::bufferOverflow:
|
||||
if (functionCall->callValueType != ValueFlow::Value::BUFFER_SIZE)
|
||||
if (functionCall->callValueType != ValueFlow::Value::ValueType::BUFFER_SIZE)
|
||||
continue;
|
||||
if (unsafeValue < 0 || unsafeValue >= functionCall->callArgValue)
|
||||
break;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace ValueFlow {
|
|||
typedef std::list<ErrorPathItem> ErrorPath;
|
||||
|
||||
explicit Value(long long val = 0)
|
||||
: valueType(INT),
|
||||
: valueType(ValueType::INT),
|
||||
intvalue(val),
|
||||
tokvalue(nullptr),
|
||||
floatValue(0.0),
|
||||
|
@ -61,34 +61,34 @@ namespace ValueFlow {
|
|||
if (valueType != rhs.valueType)
|
||||
return false;
|
||||
switch (valueType) {
|
||||
case INT:
|
||||
case ValueType::INT:
|
||||
if (intvalue != rhs.intvalue)
|
||||
return false;
|
||||
break;
|
||||
case TOK:
|
||||
case ValueType::TOK:
|
||||
if (tokvalue != rhs.tokvalue)
|
||||
return false;
|
||||
break;
|
||||
case FLOAT:
|
||||
case ValueType::FLOAT:
|
||||
// TODO: Write some better comparison
|
||||
if (floatValue > rhs.floatValue || floatValue < rhs.floatValue)
|
||||
return false;
|
||||
break;
|
||||
case MOVED:
|
||||
case ValueType::MOVED:
|
||||
if (moveKind != rhs.moveKind)
|
||||
return false;
|
||||
break;
|
||||
case UNINIT:
|
||||
case ValueType::UNINIT:
|
||||
break;
|
||||
case BUFFER_SIZE:
|
||||
case ValueType::BUFFER_SIZE:
|
||||
if (intvalue != rhs.intvalue)
|
||||
return false;
|
||||
break;
|
||||
case CONTAINER_SIZE:
|
||||
case ValueType::CONTAINER_SIZE:
|
||||
if (intvalue != rhs.intvalue)
|
||||
return false;
|
||||
break;
|
||||
case LIFETIME:
|
||||
case ValueType::LIFETIME:
|
||||
if (tokvalue != rhs.tokvalue)
|
||||
return false;
|
||||
}
|
||||
|
@ -105,36 +105,36 @@ namespace ValueFlow {
|
|||
|
||||
enum ValueType { INT, TOK, FLOAT, MOVED, UNINIT, CONTAINER_SIZE, LIFETIME, BUFFER_SIZE } valueType;
|
||||
bool isIntValue() const {
|
||||
return valueType == INT;
|
||||
return valueType == ValueType::INT;
|
||||
}
|
||||
bool isTokValue() const {
|
||||
return valueType == TOK;
|
||||
return valueType == ValueType::TOK;
|
||||
}
|
||||
bool isFloatValue() const {
|
||||
return valueType == FLOAT;
|
||||
return valueType == ValueType::FLOAT;
|
||||
}
|
||||
bool isMovedValue() const {
|
||||
return valueType == MOVED;
|
||||
return valueType == ValueType::MOVED;
|
||||
}
|
||||
bool isUninitValue() const {
|
||||
return valueType == UNINIT;
|
||||
return valueType == ValueType::UNINIT;
|
||||
}
|
||||
bool isContainerSizeValue() const {
|
||||
return valueType == CONTAINER_SIZE;
|
||||
return valueType == ValueType::CONTAINER_SIZE;
|
||||
}
|
||||
bool isLifetimeValue() const {
|
||||
return valueType == LIFETIME;
|
||||
return valueType == ValueType::LIFETIME;
|
||||
}
|
||||
bool isBufferSizeValue() const {
|
||||
return valueType == BUFFER_SIZE;
|
||||
return valueType == ValueType::BUFFER_SIZE;
|
||||
}
|
||||
|
||||
bool isLocalLifetimeValue() const {
|
||||
return valueType == LIFETIME && lifetimeScope == Local;
|
||||
return valueType == ValueType::LIFETIME && lifetimeScope == Local;
|
||||
}
|
||||
|
||||
bool isArgumentLifetimeValue() const {
|
||||
return valueType == LIFETIME && lifetimeScope == Argument;
|
||||
return valueType == ValueType::LIFETIME && lifetimeScope == Argument;
|
||||
}
|
||||
|
||||
/** int value */
|
||||
|
|
Loading…
Reference in New Issue