Skip to content

Commit 4360b18

Browse files
committed
simplify
1 parent 8702f6a commit 4360b18

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

lib/checkunusedvar.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,15 +1603,11 @@ void CheckUnusedVar::checkStructMemberUsage()
16031603
// then don't warn about other struct members
16041604
bool structInUnionWithUsedMember = false;
16051605
if (scope.type == ScopeType::eStruct && scope.nestedIn && scope.nestedIn->type == ScopeType::eUnion) {
1606-
for (const Variable &unionVar : scope.varlist) {
1607-
for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) {
1608-
if (tok->variable() == &unionVar && tok != unionVar.nameToken()) {
1609-
structInUnionWithUsedMember = true;
1610-
break;
1611-
}
1612-
}
1613-
if (structInUnionWithUsedMember)
1606+
for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) {
1607+
if (tok->variable() && tok->variable()->scope() == scope.nestedIn) {
1608+
structInUnionWithUsedMember = true;
16141609
break;
1610+
}
16151611
}
16161612
}
16171613

@@ -1632,7 +1628,6 @@ void CheckUnusedVar::checkStructMemberUsage()
16321628
if (structInUnionWithUsedMember)
16331629
continue;
16341630

1635-
16361631
// Check if the struct member variable is used anywhere in the file
16371632
bool use = false;
16381633
for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) {

0 commit comments

Comments
 (0)