Skip to content

Commit 916ab00

Browse files
Merge branch 'main' into chr_13944
2 parents abcbdb3 + b37e6b8 commit 916ab00

14 files changed

Lines changed: 205 additions & 29 deletions

.selfcheck_suppressions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ useStlAlgorithm:externals/simplecpp/simplecpp.cpp
7979
funcArgNamesDifferentUnnamed:externals/simplecpp/simplecpp.h
8080
missingMemberCopy:externals/simplecpp/simplecpp.h
8181
shadowFunction:externals/simplecpp/simplecpp.h
82+
knownConditionTrueFalse:externals/simplecpp/simplecpp.cpp

lib/astutils.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,6 @@ bool isTemporary(const Token* tok, const Library* library, bool unknown)
495495
}
496496
return unknown;
497497
}
498-
if (tok->isCast())
499-
return false;
500498
// Currying a function is unknown in cppcheck
501499
if (Token::simpleMatch(tok, "(") && Token::simpleMatch(tok->astOperand1(), "("))
502500
return unknown;
@@ -1543,8 +1541,6 @@ bool isUsedAsBool(const Token* const tok, const Settings& settings)
15431541
return true;
15441542
if (parent->isCast())
15451543
return !Token::simpleMatch(parent->astOperand1(), "dynamic_cast") && isUsedAsBool(parent, settings);
1546-
if (parent->isUnaryOp("*"))
1547-
return isUsedAsBool(parent, settings);
15481544
if (Token::Match(parent, "==|!=") && tok->valueType() && tok->valueType()->pointer &&
15491545
tok->astSibling()->hasKnownIntValue() && tok->astSibling()->getKnownIntValue() == 0)
15501546
return true;

lib/checkclass.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,9 +3452,14 @@ void CheckClassImpl::checkUselessOverride()
34523452

34533453
if (isSameCode) {
34543454
// bailout for shadowed members
3455-
if (!classScope->definedType ||
3456-
!getDuplInheritedMembersRecursive(classScope->definedType, classScope->definedType, /*skipPrivate*/ false).empty() ||
3457-
!getDuplInheritedMemberFunctionsRecursive(classScope->definedType, classScope->definedType, /*skipPrivate*/ false).empty())
3455+
if (!getDuplInheritedMembersRecursive(classScope->definedType,
3456+
classScope->definedType,
3457+
/*skipPrivate*/ false)
3458+
.empty() ||
3459+
!getDuplInheritedMemberFunctionsRecursive(classScope->definedType,
3460+
classScope->definedType,
3461+
/*skipPrivate*/ false)
3462+
.empty())
34583463
continue;
34593464
uselessOverrideError(baseFunc, &func, true);
34603465
continue;

lib/checkcondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ bool CheckConditionImpl::isOverlappingCond(const Token * const cond1, const Toke
455455
if (!num1->isNumber() || MathLib::isNegative(num1->str()))
456456
return false;
457457

458-
if (!Token::Match(cond2, "&|==") || !cond2->astOperand1() || !cond2->astOperand2())
458+
if (!Token::Match(cond2, "&|==") || !cond2->astOperand1())
459459
return false;
460460
const Token *expr2 = cond2->astOperand1();
461461
const Token *num2 = cond2->astOperand2();

lib/checkother.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,13 +1945,16 @@ void CheckOtherImpl::checkConstPointer()
19451945
if (deref == MEMBER) {
19461946
if (!gparent)
19471947
continue;
1948-
if (parent->astOperand2()) {
1949-
if (parent->astOperand2()->function() && parent->astOperand2()->function()->isConst())
1948+
const Token* funcParent = parent;
1949+
while (Token::simpleMatch(funcParent->astParent(), "."))
1950+
funcParent = funcParent->astParent();
1951+
if (funcParent->astOperand2()) {
1952+
if (funcParent->astOperand2()->function() && funcParent->astOperand2()->function()->isConst())
19501953
continue;
1951-
if (mSettings.library.isFunctionConst(parent->astOperand2()))
1954+
if (mSettings.library.isFunctionConst(funcParent->astOperand2()))
19521955
continue;
1953-
if (parent->astOperand2()->varId()) {
1954-
if (gparent->str() == "?" && astIsLHS(parent))
1956+
if (funcParent->astOperand2()->varId()) {
1957+
if (gparent->str() == "?" && astIsLHS(funcParent))
19551958
continue;
19561959
}
19571960
}

lib/checkstl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void CheckStlImpl::iterators()
549549
}
550550

551551
// Not different containers if a reference is used..
552-
if (containerToken && containerToken->variable() && containerToken->variable()->isReference()) {
552+
if (containerToken->variable() && containerToken->variable()->isReference()) {
553553
const Token *nameToken = containerToken->variable()->nameToken();
554554
if (Token::Match(nameToken, "%name% =")) {
555555
const Token *name1 = nameToken->tokAt(2);

lib/checkunusedvar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void Variables::clearAliases(nonneg int varid)
249249

250250
void Variables::eraseAliases(nonneg int varid)
251251
{
252-
VariableUsage *usage = find(varid);
252+
const VariableUsage *usage = find(varid);
253253

254254
if (usage) {
255255
for (auto aliases = usage->_aliases.cbegin(); aliases != usage->_aliases.cend(); ++aliases)
@@ -329,7 +329,7 @@ void Variables::write(nonneg int varid, const Token* tok)
329329

330330
void Variables::writeAliases(nonneg int varid, const Token* tok)
331331
{
332-
VariableUsage *usage = find(varid);
332+
const VariableUsage *usage = find(varid);
333333

334334
if (usage) {
335335
for (auto aliases = usage->_aliases.cbegin(); aliases != usage->_aliases.cend(); ++aliases) {

lib/forwardanalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ namespace {
782782
} else if (thenBranch.check) {
783783
return Break();
784784
} else {
785-
if (analyzer->isConditional() && stopUpdates())
785+
if (stopOnCondition(condTok) && stopUpdates())
786786
return Break(Analyzer::Terminate::Conditional);
787787
analyzer->assume(condTok, false);
788788
}

lib/reverseanalyzer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,6 @@ namespace {
340340
valueFlowGenericForward(condTok, analyzer, tokenlist, errorLogger, settings);
341341
else if (condAction.isRead())
342342
break;
343-
// If the condition modifies the variable then bail
344-
if (condAction.isModified())
345-
break;
346343
tok = jumpToStart(tok->link());
347344
continue;
348345
}

lib/symboldatabase.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,10 +1043,8 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
10431043
scope.definedType->needInitialization = Type::NeedInitialization::True;
10441044
else if (!unknown)
10451045
scope.definedType->needInitialization = Type::NeedInitialization::False;
1046-
else {
1047-
if (scope.definedType->needInitialization == Type::NeedInitialization::Unknown)
1048-
unknowns++;
1049-
}
1046+
else
1047+
unknowns++;
10501048
}
10511049
} else if (scope.type == ScopeType::eUnion && scope.definedType->needInitialization == Type::NeedInitialization::Unknown)
10521050
scope.definedType->needInitialization = Type::NeedInitialization::True;

0 commit comments

Comments
 (0)