Skip to content

Commit b71b43a

Browse files
authored
Merge pull request #15705 from geoffw0/qldoc3
Shared: Fill some QLDoc holes
2 parents 67612e6 + 0edfafe commit b71b43a

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

shared/dataflow/codeql/dataflow/DataFlow.qll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
/** Provides language-specific data flow parameters. */
88
signature module InputSig {
9+
/**
10+
* A node in the data flow graph.
11+
*/
912
class Node {
1013
/** Gets a textual representation of this element. */
1114
string toString();
@@ -30,9 +33,27 @@ signature module InputSig {
3033
ReturnKind getKind();
3134
}
3235

36+
/**
37+
* A node in the data flow graph that represents an output of a call.
38+
*/
3339
class OutNode extends Node;
3440

41+
/**
42+
* A node in the data flow graph representing the value of some other node
43+
* after an operation that might have changed its state. A typical example is
44+
* an argument, which may have been modified by the callee. For example,
45+
* consider the following code calling a setter method:
46+
* ```
47+
* x.setFoo(y);
48+
* ```
49+
* The post-update node for the argument node `x` is the node representing the
50+
* value of `x` after the field `foo` has been updated.
51+
*/
3552
class PostUpdateNode extends Node {
53+
/**
54+
* Gets the pre-update node, that is, the node that represents the same
55+
* value prior to the operation.
56+
*/
3657
Node getPreUpdateNode();
3758
}
3859

@@ -131,6 +152,12 @@ signature module InputSig {
131152
string toString();
132153
}
133154

155+
/**
156+
* Holds if access paths with `c` at their head always should be tracked at
157+
* high precision. This disables adaptive access path precision for such
158+
* access paths. This may be beneficial for content that indicates an
159+
* element of an array or container.
160+
*/
134161
predicate forceHighPrecision(Content c);
135162

136163
/**
@@ -150,11 +177,19 @@ signature module InputSig {
150177
Content getAReadContent();
151178
}
152179

180+
/**
181+
* A content approximation. A content approximation corresponds to one or
182+
* more `Content`s, and is used to provide an in-between level of precision
183+
* for pruning.
184+
*/
153185
class ContentApprox {
154186
/** Gets a textual representation of this element. */
155187
string toString();
156188
}
157189

190+
/**
191+
* Gets the content approximation for content `c`.
192+
*/
158193
ContentApprox getContentApprox(Content c);
159194

160195
class ParameterPosition {
@@ -169,8 +204,16 @@ signature module InputSig {
169204
string toString();
170205
}
171206

207+
/**
208+
* Holds if the parameter position `ppos` matches the argument position
209+
* `apos`.
210+
*/
172211
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos);
173212

213+
/**
214+
* Holds if there is a simple local flow step from `node1` to `node2`. These
215+
* are the value-preserving intra-callable flow steps.
216+
*/
174217
predicate simpleLocalFlowStep(Node node1, Node node2);
175218

176219
/**

shared/rangeanalysis/codeql/rangeanalysis/RangeAnalysis.qll

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,62 @@ signature module Semantic {
160160
/** Gets a tiebreaker id in case `getBlockId1` is not unique. */
161161
default string getBlockId2(BasicBlock bb) { result = "" }
162162

163+
/**
164+
* A guard in the range analysis.
165+
*/
163166
class Guard {
167+
/**
168+
* Gets a string representation of the guard.
169+
*/
164170
string toString();
165171

172+
/**
173+
* Gets the basic block associated with the guard.
174+
*/
166175
BasicBlock getBasicBlock();
167176

177+
/**
178+
* Gets the guard as an expression, if any.
179+
*/
168180
Expr asExpr();
169181

182+
/**
183+
* Holds if the guard directly controls a given basic block. For example in
184+
* the following code, the guard `(x > y)` directly controls the block
185+
* beneath it:
186+
* ```
187+
* if (x > y)
188+
* {
189+
* Console.WriteLine("x is greater than y");
190+
* }
191+
* ```
192+
* `branch` indicates whether the basic block is entered when the guard
193+
* evaluates to `true` or when it evaluates to `false`.
194+
*/
170195
predicate directlyControls(BasicBlock controlled, boolean branch);
171196

197+
/**
198+
* Holds if this guard is an equality test between `e1` and `e2`. If the
199+
* test is negated, that is `!=`, then `polarity` is false, otherwise
200+
* `polarity` is true.
201+
*/
172202
predicate isEquality(Expr e1, Expr e2, boolean polarity);
173203

204+
/**
205+
* Holds if there is a branch edge between two basic blocks. For example
206+
* in the following C code, there are two branch edges from the basic block
207+
* containing the condition `(x > y)` to the beginnings of the true and
208+
* false blocks that follow:
209+
* ```
210+
* if (x > y) {
211+
* printf("x is greater than y\n");
212+
* } else {
213+
* printf("x is not greater than y\n");
214+
* }
215+
* ```
216+
* `branch` indicates whether the second basic block is the one entered
217+
* when the guard evaluates to `true` or when it evaluates to `false`.
218+
*/
174219
predicate hasBranchEdge(BasicBlock bb1, BasicBlock bb2, boolean branch);
175220
}
176221

@@ -194,18 +239,50 @@ signature module Semantic {
194239
/** Gets the type of an expression. */
195240
Type getExprType(Expr e);
196241

242+
/**
243+
* A static single-assignment (SSA) variable.
244+
*/
197245
class SsaVariable {
246+
/**
247+
* Gets an expression reading the value of this SSA variable.
248+
*/
198249
Expr getAUse();
199250

251+
/**
252+
* Gets the basic block where this SSA variable is defined.
253+
*/
200254
BasicBlock getBasicBlock();
201255
}
202256

257+
/**
258+
* A phi node in the SSA form. A phi node is a kind of node in the SSA form
259+
* that represents a merge point where multiple control flow paths converge
260+
* and the value of a variable needs to be selected according to which
261+
* control flow path was taken. For example, in the following Ruby code:
262+
* ```rb
263+
* if b
264+
* x = 0
265+
* else
266+
* x = 1
267+
* end
268+
* puts x
269+
* ```
270+
* A phi node for `x` is inserted just before the call `puts x`, since the
271+
* value of `x` may come from either `x = 0` or `x = 1`.
272+
*/
203273
class SsaPhiNode extends SsaVariable {
204274
/** Holds if `inp` is an input to the phi node along the edge originating in `bb`. */
205275
predicate hasInputFromBlock(SsaVariable inp, BasicBlock bb);
206276
}
207277

278+
/**
279+
* An SSA variable representing the value of an explicit update of the source variable.
280+
*/
208281
class SsaExplicitUpdate extends SsaVariable {
282+
/**
283+
* Gets the expression that defines the value of the variable in this
284+
* update.
285+
*/
209286
Expr getDefiningExpr();
210287
}
211288

@@ -296,11 +373,32 @@ signature module LangSig<Semantic Sem, DeltaSig D> {
296373
}
297374

298375
signature module BoundSig<LocationSig Location, Semantic Sem, DeltaSig D> {
376+
/**
377+
* A bound that the range analysis can infer for a variable. This includes
378+
* constant bounds represented by the abstract value zero, SSA bounds for when
379+
* a variable is bounded by the value of a different variable, and possibly
380+
* other abstract values that may be useful variable bounds. Since all bounds
381+
* are combined with an integer delta there's no need to represent constant
382+
* bounds other than zero.
383+
*/
299384
class SemBound {
385+
/**
386+
* Gets a string representation of this bound.
387+
*/
300388
string toString();
301389

390+
/**
391+
* Gets the location of this bound.
392+
*/
302393
Location getLocation();
303394

395+
/**
396+
* Gets an expression that equals this bound plus `delta`.
397+
*
398+
* For the zero-bound this gets integer constants equal to `delta`, for any
399+
* value `delta`. For other bounds this gets expressions equal to the bound
400+
* and `delta = 0`.
401+
*/
304402
Sem::Expr getExpr(D::Delta delta);
305403
}
306404

0 commit comments

Comments
 (0)