Skip to content

Commit 4220240

Browse files
committed
Address review comments
1 parent cc02c95 commit 4220240

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

csharp/ql/src/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,17 +712,17 @@ module Private {
712712
exists(SourceOrSinkElement e |
713713
sourceElement(e, output, kind) and
714714
if outputNeedsReference(specLast(output))
715-
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
716-
else ref.asElement() = e
715+
then e = ref.getCallTarget()
716+
else e = ref.asElement()
717717
)
718718
}
719719

720720
private predicate sinkElementRef(InterpretNode ref, string input, string kind) {
721721
exists(SourceOrSinkElement e |
722722
sinkElement(e, input, kind) and
723723
if inputNeedsReference(specLast(input))
724-
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
725-
else ref.asElement() = e
724+
then e = ref.getCallTarget()
725+
else e = ref.asElement()
726726
)
727727
}
728728

csharp/ql/src/semmle/code/csharp/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ class InterpretNode extends TInterpretNode {
136136
/** Gets the callable that this node corresponds to, if any. */
137137
DataFlowCallable asCallable() { result = this.asElement() }
138138

139+
/** Gets the target of this call, if any. */
140+
Callable getCallTarget() { result = this.asCall().getARuntimeTarget() }
141+
139142
/** Gets a textual representation of this node. */
140143
string toString() {
141144
result = this.asElement().toString()

java/ql/src/semmle/code/java/dataflow/internal/DataFlowDispatch.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,13 @@ private import DataFlowUtil
44
private import semmle.code.java.dataflow.InstanceAccess
55
private import semmle.code.java.dataflow.FlowSummary
66
private import semmle.code.java.dispatch.VirtualDispatch as VirtualDispatch
7-
private import semmle.code.java.dataflow.internal.FlowSummaryImplSpecific
87

98
private module DispatchImpl {
109
/** Gets a viable implementation of the target of the given `Call`. */
1110
Callable viableCallable(Call c) {
1211
result = VirtualDispatch::viableCallable(c)
1312
or
14-
result = c.getCallee().getSourceDeclaration() and
15-
(
16-
result instanceof SummarizedCallable
17-
or
18-
sourceElement(result, _, _)
19-
or
20-
sinkElement(result, _, _)
21-
)
13+
result.(SummarizedCallable) = c.getCallee().getSourceDeclaration()
2214
}
2315

2416
/**

java/ql/src/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,17 +712,17 @@ module Private {
712712
exists(SourceOrSinkElement e |
713713
sourceElement(e, output, kind) and
714714
if outputNeedsReference(specLast(output))
715-
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
716-
else ref.asElement() = e
715+
then e = ref.getCallTarget()
716+
else e = ref.asElement()
717717
)
718718
}
719719

720720
private predicate sinkElementRef(InterpretNode ref, string input, string kind) {
721721
exists(SourceOrSinkElement e |
722722
sinkElement(e, input, kind) and
723723
if inputNeedsReference(specLast(input))
724-
then viableCallable(ref.asCall()) = any(InterpretNode n | n.asElement() = e).asCallable()
725-
else ref.asElement() = e
724+
then e = ref.getCallTarget()
725+
else e = ref.asElement()
726726
)
727727
}
728728

java/ql/src/semmle/code/java/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class InterpretNode extends TInterpretNode {
125125
/** Gets the callable that this node corresponds to, if any. */
126126
DataFlowCallable asCallable() { result = this.asElement() }
127127

128+
/** Gets the target of this call, if any. */
129+
Callable getCallTarget() { result = this.asCall().getCallee().getSourceDeclaration() }
130+
128131
/** Gets a textual representation of this node. */
129132
string toString() {
130133
result = this.asElement().toString()

0 commit comments

Comments
 (0)