Running astyle [ci skip]
This commit is contained in:
parent
71d1dd2bb8
commit
1be5bb8bbc
|
@ -120,8 +120,7 @@ struct Analyzer {
|
|||
Action action;
|
||||
Terminate terminate;
|
||||
|
||||
void update(Result rhs)
|
||||
{
|
||||
void update(Result rhs) {
|
||||
if (terminate == Terminate::None)
|
||||
terminate = rhs.terminate;
|
||||
action |= rhs.action;
|
||||
|
|
|
@ -1423,17 +1423,17 @@ bool isConstFunctionCall(const Token* ftok, const Library& library)
|
|||
if (!Function::returnsConst(f)) {
|
||||
std::vector<const Function*> fs = f->getOverloadedFunctions();
|
||||
if (std::any_of(fs.begin(), fs.end(), [&](const Function* g) {
|
||||
if (f == g)
|
||||
return false;
|
||||
if (f->argumentList.size() != g->argumentList.size())
|
||||
return false;
|
||||
if (functionModifiesArguments(g))
|
||||
return false;
|
||||
if (g->isConst() && Function::returnsConst(g))
|
||||
return true;
|
||||
if (f == g)
|
||||
return false;
|
||||
}))
|
||||
return true;
|
||||
if (f->argumentList.size() != g->argumentList.size())
|
||||
return false;
|
||||
if (functionModifiesArguments(g))
|
||||
return false;
|
||||
if (g->isConst() && Function::returnsConst(g))
|
||||
return true;
|
||||
return false;
|
||||
}))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (f->argumentList.empty()) {
|
||||
|
@ -1467,11 +1467,11 @@ bool isConstFunctionCall(const Token* ftok, const Library& library)
|
|||
if (memberFunction && args.empty())
|
||||
return false;
|
||||
return constMember && std::all_of(args.begin(), args.end(), [](const Token* tok) {
|
||||
const Variable* var = tok->variable();
|
||||
if (var)
|
||||
return var->isConst();
|
||||
return false;
|
||||
});
|
||||
const Variable* var = tok->variable();
|
||||
if (var)
|
||||
return var->isConst();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1679,11 +1679,11 @@ static void valueFlowGlobalStaticVar(TokenList *tokenList, const Settings *setti
|
|||
}
|
||||
|
||||
static Analyzer::Result valueFlowForward(Token* startToken,
|
||||
const Token* endToken,
|
||||
const Token* exprTok,
|
||||
std::list<ValueFlow::Value> values,
|
||||
TokenList* const tokenlist,
|
||||
const Settings* settings);
|
||||
const Token* endToken,
|
||||
const Token* exprTok,
|
||||
std::list<ValueFlow::Value> values,
|
||||
TokenList* const tokenlist,
|
||||
const Settings* settings);
|
||||
|
||||
static void valueFlowReverse(TokenList* tokenlist,
|
||||
Token* tok,
|
||||
|
@ -1974,7 +1974,9 @@ struct ValueFlowAnalyzer : Analyzer {
|
|||
virtual bool isGlobal() const {
|
||||
return false;
|
||||
}
|
||||
virtual bool dependsOnThis() const { return false; }
|
||||
virtual bool dependsOnThis() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool invalid() const {
|
||||
return false;
|
||||
|
@ -2020,8 +2022,7 @@ struct ValueFlowAnalyzer : Analyzer {
|
|||
return Action::None;
|
||||
}
|
||||
|
||||
virtual Action isThisModified(const Token* tok) const
|
||||
{
|
||||
virtual Action isThisModified(const Token* tok) const {
|
||||
if (isThisChanged(tok, 0, getSettings(), isCPP()))
|
||||
return Action::Invalid;
|
||||
return Action::None;
|
||||
|
@ -2405,8 +2406,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
|||
ExpressionAnalyzer() : SingleValueFlowAnalyzer(), expr(nullptr), local(true), unknown(false), dependOnThis(false) {}
|
||||
|
||||
ExpressionAnalyzer(const Token* e, const ValueFlow::Value& val, const TokenList* t)
|
||||
: SingleValueFlowAnalyzer(val, t), expr(e), local(true), unknown(false), dependOnThis(false)
|
||||
{
|
||||
: SingleValueFlowAnalyzer(val, t), expr(e), local(true), unknown(false), dependOnThis(false) {
|
||||
|
||||
dependOnThis = exprDependsOnThis(expr);
|
||||
setupExprVarIds(expr);
|
||||
|
@ -2421,8 +2421,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
|||
var->isStatic() || var->isReference() || var->isExtern();
|
||||
}
|
||||
|
||||
void setupExprVarIds(const Token* start, int depth = 0)
|
||||
{
|
||||
void setupExprVarIds(const Token* start, int depth = 0) {
|
||||
const int maxDepth = 4;
|
||||
if (depth > maxDepth)
|
||||
return;
|
||||
|
@ -2468,9 +2467,13 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
|||
return ps;
|
||||
}
|
||||
|
||||
virtual bool match(const Token* tok) const OVERRIDE { return tok->exprId() == expr->exprId(); }
|
||||
virtual bool match(const Token* tok) const OVERRIDE {
|
||||
return tok->exprId() == expr->exprId();
|
||||
}
|
||||
|
||||
virtual bool dependsOnThis() const OVERRIDE { return dependOnThis; }
|
||||
virtual bool dependsOnThis() const OVERRIDE {
|
||||
return dependOnThis;
|
||||
}
|
||||
|
||||
virtual bool isGlobal() const OVERRIDE {
|
||||
return !local;
|
||||
|
@ -2492,11 +2495,11 @@ struct OppositeExpressionAnalyzer : ExpressionAnalyzer {
|
|||
};
|
||||
|
||||
static Analyzer::Result valueFlowForwardExpression(Token* startToken,
|
||||
const Token* endToken,
|
||||
const Token* exprTok,
|
||||
const std::list<ValueFlow::Value>& values,
|
||||
const TokenList* const tokenlist,
|
||||
const Settings* settings)
|
||||
const Token* endToken,
|
||||
const Token* exprTok,
|
||||
const std::list<ValueFlow::Value>& values,
|
||||
const TokenList* const tokenlist,
|
||||
const Settings* settings)
|
||||
{
|
||||
Analyzer::Result result{};
|
||||
for (const ValueFlow::Value& v : values) {
|
||||
|
@ -5043,10 +5046,10 @@ static void valueFlowForLoopSimplify(Token * const bodyStart, const nonneg int v
|
|||
}
|
||||
|
||||
static void valueFlowForLoopSimplifyAfter(Token* fortok,
|
||||
nonneg int varid,
|
||||
const MathLib::bigint num,
|
||||
TokenList* tokenlist,
|
||||
const Settings* settings)
|
||||
nonneg int varid,
|
||||
const MathLib::bigint num,
|
||||
TokenList* tokenlist,
|
||||
const Settings* settings)
|
||||
{
|
||||
const Token *vartok = nullptr;
|
||||
for (const Token *tok = fortok; tok; tok = tok->next()) {
|
||||
|
@ -6035,19 +6038,19 @@ struct ContainerExpressionAnalyzer : ExpressionAnalyzer {
|
|||
};
|
||||
|
||||
static Analyzer::Result valueFlowContainerForward(Token* startToken,
|
||||
const Token* endToken,
|
||||
const Token* exprTok,
|
||||
const ValueFlow::Value& value,
|
||||
TokenList* tokenlist)
|
||||
const Token* endToken,
|
||||
const Token* exprTok,
|
||||
const ValueFlow::Value& value,
|
||||
TokenList* tokenlist)
|
||||
{
|
||||
ContainerExpressionAnalyzer a(exprTok, value, tokenlist);
|
||||
return valueFlowGenericForward(startToken, endToken, a, tokenlist->getSettings());
|
||||
}
|
||||
|
||||
static Analyzer::Result valueFlowContainerForward(Token* startToken,
|
||||
const Token* exprTok,
|
||||
const ValueFlow::Value& value,
|
||||
TokenList* tokenlist)
|
||||
const Token* exprTok,
|
||||
const ValueFlow::Value& value,
|
||||
TokenList* tokenlist)
|
||||
{
|
||||
const Token* endToken = nullptr;
|
||||
const Function* f = Scope::nestedInFunction(startToken->scope());
|
||||
|
|
|
@ -2330,8 +2330,7 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer75()
|
||||
{
|
||||
void nullpointer75() {
|
||||
check("struct a {\n"
|
||||
" a *b() const;\n"
|
||||
" void c();\n"
|
||||
|
|
|
@ -152,13 +152,21 @@ private:
|
|||
return !val.isLifetimeValue();
|
||||
}
|
||||
|
||||
static bool isNotPossible(const ValueFlow::Value& val) { return !val.isPossible(); }
|
||||
static bool isNotPossible(const ValueFlow::Value& val) {
|
||||
return !val.isPossible();
|
||||
}
|
||||
|
||||
static bool isNotKnown(const ValueFlow::Value& val) { return !val.isKnown(); }
|
||||
static bool isNotKnown(const ValueFlow::Value& val) {
|
||||
return !val.isKnown();
|
||||
}
|
||||
|
||||
static bool isNotInconclusive(const ValueFlow::Value& val) { return !val.isInconclusive(); }
|
||||
static bool isNotInconclusive(const ValueFlow::Value& val) {
|
||||
return !val.isInconclusive();
|
||||
}
|
||||
|
||||
static bool isNotImpossible(const ValueFlow::Value& val) { return !val.isImpossible(); }
|
||||
static bool isNotImpossible(const ValueFlow::Value& val) {
|
||||
return !val.isImpossible();
|
||||
}
|
||||
|
||||
bool testValueOfXKnown(const char code[], unsigned int linenr, int value) {
|
||||
// Tokenize..
|
||||
|
@ -4662,9 +4670,8 @@ private:
|
|||
}
|
||||
|
||||
static std::string isPossibleContainerSizeValue(std::list<ValueFlow::Value> values,
|
||||
MathLib::bigint i,
|
||||
bool unique = true)
|
||||
{
|
||||
MathLib::bigint i,
|
||||
bool unique = true) {
|
||||
if (!unique)
|
||||
values.remove_if(&isNotPossible);
|
||||
if (values.size() != 1)
|
||||
|
@ -4679,9 +4686,8 @@ private:
|
|||
}
|
||||
|
||||
static std::string isImpossibleContainerSizeValue(std::list<ValueFlow::Value> values,
|
||||
MathLib::bigint i,
|
||||
bool unique = true)
|
||||
{
|
||||
MathLib::bigint i,
|
||||
bool unique = true) {
|
||||
if (!unique)
|
||||
values.remove_if(&isNotImpossible);
|
||||
if (values.size() != 1)
|
||||
|
@ -4696,9 +4702,8 @@ private:
|
|||
}
|
||||
|
||||
static std::string isInconclusiveContainerSizeValue(std::list<ValueFlow::Value> values,
|
||||
MathLib::bigint i,
|
||||
bool unique = true)
|
||||
{
|
||||
MathLib::bigint i,
|
||||
bool unique = true) {
|
||||
if (!unique)
|
||||
values.remove_if(&isNotInconclusive);
|
||||
if (values.size() != 1)
|
||||
|
@ -4712,8 +4717,7 @@ private:
|
|||
return "";
|
||||
}
|
||||
|
||||
static std::string isKnownContainerSizeValue(std::list<ValueFlow::Value> values, MathLib::bigint i, bool unique = true)
|
||||
{
|
||||
static std::string isKnownContainerSizeValue(std::list<ValueFlow::Value> values, MathLib::bigint i, bool unique = true) {
|
||||
if (!unique)
|
||||
values.remove_if(&isNotKnown);
|
||||
if (values.size() != 1)
|
||||
|
|
Loading…
Reference in New Issue