Skip to content

Commit b5ff407

Browse files
committed
Scope: Adopt use of getAChildScope()
1 parent f25507e commit b5ff407

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ class Scope extends Element {
138138
* Holds if `name` is declared in a nested scope.
139139
*/
140140
private predicate isNameDeclaredInNestedScope(string name) {
141-
exists(Scope child |
142-
child.getStrictParent() = this and
143-
child.isNameDeclaredInThisOrNestedScope(name)
144-
)
141+
this.getAChildScope().isNameDeclaredInThisOrNestedScope(name)
145142
}
146143

147144
/**
@@ -173,7 +170,8 @@ class Scope extends Element {
173170
}
174171

175172
/**
176-
* Gets a variable with `name` which is declared above and hidden by a variable in this or a nested scope.
173+
* Gets a variable with `name` which is declared in a scope above this one, and hidden by a variable in this or a
174+
* nested scope.
177175
*/
178176
UserVariable getAHidingVariable(string name) {
179177
isNameDeclaredAboveHiddenByThisOrNested(name) and
@@ -185,7 +183,7 @@ class Scope extends Element {
185183
or
186184
// Declared in a child scope
187185
exists(Scope child |
188-
child.getStrictParent() = this and
186+
getAChildScope() = child and
189187
child.isNameDeclaredInThisOrNestedScope(name) and
190188
result = child.getAHidingVariable(name)
191189
)
@@ -248,8 +246,8 @@ class TranslationUnit extends SourceFile {
248246
/** Holds if `v2` strictly (`v2` is in an inner scope compared to `v1`) hides `v1`. */
249247
predicate hides_candidateStrict(UserVariable v1, UserVariable v2) {
250248
exists(Scope s, string name |
251-
v1 = s.getStrictParent().getAHiddenVariable(name) and
252-
v2 = s.getAHidingVariable(name) and
249+
v1 = s.getAHiddenVariable(name) and
250+
v2 = s.getAChildScope().getAHidingVariable(name) and
253251
not v1 = v2
254252
) and
255253
inSameTranslationUnitLate(v1.getFile(), v2.getFile()) and

0 commit comments

Comments
 (0)