astyle formatting

This commit is contained in:
Daniel Marjamäki 2021-06-19 14:47:35 +02:00
parent dd178c3ad9
commit 2d08564c8a
5 changed files with 40 additions and 139 deletions

View File

@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="results">
<attribute name="version">
<choice>
<value type="string">2</value>
</choice>
</attribute>
<element name="cppcheck">
<attribute name="version">
<data type="string">
<param name="pattern">[1-9]\.[0-9]+.*</param>
</data>
</attribute>
</element>
<element name="errors">
<zeroOrMore>
<element name="error">
<attribute name="id">
<data type="NCName"/>
</attribute>
<optional>
<attribute name="inconclusive">
<data type="boolean"/>
</attribute>
</optional>
<attribute name="msg">
<data type="string"/>
</attribute>
<attribute name="severity">
<choice>
<value type="string">error</value>
<value type="string">information</value>
<value type="string">performance</value>
<value type="string">portability</value>
<value type="string">style</value>
<value type="string">warning</value>
</choice>
</attribute>
<attribute name="verbose">
<data type="string"/>
</attribute>
<optional>
<attribute name="file0">
<data type="string"/>
</attribute>
</optional>
<optional>
<attribute name="cwe">
<data type="integer">
<param name="minExclusive">0</param>
</data>
</attribute>
</optional>
<optional>
<attribute name="hash">
<data type="integer">
<param name="minExclusive">1</param>
</data>
</attribute>
</optional>
<zeroOrMore>
<element name="location">
<attribute name="file">
<data type="string"/>
</attribute>
<attribute name="line">
<data type="integer">
<param name="minInclusive">0</param>
</data>
</attribute>
<attribute name="column">
<data type="integer">
<param name="minInclusive">0</param>
</data>
</attribute>
<optional>
<attribute name="info">
<data type="string"/>
</attribute>
</optional>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="symbol">
<data type="string"/>
</element>
</zeroOrMore>
</element>
</zeroOrMore>
</element>
</element>
</start>
</grammar>

View File

@ -25,8 +25,7 @@ struct ForwardTraversal {
Analyzer::Terminate terminate = Analyzer::Terminate::None; Analyzer::Terminate terminate = Analyzer::Terminate::None;
bool forked = false; bool forked = false;
Progress Break(Analyzer::Terminate t = Analyzer::Terminate::None) Progress Break(Analyzer::Terminate t = Analyzer::Terminate::None) {
{
if ((!analyzeOnly || analyzeTerminate) && t != Analyzer::Terminate::None) if ((!analyzeOnly || analyzeTerminate) && t != Analyzer::Terminate::None)
terminate = t; terminate = t;
return Progress::Break; return Progress::Break;

View File

@ -26,9 +26,9 @@ class Token;
template <class T> class ValuePtr; template <class T> class ValuePtr;
Analyzer::Result valueFlowGenericForward(Token* start, Analyzer::Result valueFlowGenericForward(Token* start,
const Token* end, const Token* end,
const ValuePtr<Analyzer>& a, const ValuePtr<Analyzer>& a,
const Settings* settings); const Settings* settings);
Analyzer::Result valueFlowGenericForward(Token* start, const ValuePtr<Analyzer>& a, const Settings* settings); Analyzer::Result valueFlowGenericForward(Token* start, const ValuePtr<Analyzer>& a, const Settings* settings);

View File

@ -262,8 +262,7 @@ static void fillProgramMemoryFromAssignments(ProgramMemory& pm, const Token* tok
continue; continue;
} }
tok2 = cond->astParent()->previous(); tok2 = cond->astParent()->previous();
} } else if (conditionIsTrue(cond, state)) {
else if (conditionIsTrue(cond, state)) {
if (inElse) if (inElse)
tok2 = tok2->link()->tokAt(-2); tok2 = tok2->link()->tokAt(-2);
++indentlevel; ++indentlevel;

View File

@ -1665,11 +1665,11 @@ static void valueFlowGlobalStaticVar(TokenList *tokenList, const Settings *setti
} }
static Analyzer::Result valueFlowForwardVariable(Token* const startToken, static Analyzer::Result valueFlowForwardVariable(Token* const startToken,
const Token* const endToken, const Token* const endToken,
const Variable* const var, const Variable* const var,
std::list<ValueFlow::Value> values, std::list<ValueFlow::Value> values,
TokenList* const tokenlist, TokenList* const tokenlist,
const Settings* const settings); const Settings* const settings);
static void valueFlowReverse(TokenList* tokenlist, static void valueFlowReverse(TokenList* tokenlist,
Token* tok, Token* tok,
@ -2408,12 +2408,12 @@ static std::vector<const Variable*> getAliasesFromValues(std::list<ValueFlow::Va
} }
static Analyzer::Result valueFlowForwardVariable(Token* const startToken, static Analyzer::Result valueFlowForwardVariable(Token* const startToken,
const Token* const endToken, const Token* const endToken,
const Variable* const var, const Variable* const var,
std::list<ValueFlow::Value> values, std::list<ValueFlow::Value> values,
std::vector<const Variable*> aliases, std::vector<const Variable*> aliases,
TokenList* const tokenlist, TokenList* const tokenlist,
const Settings* const settings) const Settings* const settings)
{ {
Analyzer::Action actions; Analyzer::Action actions;
Analyzer::Terminate terminate = Analyzer::Terminate::None; Analyzer::Terminate terminate = Analyzer::Terminate::None;
@ -2428,11 +2428,11 @@ static Analyzer::Result valueFlowForwardVariable(Token* const startToken,
} }
static Analyzer::Result valueFlowForwardVariable(Token* const startToken, static Analyzer::Result valueFlowForwardVariable(Token* const startToken,
const Token* const endToken, const Token* const endToken,
const Variable* const var, const Variable* const var,
std::list<ValueFlow::Value> values, std::list<ValueFlow::Value> values,
TokenList* const tokenlist, TokenList* const tokenlist,
const Settings* const settings) const Settings* const settings)
{ {
auto aliases = getAliasesFromValues(values); auto aliases = getAliasesFromValues(values);
return valueFlowForwardVariable( return valueFlowForwardVariable(
@ -2532,11 +2532,11 @@ struct OppositeExpressionAnalyzer : ExpressionAnalyzer {
}; };
static Analyzer::Result valueFlowForwardExpression(Token* startToken, static Analyzer::Result valueFlowForwardExpression(Token* startToken,
const Token* endToken, const Token* endToken,
const Token* exprTok, const Token* exprTok,
const std::list<ValueFlow::Value>& values, const std::list<ValueFlow::Value>& values,
const TokenList* const tokenlist, const TokenList* const tokenlist,
const Settings* settings) const Settings* settings)
{ {
Analyzer::Action actions; Analyzer::Action actions;
Analyzer::Terminate terminate = Analyzer::Terminate::None; Analyzer::Terminate terminate = Analyzer::Terminate::None;
@ -2623,11 +2623,11 @@ ValuePtr<Analyzer> makeAnalyzer(Token* exprTok, const ValueFlow::Value& value, c
} }
static Analyzer::Result valueFlowForward(Token* startToken, static Analyzer::Result valueFlowForward(Token* startToken,
const Token* endToken, const Token* endToken,
const Token* exprTok, const Token* exprTok,
std::list<ValueFlow::Value> values, std::list<ValueFlow::Value> values,
TokenList* const tokenlist, TokenList* const tokenlist,
const Settings* settings) const Settings* settings)
{ {
const Token* expr = solveExprValues(exprTok, values); const Token* expr = solveExprValues(exprTok, values);
if (expr->variable()) { if (expr->variable()) {
@ -4733,8 +4733,7 @@ struct SimpleConditionHandler : ConditionHandler {
const Token* exprTok, const Token* exprTok,
const std::list<ValueFlow::Value>& values, const std::list<ValueFlow::Value>& values,
TokenList* tokenlist, TokenList* tokenlist,
const Settings* settings) const OVERRIDE const Settings* settings) const OVERRIDE {
{
return valueFlowForward(start->next(), stop, exprTok, values, tokenlist, settings); return valueFlowForward(start->next(), stop, exprTok, values, tokenlist, settings);
} }
@ -6094,18 +6093,18 @@ struct ContainerVariableAnalyzer : VariableAnalyzer {
}; };
static Analyzer::Result valueFlowContainerForward(Token* tok, static Analyzer::Result valueFlowContainerForward(Token* tok,
const Token* endToken, const Token* endToken,
const Variable* var, const Variable* var,
ValueFlow::Value value, ValueFlow::Value value,
TokenList* tokenlist) TokenList* tokenlist)
{ {
ContainerVariableAnalyzer a(var, value, getAliasesFromValues({value}), tokenlist); ContainerVariableAnalyzer a(var, value, getAliasesFromValues({value}), tokenlist);
return valueFlowGenericForward(tok, endToken, a, tokenlist->getSettings()); return valueFlowGenericForward(tok, endToken, a, tokenlist->getSettings());
} }
static Analyzer::Result valueFlowContainerForward(Token* tok, static Analyzer::Result valueFlowContainerForward(Token* tok,
const Variable* var, const Variable* var,
ValueFlow::Value value, ValueFlow::Value value,
TokenList* tokenlist) TokenList* tokenlist)
{ {
const Token * endOfVarScope = nullptr; const Token * endOfVarScope = nullptr;
if (var->isLocal() || var->isArgument()) if (var->isLocal() || var->isArgument())
@ -6523,8 +6522,7 @@ struct ContainerConditionHandler : ConditionHandler {
const Token* exprTok, const Token* exprTok,
const std::list<ValueFlow::Value>& values, const std::list<ValueFlow::Value>& values,
TokenList* tokenlist, TokenList* tokenlist,
const Settings*) const OVERRIDE const Settings*) const OVERRIDE {
{
// TODO: Forward multiple values // TODO: Forward multiple values
if (values.empty()) if (values.empty())
return {}; return {};