Skip to content

Commit d5a478d

Browse files
committed
astyle formatting
[ci skip]
1 parent 4cef2e9 commit d5a478d

8 files changed

Lines changed: 108 additions & 112 deletions

File tree

lib/astutils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ const Token * astIsVariableComparison(const Token *tok, const std::string &comp,
138138

139139
static bool hasToken(const Token * startTok, const Token * stopTok, const Token * tok)
140140
{
141-
for(const Token * tok2 = startTok;tok2 != stopTok;tok2 = tok2->next()) {
142-
if(tok2 == tok)
141+
for (const Token * tok2 = startTok; tok2 != stopTok; tok2 = tok2->next()) {
142+
if (tok2 == tok)
143143
return true;
144144
}
145145
return false;
@@ -156,9 +156,9 @@ const Token * nextAfterAstRightmostLeaf(const Token * tok)
156156
else
157157
rightmostLeaf = rightmostLeaf->astOperand1();
158158
} while (rightmostLeaf->astOperand1());
159-
while(Token::Match(rightmostLeaf->next(), "]|)") && !hasToken(rightmostLeaf->next()->link(), rightmostLeaf->next(), tok))
159+
while (Token::Match(rightmostLeaf->next(), "]|)") && !hasToken(rightmostLeaf->next()->link(), rightmostLeaf->next(), tok))
160160
rightmostLeaf = rightmostLeaf->next();
161-
if(rightmostLeaf->str() == "{" && rightmostLeaf->link())
161+
if (rightmostLeaf->str() == "{" && rightmostLeaf->link())
162162
rightmostLeaf = rightmostLeaf->link();
163163
return rightmostLeaf->next();
164164
}
@@ -963,9 +963,9 @@ const Token *findLambdaEndToken(const Token *first)
963963
{
964964
if (!first || first->str() != "[")
965965
return nullptr;
966-
if(!Token::Match(first->link(), "] (|{"))
966+
if (!Token::Match(first->link(), "] (|{"))
967967
return nullptr;
968-
if(first->astOperand1() != first->link()->next())
968+
if (first->astOperand1() != first->link()->next())
969969
return nullptr;
970970
const Token * tok = first;
971971

lib/checkautovariables.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -590,23 +590,23 @@ void CheckAutoVariables::returnReference()
590590

591591
static bool isInScope(const Token * tok, const Scope * scope)
592592
{
593-
if(!tok)
593+
if (!tok)
594594
return false;
595-
if(!scope)
595+
if (!scope)
596596
return false;
597597
const Variable * var = tok->variable();
598-
if(var && (var->isGlobal() || var->isStatic() || var->isExtern()))
598+
if (var && (var->isGlobal() || var->isStatic() || var->isExtern()))
599599
return false;
600-
if(tok->scope() && tok->scope()->isNestedIn(scope))
600+
if (tok->scope() && tok->scope()->isNestedIn(scope))
601601
return true;
602-
if(!var)
602+
if (!var)
603603
return false;
604-
if(var->isArgument() && !var->isReference()) {
604+
if (var->isArgument() && !var->isReference()) {
605605
const Scope * tokScope = tok->scope();
606-
if(!tokScope)
606+
if (!tokScope)
607607
return false;
608-
for(const Scope * argScope:tokScope->nestedList) {
609-
if(argScope && argScope->isNestedIn(scope))
608+
for (const Scope * argScope:tokScope->nestedList) {
609+
if (argScope && argScope->isNestedIn(scope))
610610
return true;
611611
}
612612
}
@@ -615,35 +615,35 @@ static bool isInScope(const Token * tok, const Scope * scope)
615615

616616
void CheckAutoVariables::checkVarLifetimeScope(const Token * start, const Token * end)
617617
{
618-
if(!start)
618+
if (!start)
619619
return;
620620
const Scope * scope = start->scope();
621-
if(!scope)
621+
if (!scope)
622622
return;
623623
// If the scope is not set correctly then skip checking it
624-
if(scope->bodyStart != start)
624+
if (scope->bodyStart != start)
625625
return;
626626
for (const Token *tok = start; tok && tok != end; tok = tok->next()) {
627627
// Skip duplicate warning from dangling references
628-
if(Token::Match(tok, "& %var%"))
628+
if (Token::Match(tok, "& %var%"))
629629
continue;
630-
if(tok->variable() && tok->variable()->isPointer())
630+
if (tok->variable() && tok->variable()->isPointer())
631631
continue;
632-
if(std::any_of(tok->values().begin(), tok->values().end(), std::mem_fn(&ValueFlow::Value::isTokValue)))
632+
if (std::any_of(tok->values().begin(), tok->values().end(), std::mem_fn(&ValueFlow::Value::isTokValue)))
633633
continue;
634634

635-
for(const ValueFlow::Value& val:tok->values()) {
636-
if(!val.isLifetimeValue())
635+
for (const ValueFlow::Value& val:tok->values()) {
636+
if (!val.isLifetimeValue())
637637
continue;
638-
if(Token::Match(tok->astParent(), "return|throw")) {
638+
if (Token::Match(tok->astParent(), "return|throw")) {
639639
if (isInScope(val.tokvalue, scope)) {
640640
errorReturnDanglingLifetime(tok, &val);
641641
break;
642642
}
643643
}
644644
}
645645
const Token *lambdaEndToken = findLambdaEndToken(tok);
646-
if(lambdaEndToken) {
646+
if (lambdaEndToken) {
647647
checkVarLifetimeScope(lambdaEndToken->link(), lambdaEndToken);
648648
tok = lambdaEndToken;
649649
}
@@ -669,31 +669,31 @@ void CheckAutoVariables::errorReturnDanglingLifetime(const Token *tok, const Val
669669
const Token *vartok = val->tokvalue;
670670
ErrorPath errorPath = val->errorPath;
671671
std::string msg = "";
672-
switch(val->lifetimeKind) {
673-
case ValueFlow::Value::Object:
674-
msg = "Returning object";
675-
break;
676-
case ValueFlow::Value::Lambda:
677-
msg = "Returning lambda";
678-
break;
679-
case ValueFlow::Value::Iterator:
680-
msg = "Returning iterator";
681-
break;
672+
switch (val->lifetimeKind) {
673+
case ValueFlow::Value::Object:
674+
msg = "Returning object";
675+
break;
676+
case ValueFlow::Value::Lambda:
677+
msg = "Returning lambda";
678+
break;
679+
case ValueFlow::Value::Iterator:
680+
msg = "Returning iterator";
681+
break;
682682
}
683-
if(vartok) {
683+
if (vartok) {
684684
errorPath.emplace_back(vartok, "Variable created here.");
685685
const Variable * var = vartok->variable();
686-
if(var) {
687-
switch(val->lifetimeKind) {
688-
case ValueFlow::Value::Object:
689-
msg += " that points to local variable";
690-
break;
691-
case ValueFlow::Value::Lambda:
692-
msg += " that captures local variable";
693-
break;
694-
case ValueFlow::Value::Iterator:
695-
msg += " to local container";
696-
break;
686+
if (var) {
687+
switch (val->lifetimeKind) {
688+
case ValueFlow::Value::Object:
689+
msg += " that points to local variable";
690+
break;
691+
case ValueFlow::Value::Lambda:
692+
msg += " that captures local variable";
693+
break;
694+
case ValueFlow::Value::Iterator:
695+
msg += " to local container";
696+
break;
697697
}
698698
msg += " '" + var->name() + "'";
699699
}

lib/checkcondition.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ namespace {
5353

5454
bool CheckCondition::diag(const Token* tok, bool insert)
5555
{
56-
if(!tok)
56+
if (!tok)
5757
return false;
58-
if(mCondDiags.find(tok) == mCondDiags.end()) {
59-
if(insert)
58+
if (mCondDiags.find(tok) == mCondDiags.end()) {
59+
if (insert)
6060
mCondDiags.insert(tok);
6161
return false;
6262
}
@@ -717,7 +717,7 @@ static std::string innerSmtString(const Token * tok)
717717

718718
void CheckCondition::oppositeInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
719719
{
720-
if(diag(tok1) & diag(tok2))
720+
if (diag(tok1) & diag(tok2))
721721
return;
722722
const std::string s1(tok1 ? tok1->expressionString() : "x");
723723
const std::string s2(tok2 ? tok2->expressionString() : "!x");
@@ -732,7 +732,7 @@ void CheckCondition::oppositeInnerConditionError(const Token *tok1, const Token*
732732

733733
void CheckCondition::identicalInnerConditionError(const Token *tok1, const Token* tok2, ErrorPath errorPath)
734734
{
735-
if(diag(tok1) & diag(tok2))
735+
if (diag(tok1) & diag(tok2))
736736
return;
737737
const std::string s1(tok1 ? tok1->expressionString() : "x");
738738
const std::string s2(tok2 ? tok2->expressionString() : "x");
@@ -747,7 +747,7 @@ void CheckCondition::identicalInnerConditionError(const Token *tok1, const Token
747747

748748
void CheckCondition::identicalConditionAfterEarlyExitError(const Token *cond1, const Token* cond2, ErrorPath errorPath)
749749
{
750-
if(diag(cond1) & diag(cond2))
750+
if (diag(cond1) & diag(cond2))
751751
return;
752752
const std::string cond(cond1 ? cond1->expressionString() : "x");
753753
errorPath.emplace_back(ErrorPathItem(cond1, "first condition"));
@@ -1278,7 +1278,7 @@ void CheckCondition::alwaysTrueFalse()
12781278
if (!tok->hasKnownIntValue())
12791279
continue;
12801280
// Skip already diagnosed values
1281-
if(diag(tok, false))
1281+
if (diag(tok, false))
12821282
continue;
12831283
if (Token::Match(tok, "%num%|%bool%|%char%"))
12841284
continue;

lib/symboldatabase.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,16 +959,15 @@ class CPPCHECKLIB Scope {
959959
return nullptr;
960960
}
961961

962-
bool isNestedIn(const Scope * outer) const
963-
{
964-
if(!outer)
962+
bool isNestedIn(const Scope * outer) const {
963+
if (!outer)
965964
return false;
966-
if(outer == this)
965+
if (outer == this)
967966
return true;
968967
const Scope * parent = nestedIn;
969-
while(outer != parent && parent)
968+
while (outer != parent && parent)
970969
parent = parent->nestedIn;
971-
if(parent && parent == outer)
970+
if (parent && parent == outer)
972971
return true;
973972
return false;
974973
}

0 commit comments

Comments
 (0)