Skip to content

Commit 4766492

Browse files
author
Robert Marsh
committed
C++: respond to PR comments on output iterators
1 parent 1f8167b commit 4766492

File tree

1 file changed

+3
-18
lines changed
  • cpp/ql/src/semmle/code/cpp/models/implementations

1 file changed

+3
-18
lines changed

cpp/ql/src/semmle/code/cpp/models/implementations/Iterator.qll

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,6 @@ private FunctionInput getIteratorArgumentInput(Operator op, int index) {
7878
)
7979
}
8080

81-
private FunctionOutput getIteratorArgumentOutput(Operator op, int index) {
82-
exists(Type t |
83-
t =
84-
op
85-
.getACallToThisFunction()
86-
.getArgument(index)
87-
.getExplicitlyConverted()
88-
.getType()
89-
.stripTopLevelSpecifiers()
90-
|
91-
result.isParameterDeref(index) // TODO: does this work with an rvalue reference?
92-
)
93-
}
94-
9581
/**
9682
* A non-member prefix `operator*` function for an iterator type.
9783
*/
@@ -108,7 +94,7 @@ class IteratorPointerDereferenceOperator extends Operator, TaintFunction, Iterat
10894
output.isReturnValue()
10995
or
11096
input.isReturnValueDeref() and
111-
output = getIteratorArgumentOutput(this, 0)
97+
output.isParameterDeref(0)
11298
}
11399
}
114100

@@ -310,7 +296,7 @@ class IteratorAssignmentMemberOperator extends MemberFunction, TaintFunction {
310296
}
311297

312298
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
313-
input.isParameter(0) and
299+
input.isParameterDeref(0) and
314300
output.isQualifierObject()
315301
}
316302
}
@@ -344,8 +330,7 @@ class BeginOrEndFunction extends MemberFunction, TaintFunction, GetIteratorFunct
344330
*/
345331
class InserterIteratorFunction extends GetIteratorFunction {
346332
InserterIteratorFunction() {
347-
this.hasName(["front_inserter", "inserter", "back_inserter"]) and
348-
this.getNamespace().hasName("std")
333+
this.hasQualifiedName("std", ["front_inserter", "inserter", "back_inserter"])
349334
}
350335

351336
override predicate getsIterator(FunctionInput input, FunctionOutput output) {

0 commit comments

Comments
 (0)