Skip to content

Commit 9be5a7b

Browse files
committed
Identifier Hidden: missed expeted for shared, generalize variable count check
1 parent a1f4362 commit 9be5a7b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| test.c:4:7:4:9 | id1 | Variable is hiding variable $@. | test.c:1:5:1:7 | id1 | id1 |
2-
| test.c:7:13:7:15 | id1 | Variable is hiding variable $@. | test.c:1:5:1:7 | id1 | id1 |
3-
| test.c:10:12:10:14 | id1 | Variable is hiding variable $@. | test.c:1:5:1:7 | id1 | id1 |
4-
| test.c:11:14:11:16 | id1 | Variable is hiding variable $@. | test.c:10:12:10:14 | id1 | id1 |
5-
| test.c:24:24:24:26 | id2 | Variable is hiding variable $@. | test.c:22:5:22:7 | id2 | id2 |
1+
| test.c:4:7:4:9 | id1 | Declaration is hiding declaration $@. | test.c:1:5:1:7 | id1 | id1 |
2+
| test.c:7:13:7:15 | id1 | Declaration is hiding declaration $@. | test.c:1:5:1:7 | id1 | id1 |
3+
| test.c:10:12:10:14 | id1 | Declaration is hiding declaration $@. | test.c:1:5:1:7 | id1 | id1 |
4+
| test.c:11:14:11:16 | id1 | Declaration is hiding declaration $@. | test.c:10:12:10:14 | id1 | id1 |
5+
| test.c:24:24:24:26 | id2 | Declaration is hiding declaration $@. | test.c:22:5:22:7 | id2 | id2 |

cpp/common/src/codingstandards/cpp/Scope.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class Scope extends Element {
8080

8181
int getNumberOfVariables() { result = count(getAVariable()) }
8282

83+
int getNumberOfDeclarations() { result = count(getADeclaration()) }
84+
8385
Scope getAnAncestor() { result = this.getStrictParent+() }
8486

8587
Scope getStrictParent() { result = getParentScope(this) }
@@ -133,9 +135,9 @@ private UserDeclaration getPotentialScopeOfDeclaration_candidate(UserDeclaration
133135
exists(Scope s |
134136
result = s.getADeclaration() and
135137
(
136-
// Declaration in an ancestor scope, but only if there are less than 100 variables in this scope
138+
// Declaration in an ancestor scope, but only if there are less than 100 declarations in this scope
137139
v = s.getAnAncestor().getADeclaration() and
138-
s.getNumberOfVariables() < 100
140+
s.getNumberOfDeclarations() < 100
139141
or
140142
// In the same scope, but not the same Declaration, and choose just one to report
141143
v = s.getADeclaration() and
@@ -152,7 +154,7 @@ private UserDeclaration getOuterScopesOfDeclaration_candidate(UserDeclaration v)
152154
(
153155
// Declaration in an ancestor scope, but only if there are less than 100 variables in this scope
154156
v = s.getAnAncestor().getADeclaration() and
155-
s.getNumberOfVariables() < 100
157+
s.getNumberOfDeclarations() < 100
156158
)
157159
)
158160
}

0 commit comments

Comments
 (0)