Skip to content

Commit c92a7e2

Browse files
committed
Minimize change to Iterators.qll
1 parent ec7ed15 commit c92a7e2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

cpp/common/src/codingstandards/cpp/Iterators.qll

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ class ContainerInvalidationOperation extends FunctionCall {
177177
]
178178
)
179179
or
180-
this.getTarget().hasGlobalOrStdName(["swap", "operator>>", "getline"])
180+
exists(FunctionCall fc |
181+
fc.getTarget().getNamespace() instanceof StdNS and
182+
this.getTarget().getName() in ["swap", "operator>>", "getline"]
183+
)
181184
)
182185
)
183186
}
@@ -252,11 +255,16 @@ class AdditiveOperatorFunctionCall extends FunctionCall {
252255
*/
253256
class STLContainer extends Class {
254257
STLContainer() {
255-
this.hasGlobalOrStdName([
258+
getNamespace() instanceof StdNS and
259+
getSimpleName() in [
256260
"vector", "list", "deque", "set", "multiset", "map", "multimap", "stack", "queue",
257261
"priority_queue", "string", "forward_list", "unordered_set", "unordered_multiset",
258262
"unordered_map", "unordered_multimap", "valarray", "string", "basic_string"
259-
])
263+
]
264+
or
265+
getSimpleName() = "string"
266+
or
267+
getSimpleName() = "basic_string"
260268
}
261269

262270
/**
@@ -291,7 +299,7 @@ class STLContainer extends Class {
291299
IteratorSource getAConstIteratorEndFunctionCall() { result = getACallTo("cend") }
292300

293301
IteratorSource getANonConstIteratorFunctionCall() {
294-
//result = this.getACallToAFunction() and
302+
result = getACallToAFunction() and
295303
result.getTarget().getType() instanceof NonConstIteratorType
296304
}
297305

@@ -343,24 +351,24 @@ class STLContainerVariable extends Variable {
343351
* to create this functionality.
344352
*/
345353
class IteratorRangeModel extends Function {
346-
IteratorRangeModel() { this.hasGlobalOrStdName("lexicographical_compare") }
354+
IteratorRangeModel() { hasQualifiedName("std", "lexicographical_compare") }
347355

348356
int getAnIndexOfAStartRange() {
349-
(this.hasGlobalOrStdName("lexicographical_compare") and result = [0, 1])
357+
(hasQualifiedName("std", "lexicographical_compare") and result = [0, 1])
350358
}
351359

352360
int getAnIndexOfAEndRange() {
353-
(this.hasGlobalOrStdName("lexicographical_compare") and result = [2, 3])
361+
(hasQualifiedName("std", "lexicographical_compare") and result = [2, 3])
354362
}
355363

356364
int getAnIteratorArgumentIndex() {
357-
(this.hasGlobalOrStdName("lexicographical_compare") and result = [0, 1, 2, 3])
365+
(hasQualifiedName("std", "lexicographical_compare") and result = [0, 1, 2, 3])
358366
}
359367

360368
predicate getAPairOfStartEndIndexes(int start, int end) {
361-
this.hasGlobalOrStdName("lexicographical_compare") and start = 0 and end = 1
369+
hasQualifiedName("std", "lexicographical_compare") and start = 0 and end = 1
362370
or
363-
this.hasGlobalOrStdName("lexicographical_compare") and start = 2 and end = 3
371+
hasQualifiedName("std", "lexicographical_compare") and start = 2 and end = 3
364372
}
365373
}
366374

0 commit comments

Comments
 (0)