Refactoring: Use enum class

This commit is contained in:
Daniel Marjamäki 2019-07-16 11:12:35 +02:00
parent 32eda27391
commit b4a05a3dd0
2 changed files with 13 additions and 13 deletions

View File

@ -3019,7 +3019,7 @@ struct LifetimeStore {
ValueFlow::Value value; ValueFlow::Value value;
value.valueType = ValueFlow::Value::LIFETIME; value.valueType = ValueFlow::Value::LIFETIME;
value.lifetimeScope = ValueFlow::Value::Local; value.lifetimeScope = ValueFlow::Value::LifetimeScope::Local;
value.tokvalue = lifeTok; value.tokvalue = lifeTok;
value.errorPath = er; value.errorPath = er;
value.lifetimeKind = type; value.lifetimeKind = type;
@ -3045,7 +3045,7 @@ struct LifetimeStore {
if (var && var->isArgument()) { if (var && var->isArgument()) {
ValueFlow::Value value; ValueFlow::Value value;
value.valueType = ValueFlow::Value::LIFETIME; value.valueType = ValueFlow::Value::LIFETIME;
value.lifetimeScope = ValueFlow::Value::Argument; value.lifetimeScope = ValueFlow::Value::LifetimeScope::Argument;
value.tokvalue = var->nameToken(); value.tokvalue = var->nameToken();
value.errorPath = er; value.errorPath = er;
value.lifetimeKind = type; value.lifetimeKind = type;
@ -3328,8 +3328,8 @@ static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger
errorPath.emplace_back(tok, "Address of variable taken here."); errorPath.emplace_back(tok, "Address of variable taken here.");
ValueFlow::Value value; ValueFlow::Value value;
value.valueType = ValueFlow::Value::LIFETIME; value.valueType = ValueFlow::Value::ValueType::LIFETIME;
value.lifetimeScope = ValueFlow::Value::Local; value.lifetimeScope = ValueFlow::Value::LifetimeScope::Local;
value.tokvalue = lifeTok; value.tokvalue = lifeTok;
value.errorPath = errorPath; value.errorPath = errorPath;
if (astIsPointer(lifeTok) || !Token::Match(lifeTok->astParent(), ".|[")) if (astIsPointer(lifeTok) || !Token::Match(lifeTok->astParent(), ".|["))
@ -3354,8 +3354,8 @@ static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger
errorPath.emplace_back(tok, "Pointer to container is created here."); errorPath.emplace_back(tok, "Pointer to container is created here.");
ValueFlow::Value value; ValueFlow::Value value;
value.valueType = ValueFlow::Value::LIFETIME; value.valueType = ValueFlow::Value::ValueType::LIFETIME;
value.lifetimeScope = ValueFlow::Value::Local; value.lifetimeScope = ValueFlow::Value::LifetimeScope::Local;
value.tokvalue = tok; value.tokvalue = tok;
value.errorPath = errorPath; value.errorPath = errorPath;
value.lifetimeKind = isIterator ? ValueFlow::Value::LifetimeKind::Iterator : ValueFlow::Value::LifetimeKind::Object; value.lifetimeKind = isIterator ? ValueFlow::Value::LifetimeKind::Iterator : ValueFlow::Value::LifetimeKind::Object;
@ -3384,8 +3384,8 @@ static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger
errorPath.emplace_back(tok, "Array decayed to pointer here."); errorPath.emplace_back(tok, "Array decayed to pointer here.");
ValueFlow::Value value; ValueFlow::Value value;
value.valueType = ValueFlow::Value::LIFETIME; value.valueType = ValueFlow::Value::ValueType::LIFETIME;
value.lifetimeScope = ValueFlow::Value::Local; value.lifetimeScope = ValueFlow::Value::LifetimeScope::Local;
value.tokvalue = var->nameToken(); value.tokvalue = var->nameToken();
value.errorPath = errorPath; value.errorPath = errorPath;
setTokenValue(tok, value, tokenlist->getSettings()); setTokenValue(tok, value, tokenlist->getSettings());
@ -5502,7 +5502,7 @@ ValueFlow::Value::Value(const Token *c, long long val)
conditional(false), conditional(false),
defaultArg(false), defaultArg(false),
lifetimeKind(LifetimeKind::Object), lifetimeKind(LifetimeKind::Object),
lifetimeScope(Local), lifetimeScope(LifetimeScope::Local),
valueKind(ValueKind::Possible) valueKind(ValueKind::Possible)
{ {
errorPath.emplace_back(c, "Assuming that condition '" + c->expressionString() + "' is not redundant"); errorPath.emplace_back(c, "Assuming that condition '" + c->expressionString() + "' is not redundant");

View File

@ -53,7 +53,7 @@ namespace ValueFlow {
conditional(false), conditional(false),
defaultArg(false), defaultArg(false),
lifetimeKind(LifetimeKind::Object), lifetimeKind(LifetimeKind::Object),
lifetimeScope(Local), lifetimeScope(LifetimeScope::Local),
valueKind(ValueKind::Possible) valueKind(ValueKind::Possible)
{} {}
Value(const Token *c, long long val); Value(const Token *c, long long val);
@ -131,11 +131,11 @@ namespace ValueFlow {
} }
bool isLocalLifetimeValue() const { bool isLocalLifetimeValue() const {
return valueType == ValueType::LIFETIME && lifetimeScope == Local; return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::Local;
} }
bool isArgumentLifetimeValue() const { bool isArgumentLifetimeValue() const {
return valueType == ValueType::LIFETIME && lifetimeScope == Argument; return valueType == ValueType::LIFETIME && lifetimeScope == LifetimeScope::Argument;
} }
/** int value */ /** int value */
@ -169,7 +169,7 @@ namespace ValueFlow {
enum class LifetimeKind {Object, Lambda, Iterator, Address} lifetimeKind; enum class LifetimeKind {Object, Lambda, Iterator, Address} lifetimeKind;
enum LifetimeScope { Local, Argument } lifetimeScope; enum class LifetimeScope { Local, Argument } lifetimeScope;
static const char * toString(MoveKind moveKind) { static const char * toString(MoveKind moveKind) {
switch (moveKind) { switch (moveKind) {