Skip to content

Commit 732da9c

Browse files
authored
Merge pull request github#3586 from MathiasVP/qldoc-for-remaining-controlflow
C++: QLDoc for the remaining elements in the controlflow directory
2 parents 0d8472b + 5fb79cd commit 732da9c

File tree

10 files changed

+52
-2
lines changed

10 files changed

+52
-2
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/DefinitionsAndUses.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides classes and predicates for reasoning about definitions and uses of variables.
3+
*/
4+
15
import cpp
26
private import semmle.code.cpp.controlflow.StackVariableReachability
37
private import semmle.code.cpp.dataflow.EscapesTree
@@ -135,6 +139,7 @@ library class DefOrUse extends ControlFlowNodeBase {
135139
}
136140
}
137141

142+
/** A definition of a stack variable. */
138143
library class Def extends DefOrUse {
139144
Def() { definition(_, this) }
140145

@@ -149,6 +154,7 @@ private predicate parameterIsOverwritten(Function f, Parameter p) {
149154
definitionBarrier(p, _)
150155
}
151156

157+
/** A definition of a parameter. */
152158
library class ParameterDef extends DefOrUse {
153159
ParameterDef() {
154160
// Optimization: parameters that are not overwritten do not require
@@ -162,6 +168,7 @@ library class ParameterDef extends DefOrUse {
162168
}
163169
}
164170

171+
/** A use of a stack variable. */
165172
library class Use extends DefOrUse {
166173
Use() { useOfVar(_, this) }
167174

cpp/ql/src/semmle/code/cpp/controlflow/Dereferenced.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides predicates for detecting whether an expression dereferences a pointer.
3+
*/
4+
15
import cpp
26
import Nullness
37

cpp/ql/src/semmle/code/cpp/controlflow/Guards.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides classes and predicates for reasoning about guards and the control
3+
* flow elements controlled by those guards.
4+
*/
5+
16
import cpp
27
import semmle.code.cpp.controlflow.BasicBlocks
38
import semmle.code.cpp.controlflow.SSA

cpp/ql/src/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides classes and predicates for reasoning about guards and the control
3+
* flow elements controlled by those guards.
4+
*/
5+
16
import cpp
27
import semmle.code.cpp.ir.IR
38

@@ -32,7 +37,7 @@ class GuardCondition extends Expr {
3237
}
3338

3439
/**
35-
* Holds if this condition controls `block`, meaning that `block` is only
40+
* Holds if this condition controls `controlled`, meaning that `controlled` is only
3641
* entered if the value of this condition is `testIsTrue`.
3742
*
3843
* Illustration:
@@ -253,7 +258,7 @@ class IRGuardCondition extends Instruction {
253258
IRGuardCondition() { branch = get_branch_for_condition(this) }
254259

255260
/**
256-
* Holds if this condition controls `block`, meaning that `block` is only
261+
* Holds if this condition controls `controlled`, meaning that `controlled` is only
257262
* entered if the value of this condition is `testIsTrue`.
258263
*
259264
* Illustration:
@@ -290,6 +295,10 @@ class IRGuardCondition extends Instruction {
290295
)
291296
}
292297

298+
/**
299+
* Holds if the control-flow edge `(pred, succ)` may be taken only if
300+
* the value of this condition is `testIsTrue`.
301+
*/
293302
cached
294303
predicate controlsEdge(IRBlock pred, IRBlock succ, boolean testIsTrue) {
295304
pred.getASuccessor() = succ and

cpp/ql/src/semmle/code/cpp/controlflow/Nullness.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides classes and predicates for working with null values and checks for nullness.
3+
*/
4+
15
import cpp
26
import DefinitionsAndUses
37

cpp/ql/src/semmle/code/cpp/controlflow/SSA.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
/**
2+
* Provides classes and predicates for SSA representation (Static Single Assignment form).
3+
*/
4+
15
import cpp
26
import semmle.code.cpp.controlflow.Dominance
37
import SSAUtils
48

9+
/**
10+
* The SSA logic comes in two versions: the standard SSA and range-analysis RangeSSA.
11+
* This class provides the standard SSA logic.
12+
*/
513
library class StandardSSA extends SSAHelper {
614
StandardSSA() { this = 0 }
715
}
@@ -50,11 +58,13 @@ class SsaDefinition extends ControlFlowNodeBase {
5058
*/
5159
ControlFlowNode getDefinition() { result = this }
5260

61+
/** Gets the `BasicBlock` containing this definition. */
5362
BasicBlock getBasicBlock() { result.contains(getDefinition()) }
5463

5564
/** Holds if this definition is a phi node for variable `v`. */
5665
predicate isPhiNode(StackVariable v) { exists(StandardSSA x | x.phi_node(v, this.(BasicBlock))) }
5766

67+
/** Gets the location of this definition. */
5868
Location getLocation() { result = this.(ControlFlowNode).getLocation() }
5969

6070
/** Holds if the SSA variable `(this, p)` is defined by parameter `p`. */

cpp/ql/src/semmle/code/cpp/controlflow/SSAUtils.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* Provides classes and predicates for use in the SSA library.
3+
*/
4+
15
import cpp
26
import semmle.code.cpp.controlflow.Dominance
37
import semmle.code.cpp.controlflow.SSA // must be imported for proper caching of SSAHelper

cpp/ql/src/semmle/code/cpp/controlflow/StackVariableReachability.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Provides a library for working with local (intra-procedural) control-flow
3+
* reachability involving stack variables.
4+
*/
5+
16
import cpp
27

38
/**

cpp/ql/src/semmle/code/cpp/controlflow/SubBasicBlocks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
168168
/** Gets the first control-flow node in this `SubBasicBlock`. */
169169
ControlFlowNode getStart() { result = this }
170170

171+
/** Gets the function that contains this `SubBasicBlock`. */
171172
pragma[noinline]
172173
Function getEnclosingFunction() { result = this.getStart().getControlFlowScope() }
173174
}

cpp/ql/src/semmle/code/cpp/dataflow/internal/SubBasicBlocks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class SubBasicBlock extends ControlFlowNodeBase {
168168
/** Gets the first control-flow node in this `SubBasicBlock`. */
169169
ControlFlowNode getStart() { result = this }
170170

171+
/** Gets the function that contains this `SubBasicBlock`. */
171172
pragma[noinline]
172173
Function getEnclosingFunction() { result = this.getStart().getControlFlowScope() }
173174
}

0 commit comments

Comments
 (0)