C#: Address review comments

This commit is contained in:
Tom Hvitved
2020-05-04 09:01:49 +02:00
parent 1959480b78
commit 32b419229d
5 changed files with 30 additions and 22 deletions

View File

@@ -163,7 +163,7 @@ class CallableFlowSink extends TCallableFlowSink {
Expr getSink(Call c) { none() }
/**
* Gets the type of the sink for call `c`. Unlik `getSink()`, this is defined
* Gets the type of the sink for call `c`. Unlike `getSink()`, this is defined
* for all flow sink specifications.
*/
Type getSinkType(Call c) { result = this.getSink(c).getType() }
@@ -235,18 +235,22 @@ private CallableFlowSinkDelegateArg getDelegateFlowSinkArg(
/** A flow sink specification: parameter of a delegate argument. */
class CallableFlowSinkDelegateArg extends CallableFlowSink, TCallableFlowSinkDelegateArg {
private int i;
private int j;
private int delegateIndex;
private int parameterIndex;
CallableFlowSinkDelegateArg() { this = TCallableFlowSinkDelegateArg(i, j) }
CallableFlowSinkDelegateArg() {
this = TCallableFlowSinkDelegateArg(delegateIndex, parameterIndex)
}
/** Gets the index of the delegate argument. */
int getDelegateIndex() { result = i }
int getDelegateIndex() { result = delegateIndex }
/** Gets the index of the delegate parameter. */
int getDelegateParameterIndex() { result = j }
int getDelegateParameterIndex() { result = parameterIndex }
override string toString() { result = "parameter " + j + " of argument " + i }
override string toString() {
result = "parameter " + parameterIndex + " of argument " + delegateIndex
}
override Expr getSink(Call c) {
// The uses of the `j`th parameter are the actual sinks
@@ -256,10 +260,10 @@ class CallableFlowSinkDelegateArg extends CallableFlowSink, TCallableFlowSinkDel
override Type getSinkType(Call c) {
result =
c
.getArgument(i)
.getArgument(delegateIndex)
.(DelegateArgumentToLibraryCallable)
.getDelegateType()
.getParameter(j)
.getParameter(parameterIndex)
.getType()
}
}

View File

@@ -860,25 +860,29 @@ private module ArgumentNodes {
*/
class ImplicitDelegateArgumentNode extends ArgumentNode, TImplicitDelegateArgumentNode {
private ControlFlow::Node cfn;
private int i;
private int j;
private int delegateIndex;
private int parameterIndex;
ImplicitDelegateArgumentNode() { this = TImplicitDelegateArgumentNode(cfn, i, j) }
ImplicitDelegateArgumentNode() {
this = TImplicitDelegateArgumentNode(cfn, delegateIndex, parameterIndex)
}
private ImplicitDelegateDataFlowCall getDelegateCall() { result.getControlFlowNode() = cfn }
override predicate argumentOf(DataFlowCall call, int pos) {
call = this.getDelegateCall() and
pos = j
pos = parameterIndex
}
override Callable getEnclosingCallable() { result = cfn.getEnclosingCallable() }
override Type getType() { result = this.getDelegateCall().getDelegateParameterType(j) }
override Type getType() {
result = this.getDelegateCall().getDelegateParameterType(parameterIndex)
}
override Location getLocation() { result = cfn.getLocation() }
override string toString() { result = "[implicit argument " + j + "] " + cfn }
override string toString() { result = "[implicit argument " + parameterIndex + "] " + cfn }
}
}
@@ -1332,8 +1336,8 @@ class LibraryCodeNode extends Node, TLibraryCodeNode {
predicate preservesValue() { preservesValue = true }
/**
* Gets the predecessor of this library-code node. `ap` describes the content
* that is read from when entering this node (if any).
* Gets the predecessor of this library-code node. The head of `ap` describes
* the content that is read from when entering this node (if any).
*/
Node getPredecessor(AccessPath ap) {
ap = sourceAp and
@@ -1352,8 +1356,8 @@ class LibraryCodeNode extends Node, TLibraryCodeNode {
}
/**
* Gets the successor of this library-code node. `ap` describes the content that
* is stored into when leaving this node (if any).
* Gets the successor of this library-code node. The head of `ap` describes
* the content that is stored into when leaving this node (if any).
*/
Node getSuccessor(AccessPath ap) {
ap = sinkAp and

View File

@@ -119,7 +119,7 @@ library class DelegateArgumentToLibraryCallable extends Expr {
Call getCall() { result = call }
/** Gets the index of this delegate argument in the call. */
int getArgumentIndex() { this.getCall().getArgument(result) = this }
int getArgumentIndex() { this = this.getCall().getArgument(result) }
/** Gets the delegate type of this argument. */
DelegateType getDelegateType() { result = dt }

View File

@@ -1683,7 +1683,7 @@ callableFlow
| System.Web.HttpUtility.HtmlEncode(string) | argument 0 -> return | false |
| System.Web.HttpUtility.UrlEncode(string) | argument 0 -> return | false |
| System.Web.UI.WebControls.TextBox.get_Text() | qualifier -> return | false |
callableFlowAp
callableFlowAccessPath
| System.Lazy<>.Lazy(Func<T>) | output from argument 0 [<empty>] -> return [Value] |
| System.Lazy<>.Lazy(Func<T>, LazyThreadSafetyMode) | output from argument 0 [<empty>] -> return [Value] |
| System.Lazy<>.Lazy(Func<T>, bool) | output from argument 0 [<empty>] -> return [Value] |

View File

@@ -13,7 +13,7 @@ query predicate callableFlow(string callable, string flow, boolean preservesValu
)
}
query predicate callableFlowAp(string callable, string flow) {
query predicate callableFlowAccessPath(string callable, string flow) {
exists(
LibraryTypeDataFlow x, CallableFlowSource source, AccessPath sourceAp, CallableFlowSink sink,
AccessPath sinkAp, Callable c