Skip to content

Commit a204b7f

Browse files
authored
Merge pull request github#6866 from github/ginsbach/MoreInstanceofExtensions
more instanceof extensions
2 parents c215838 + c9c0c7f commit a204b7f

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,13 @@ class DataFlowExpr = Expr;
219219
class DataFlowType = Type;
220220

221221
/** A function call relevant for data flow. */
222-
class DataFlowCall extends Expr {
223-
DataFlowCall() { this instanceof Call }
224-
222+
class DataFlowCall extends Expr instanceof Call {
225223
/**
226224
* Gets the nth argument for this call.
227225
*
228226
* The range of `n` is from `0` to `getNumberOfArguments() - 1`.
229227
*/
230-
Expr getArgument(int n) { result = this.(Call).getArgument(n) }
228+
Expr getArgument(int n) { result = super.getArgument(n) }
231229

232230
/** Gets the data flow node corresponding to this call. */
233231
ExprNode getNode() { result.getExpr() = this }

cpp/ql/src/AlertSuppression.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ class SuppressionComment extends Comment {
6060
/**
6161
* The scope of an alert suppression comment.
6262
*/
63-
class SuppressionScope extends ElementBase {
64-
SuppressionScope() { this instanceof SuppressionComment }
65-
63+
class SuppressionScope extends ElementBase instanceof SuppressionComment {
6664
/**
6765
* Holds if this element is at the specified location.
6866
* The location spans column `startcolumn` of line `startline` to
@@ -73,7 +71,7 @@ class SuppressionScope extends ElementBase {
7371
predicate hasLocationInfo(
7472
string filepath, int startline, int startcolumn, int endline, int endcolumn
7573
) {
76-
this.(SuppressionComment).covers(filepath, startline, startcolumn, endline, endcolumn)
74+
super.covers(filepath, startline, startcolumn, endline, endcolumn)
7775
}
7876
}
7977

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,9 @@ private module ParameterNodes {
940940
import ParameterNodes
941941

942942
/** A data-flow node that represents a call argument. */
943-
class ArgumentNode extends Node {
944-
ArgumentNode() { this instanceof ArgumentNodeImpl }
945-
943+
class ArgumentNode extends Node instanceof ArgumentNodeImpl {
946944
/** Holds if this argument occurs at the given position in the given call. */
947-
final predicate argumentOf(DataFlowCall call, int pos) {
948-
this.(ArgumentNodeImpl).argumentOf(call, pos)
949-
}
945+
final predicate argumentOf(DataFlowCall call, int pos) { super.argumentOf(call, pos) }
950946
}
951947

952948
abstract private class ArgumentNodeImpl extends Node {

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ class ExprNode extends Node, TExprNode_ {
9898
* The value of a parameter at function entry, viewed as a node in a data
9999
* flow graph.
100100
*/
101-
class ParameterNode extends Node {
102-
ParameterNode() { this instanceof ParameterNodeImpl }
103-
101+
class ParameterNode extends Node instanceof ParameterNodeImpl {
104102
/** Gets the parameter corresponding to this node, if any. */
105103
DotNet::Parameter getParameter() {
106104
exists(DataFlowCallable c, int i | this.isParameterOf(c, i) and result = c.getParameter(i))
@@ -110,9 +108,7 @@ class ParameterNode extends Node {
110108
* Holds if this node is the parameter of callable `c` at the specified
111109
* (zero-based) position.
112110
*/
113-
predicate isParameterOf(DataFlowCallable c, int i) {
114-
this.(ParameterNodeImpl).isParameterOf(c, i)
115-
}
111+
predicate isParameterOf(DataFlowCallable c, int i) { super.isParameterOf(c, i) }
116112
}
117113

118114
/** A definition, viewed as a node in a data flow graph. */

csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,12 @@ private module Impl {
8989
}
9090

9191
/** An expression whose value may control the execution of another element. */
92-
class Guard extends Expr {
93-
Guard() { this instanceof G::Guard }
94-
92+
class Guard extends Expr instanceof G::Guard {
9593
/**
9694
* Holds if basic block `bb` is guarded by this guard having value `v`.
9795
*/
9896
predicate controlsBasicBlock(ControlFlow::BasicBlock bb, G::AbstractValue v) {
99-
this.(G::Guard).controlsBasicBlock(bb, v)
97+
super.controlsBasicBlock(bb, v)
10098
}
10199

102100
/**
@@ -108,7 +106,7 @@ private module Impl {
108106
exists(Expr e1_, Expr e2_ |
109107
e1 = unique(ExprNode cfn | hasChild(this, e1_, _, cfn) | cfn) and
110108
e2 = unique(ExprNode cfn | hasChild(this, e2_, _, cfn) | cfn) and
111-
this.(G::Guard).isEquality(e1_, e2_, polarity)
109+
super.isEquality(e1_, e2_, polarity)
112110
)
113111
}
114112
}

0 commit comments

Comments
 (0)