|
2 | 2 | * This library is a clone of semmle.code.cpp.controlflow.SSA, with |
3 | 3 | * only one difference: extra phi definitions are added after |
4 | 4 | * guards. For example: |
5 | | - * |
| 5 | + * ``` |
6 | 6 | * x = f(); |
7 | 7 | * if (x < 10) { |
8 | 8 | * // Block 1 |
|
11 | 11 | * // Block 2 |
12 | 12 | * ... |
13 | 13 | * } |
14 | | - * |
| 14 | + * ``` |
15 | 15 | * In standard SSA, basic blocks 1 and 2 do not need phi definitions |
16 | | - * for x, because they are dominated by the definition of x on the |
17 | | - * first line. In RangeSSA, however, we add phi definitions for x at |
| 16 | + * for `x`, because they are dominated by the definition of `x` on the |
| 17 | + * first line. In RangeSSA, however, we add phi definitions for `x` at |
18 | 18 | * the beginning of blocks 1 and 2. This is useful for range analysis |
19 | | - * because it enables us to deduce a more accurate range for x in the |
| 19 | + * because it enables us to deduce a more accurate range for `x` in the |
20 | 20 | * two branches of the if-statement. |
21 | 21 | */ |
22 | 22 |
|
@@ -74,19 +74,19 @@ class RangeSsaDefinition extends ControlFlowNodeBase { |
74 | 74 |
|
75 | 75 | /** |
76 | 76 | * A string representation of the SSA variable represented by the pair |
77 | | - * (this, v). |
| 77 | + * `(this, v)`. |
78 | 78 | */ |
79 | 79 | string toString(LocalScopeVariable v) { exists(RangeSSA x | result = x.toString(this, v)) } |
80 | 80 |
|
81 | | - /** Gets a use of the SSA variable represented by the pair (this, v) */ |
| 81 | + /** Gets a use of the SSA variable represented by the pair `(this, v)`. */ |
82 | 82 | VariableAccess getAUse(LocalScopeVariable v) { exists(RangeSSA x | result = x.getAUse(this, v)) } |
83 | 83 |
|
84 | | - /** Gets the control flow node for this definition */ |
| 84 | + /** Gets the control flow node for this definition. */ |
85 | 85 | ControlFlowNode getDefinition() { result = this } |
86 | 86 |
|
87 | 87 | BasicBlock getBasicBlock() { result.contains(getDefinition()) } |
88 | 88 |
|
89 | | - /** Whether this definition is a phi node for variable v */ |
| 89 | + /** Whether this definition is a phi node for variable `v`. */ |
90 | 90 | predicate isPhiNode(LocalScopeVariable v) { |
91 | 91 | exists(RangeSSA x | x.phi_node(v, this.(BasicBlock))) |
92 | 92 | } |
@@ -136,7 +136,7 @@ class RangeSsaDefinition extends ControlFlowNodeBase { |
136 | 136 | ) |
137 | 137 | } |
138 | 138 |
|
139 | | - /** Gets the expression assigned to this SsaDefinition */ |
| 139 | + /** Gets the expression assigned to this SsaDefinition. */ |
140 | 140 | Expr getDefiningValue(LocalScopeVariable v) { |
141 | 141 | exists(ControlFlowNode def | def = this.getDefinition() | |
142 | 142 | def = v.getInitializer().getExpr() and def = result |
|
0 commit comments