Skip to content

Commit 90d4127

Browse files
committed
Scope: Remove hides(..) and related predicates
There are no more consumers of hides(..). In addition, it doesn't make sense conceptually to look for variables in the same scope with the same name, as scopes will prohibit using the same name in the same scope. Reviewing real world cases where this occurs, they all seem to be extractor oddities (multiple copies of parameters for the same function etc.) which provides further evidence that this mode is not required.
1 parent 0c92f2e commit 90d4127

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,6 @@ predicate inSameTranslationUnit(File f1, File f2) {
160160
)
161161
}
162162

163-
/**
164-
* Gets a user variable which occurs in the "potential scope" of variable `v`.
165-
*/
166-
cached
167-
UserVariable getPotentialScopeOfVariable(UserVariable v) {
168-
result = getPotentialScopeOfVariable_candidate(v) and
169-
inSameTranslationUnit(v.getFile(), result.getFile())
170-
}
171-
172163
/**
173164
* Gets a user variable which occurs in the "outer scope" of variable `v`.
174165
*/
@@ -203,15 +194,6 @@ class TranslationUnit extends SourceFile {
203194
}
204195
}
205196

206-
/** Holds if `v2` may hide `v1`. */
207-
private predicate hides_candidate(UserVariable v1, UserVariable v2) {
208-
not v1 = v2 and
209-
v2 = getPotentialScopeOfVariable(v1) and
210-
v1.getName() = v2.getName() and
211-
// Member variables cannot hide other variables nor be hidden because the can be referenced through their qualified name.
212-
not (v1.isMember() or v2.isMember())
213-
}
214-
215197
/** Holds if `v2` may hide `v1`. */
216198
private predicate hides_candidateStrict(UserVariable v1, UserVariable v2) {
217199
not v1 = v2 and
@@ -256,16 +238,6 @@ private Stmt getEnclosingStmt(LocalScopeVariable v) {
256238
)
257239
}
258240

259-
/** Holds if `v2` hides `v1`. */
260-
predicate hides(UserVariable v1, UserVariable v2) {
261-
hides_candidate(v1, v2) and
262-
// Confirm that there's no closer candidate variable which `v2` hides
263-
not exists(UserVariable mid |
264-
hides_candidate(v1, mid) and
265-
hides_candidate(mid, v2)
266-
)
267-
}
268-
269241
/** Holds if `v2` strictly (`v2` is in an inner scope compared to `v1`) hides `v1`. */
270242
predicate hidesStrict(UserVariable v1, UserVariable v2) {
271243
hides_candidateStrict(v1, v2) and

0 commit comments

Comments
 (0)