SymbolDatabase: Refactoring
This commit is contained in:
parent
f45233682e
commit
8b088a472f
|
@ -1287,12 +1287,11 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
// rhs of [
|
// rhs of [
|
||||||
const Token *rhs = dimension.start->previous()->astOperand2();
|
const Token *rhs = dimension.start->previous()->astOperand2();
|
||||||
|
|
||||||
if (rhs) {
|
|
||||||
// constant folding of expression:
|
// constant folding of expression:
|
||||||
ValueFlow::valueFlowConstantFoldAST(rhs);
|
ValueFlow::valueFlowConstantFoldAST(rhs);
|
||||||
|
|
||||||
// get constant folded value:
|
// get constant folded value:
|
||||||
if (rhs->values.size() == 1U && rhs->values.front().isKnown()) {
|
if (rhs && rhs->values.size() == 1U && rhs->values.front().isKnown()) {
|
||||||
dimension.num = rhs->values.front().intvalue;
|
dimension.num = rhs->values.front().intvalue;
|
||||||
dimension.known = true;
|
dimension.known = true;
|
||||||
}
|
}
|
||||||
|
@ -1302,7 +1301,6 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SymbolDatabase::~SymbolDatabase()
|
SymbolDatabase::~SymbolDatabase()
|
||||||
{
|
{
|
||||||
|
@ -3284,19 +3282,17 @@ const Token * Scope::addEnum(const Token * tok, bool isCpp)
|
||||||
// rhs of operator:
|
// rhs of operator:
|
||||||
const Token *rhs = enumerator.start->previous()->astOperand2();
|
const Token *rhs = enumerator.start->previous()->astOperand2();
|
||||||
|
|
||||||
if (rhs) {
|
|
||||||
// constant folding of expression:
|
// constant folding of expression:
|
||||||
ValueFlow::valueFlowConstantFoldAST(rhs);
|
ValueFlow::valueFlowConstantFoldAST(rhs);
|
||||||
|
|
||||||
// get constant folded value:
|
// get constant folded value:
|
||||||
if (rhs->values.size() == 1U && rhs->values.front().isKnown()) {
|
if (rhs && rhs->values.size() == 1U && rhs->values.front().isKnown()) {
|
||||||
enumerator.value = rhs->values.front().intvalue;
|
enumerator.value = rhs->values.front().intvalue;
|
||||||
enumerator.value_known = true;
|
enumerator.value_known = true;
|
||||||
value = enumerator.value + 1;
|
value = enumerator.value + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// not initialized so use default value
|
// not initialized so use default value
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue