Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a6a225

Browse files
committed
C++: Respond to more review comments.
- Remove post-dominance requirement. It was really just hiding good results. - Fix test annotations. Turns out Clang and GCC's 'undefined behavior' warning didn't align with the C++ standard.
1 parent b249777 commit 0a6a225

8 files changed

Lines changed: 64 additions & 246 deletions

File tree

cpp/ql/src/Likely Bugs/OO/UnsafeUseOfThis.ql

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,11 @@ predicate flowThroughCallable(Instruction instr, Instruction succ) {
169169

170170
/** Holds if `instr` flows to `succ`. */
171171
predicate successor(Instruction instr, Instruction succ) {
172-
succ.getBlock().postDominates(instr.getBlock()) and
173-
(
174-
succ.(CopyInstruction).getSourceValue() = instr or
175-
succ.(CheckedConvertOrNullInstruction).getUnary() = instr or
176-
succ.(ChiInstruction).getTotal() = instr or
177-
succ.(ConvertInstruction).getUnary() = instr or
178-
succ.(InheritanceConversionInstruction).getUnary() = instr
179-
)
180-
or
172+
succ.(CopyInstruction).getSourceValue() = instr or
173+
succ.(CheckedConvertOrNullInstruction).getUnary() = instr or
174+
succ.(ChiInstruction).getTotal() = instr or
175+
succ.(ConvertInstruction).getUnary() = instr or
176+
succ.(InheritanceConversionInstruction).getUnary() = instr or
181177
flowThroughCallable(instr, succ)
182178
}
183179

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,6 @@ class IRBlock extends IRBlockBase {
151151
*/
152152
final predicate dominates(IRBlock block) { strictlyDominates(block) or this = block }
153153

154-
/**
155-
* Holds if this block immediately post-dominates `block`.
156-
*
157-
* Block `A` immediate post-dominates block `B` if block `A` strictly post-dominates block `B` and
158-
* block `B` is a direct successor of block `A`.
159-
*/
160-
final predicate immediatelyPostDominates(IRBlock block) {
161-
blockImmediatelyPostDominates(this, block)
162-
}
163-
164-
/**
165-
* Holds if this block strictly post-dominates `block`.
166-
*
167-
* Block `A` strictly post-dominates block `B` if block `A` post-dominates block `B` and blocks `A`
168-
* and `B` are not the same block.
169-
*/
170-
private predicate strictlyPostDominates(IRBlock block) {
171-
blockImmediatelyPostDominates+(this, block)
172-
}
173-
174-
/**
175-
* Holds if this block is a post-dominator of `block`.
176-
*
177-
* Block `A` post-dominates block `B` if any control flow path from `B` to the exit block of the
178-
* function must pass through block `A`. A block always post-dominates itself.
179-
*/
180-
predicate postDominates(IRBlock block) { strictlyPostDominates(block) or this = block }
181-
182154
/**
183155
* Gets a block on the dominance frontier of this block.
184156
*
@@ -308,12 +280,3 @@ private module Cached {
308280
}
309281

310282
private Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }
311-
312-
private predicate blockFunctionExit(IRBlock exit) {
313-
exit.getLastInstruction() instanceof ExitFunctionInstruction
314-
}
315-
316-
private predicate blockPredecessor(IRBlock src, IRBlock pred) { src.getAPredecessor() = pred }
317-
318-
private predicate blockImmediatelyPostDominates(IRBlock postDominator, IRBlock block) =
319-
idominance(blockFunctionExit/1, blockPredecessor/2)(_, postDominator, block)

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRBlock.qll

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,6 @@ class IRBlock extends IRBlockBase {
151151
*/
152152
final predicate dominates(IRBlock block) { strictlyDominates(block) or this = block }
153153

154-
/**
155-
* Holds if this block immediately post-dominates `block`.
156-
*
157-
* Block `A` immediate post-dominates block `B` if block `A` strictly post-dominates block `B` and
158-
* block `B` is a direct successor of block `A`.
159-
*/
160-
final predicate immediatelyPostDominates(IRBlock block) {
161-
blockImmediatelyPostDominates(this, block)
162-
}
163-
164-
/**
165-
* Holds if this block strictly post-dominates `block`.
166-
*
167-
* Block `A` strictly post-dominates block `B` if block `A` post-dominates block `B` and blocks `A`
168-
* and `B` are not the same block.
169-
*/
170-
private predicate strictlyPostDominates(IRBlock block) {
171-
blockImmediatelyPostDominates+(this, block)
172-
}
173-
174-
/**
175-
* Holds if this block is a post-dominator of `block`.
176-
*
177-
* Block `A` post-dominates block `B` if any control flow path from `B` to the exit block of the
178-
* function must pass through block `A`. A block always post-dominates itself.
179-
*/
180-
predicate postDominates(IRBlock block) { strictlyPostDominates(block) or this = block }
181-
182154
/**
183155
* Gets a block on the dominance frontier of this block.
184156
*
@@ -308,12 +280,3 @@ private module Cached {
308280
}
309281

310282
private Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }
311-
312-
private predicate blockFunctionExit(IRBlock exit) {
313-
exit.getLastInstruction() instanceof ExitFunctionInstruction
314-
}
315-
316-
private predicate blockPredecessor(IRBlock src, IRBlock pred) { src.getAPredecessor() = pred }
317-
318-
private predicate blockImmediatelyPostDominates(IRBlock postDominator, IRBlock block) =
319-
idominance(blockFunctionExit/1, blockPredecessor/2)(_, postDominator, block)

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRBlock.qll

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,6 @@ class IRBlock extends IRBlockBase {
151151
*/
152152
final predicate dominates(IRBlock block) { strictlyDominates(block) or this = block }
153153

154-
/**
155-
* Holds if this block immediately post-dominates `block`.
156-
*
157-
* Block `A` immediate post-dominates block `B` if block `A` strictly post-dominates block `B` and
158-
* block `B` is a direct successor of block `A`.
159-
*/
160-
final predicate immediatelyPostDominates(IRBlock block) {
161-
blockImmediatelyPostDominates(this, block)
162-
}
163-
164-
/**
165-
* Holds if this block strictly post-dominates `block`.
166-
*
167-
* Block `A` strictly post-dominates block `B` if block `A` post-dominates block `B` and blocks `A`
168-
* and `B` are not the same block.
169-
*/
170-
private predicate strictlyPostDominates(IRBlock block) {
171-
blockImmediatelyPostDominates+(this, block)
172-
}
173-
174-
/**
175-
* Holds if this block is a post-dominator of `block`.
176-
*
177-
* Block `A` post-dominates block `B` if any control flow path from `B` to the exit block of the
178-
* function must pass through block `A`. A block always post-dominates itself.
179-
*/
180-
predicate postDominates(IRBlock block) { strictlyPostDominates(block) or this = block }
181-
182154
/**
183155
* Gets a block on the dominance frontier of this block.
184156
*
@@ -308,12 +280,3 @@ private module Cached {
308280
}
309281

310282
private Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }
311-
312-
private predicate blockFunctionExit(IRBlock exit) {
313-
exit.getLastInstruction() instanceof ExitFunctionInstruction
314-
}
315-
316-
private predicate blockPredecessor(IRBlock src, IRBlock pred) { src.getAPredecessor() = pred }
317-
318-
private predicate blockImmediatelyPostDominates(IRBlock postDominator, IRBlock block) =
319-
idominance(blockFunctionExit/1, blockPredecessor/2)(_, postDominator, block)
Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,62 @@
11
edges
2-
| test.cpp:7:2:7:2 | InitializeParameter: B | test.cpp:8:10:8:13 | Load: this |
3-
| test.cpp:8:10:8:13 | Load: this | test.cpp:34:16:34:16 | InitializeParameter: x |
4-
| test.cpp:11:10:11:10 | InitializeParameter: b | test.cpp:12:9:12:9 | Load: b |
5-
| test.cpp:12:9:12:9 | CopyValue: (reference dereference) | test.cpp:12:9:12:9 | ConvertToNonVirtualBase: (A)... |
6-
| test.cpp:12:9:12:9 | Load: b | test.cpp:12:9:12:9 | CopyValue: (reference dereference) |
7-
| test.cpp:15:2:15:3 | InitializeParameter: ~B | test.cpp:16:3:16:3 | Load: this |
8-
| test.cpp:16:3:16:3 | Load: this | file://:0:0:0:0 | ConvertToNonVirtualBase: (A *)... |
9-
| test.cpp:21:2:21:2 | InitializeParameter: C | test.cpp:21:12:21:12 | ConvertToNonVirtualBase: call to B |
10-
| test.cpp:21:2:21:2 | InitializeParameter: C | test.cpp:22:10:22:13 | Load: this |
11-
| test.cpp:21:12:21:12 | ConvertToNonVirtualBase: call to B | test.cpp:7:2:7:2 | InitializeParameter: B |
12-
| test.cpp:22:10:22:13 | ConvertToNonVirtualBase: (B *)... | test.cpp:34:16:34:16 | InitializeParameter: x |
13-
| test.cpp:22:10:22:13 | Load: this | test.cpp:22:10:22:13 | ConvertToNonVirtualBase: (B *)... |
14-
| test.cpp:31:5:31:5 | InitializeParameter: D | test.cpp:31:14:31:17 | Load: this |
15-
| test.cpp:31:13:31:17 | ConvertToNonVirtualBase: (B)... | test.cpp:31:13:31:17 | CopyValue: (reference to) |
16-
| test.cpp:31:13:31:17 | CopyValue: (reference to) | test.cpp:11:10:11:10 | InitializeParameter: b |
17-
| test.cpp:31:13:31:17 | CopyValue: * ... | test.cpp:31:13:31:17 | ConvertToNonVirtualBase: (B)... |
18-
| test.cpp:31:14:31:17 | Load: this | test.cpp:31:13:31:17 | CopyValue: * ... |
19-
| test.cpp:34:16:34:16 | InitializeParameter: x | test.cpp:35:2:35:2 | Load: x |
20-
| test.cpp:35:2:35:2 | Load: x | test.cpp:35:2:35:2 | ConvertToNonVirtualBase: (A *)... |
21-
| test.cpp:47:2:47:2 | InitializeParameter: F | test.cpp:48:8:48:11 | Load: this |
22-
| test.cpp:48:8:48:11 | ConvertToNonVirtualBase: (E *)... | test.cpp:48:4:48:11 | ConvertToNonVirtualBase: (A *)... |
23-
| test.cpp:48:8:48:11 | Load: this | test.cpp:48:8:48:11 | ConvertToNonVirtualBase: (E *)... |
2+
| test.cpp:7:3:7:3 | InitializeParameter: B | test.cpp:8:12:8:15 | Load: this |
3+
| test.cpp:8:12:8:15 | Load: this | test.cpp:34:16:34:16 | InitializeParameter: x |
4+
| test.cpp:11:8:11:8 | InitializeParameter: b | test.cpp:12:5:12:5 | Load: b |
5+
| test.cpp:12:5:12:5 | CopyValue: (reference dereference) | test.cpp:12:5:12:5 | ConvertToNonVirtualBase: (A)... |
6+
| test.cpp:12:5:12:5 | Load: b | test.cpp:12:5:12:5 | CopyValue: (reference dereference) |
7+
| test.cpp:15:3:15:4 | InitializeParameter: ~B | test.cpp:16:5:16:5 | Load: this |
8+
| test.cpp:16:5:16:5 | Load: this | file://:0:0:0:0 | ConvertToNonVirtualBase: (A *)... |
9+
| test.cpp:21:3:21:3 | InitializeParameter: C | test.cpp:21:13:21:13 | ConvertToNonVirtualBase: call to B |
10+
| test.cpp:21:3:21:3 | InitializeParameter: C | test.cpp:22:12:22:15 | Load: this |
11+
| test.cpp:21:3:21:3 | InitializeParameter: C | test.cpp:25:7:25:10 | Load: this |
12+
| test.cpp:21:13:21:13 | ConvertToNonVirtualBase: call to B | test.cpp:7:3:7:3 | InitializeParameter: B |
13+
| test.cpp:22:12:22:15 | ConvertToNonVirtualBase: (B *)... | test.cpp:34:16:34:16 | InitializeParameter: x |
14+
| test.cpp:22:12:22:15 | Load: this | test.cpp:22:12:22:15 | ConvertToNonVirtualBase: (B *)... |
15+
| test.cpp:25:7:25:10 | ConvertToNonVirtualBase: (B *)... | test.cpp:25:7:25:10 | ConvertToNonVirtualBase: (A *)... |
16+
| test.cpp:25:7:25:10 | Load: this | test.cpp:25:7:25:10 | ConvertToNonVirtualBase: (B *)... |
17+
| test.cpp:31:3:31:3 | InitializeParameter: D | test.cpp:31:12:31:15 | Load: this |
18+
| test.cpp:31:11:31:15 | ConvertToNonVirtualBase: (B)... | test.cpp:31:11:31:15 | CopyValue: (reference to) |
19+
| test.cpp:31:11:31:15 | CopyValue: (reference to) | test.cpp:11:8:11:8 | InitializeParameter: b |
20+
| test.cpp:31:11:31:15 | CopyValue: * ... | test.cpp:31:11:31:15 | ConvertToNonVirtualBase: (B)... |
21+
| test.cpp:31:12:31:15 | Load: this | test.cpp:31:11:31:15 | CopyValue: * ... |
22+
| test.cpp:34:16:34:16 | InitializeParameter: x | test.cpp:35:3:35:3 | Load: x |
23+
| test.cpp:35:3:35:3 | Load: x | test.cpp:35:3:35:3 | ConvertToNonVirtualBase: (A *)... |
24+
| test.cpp:47:3:47:3 | InitializeParameter: F | test.cpp:48:10:48:13 | Load: this |
25+
| test.cpp:48:10:48:13 | ConvertToNonVirtualBase: (E *)... | test.cpp:48:6:48:13 | ConvertToNonVirtualBase: (A *)... |
26+
| test.cpp:48:10:48:13 | Load: this | test.cpp:48:10:48:13 | ConvertToNonVirtualBase: (E *)... |
2427
nodes
2528
| file://:0:0:0:0 | ConvertToNonVirtualBase: (A *)... | semmle.label | ConvertToNonVirtualBase: (A *)... |
26-
| test.cpp:7:2:7:2 | InitializeParameter: B | semmle.label | InitializeParameter: B |
27-
| test.cpp:8:10:8:13 | Load: this | semmle.label | Load: this |
28-
| test.cpp:11:10:11:10 | InitializeParameter: b | semmle.label | InitializeParameter: b |
29-
| test.cpp:12:9:12:9 | ConvertToNonVirtualBase: (A)... | semmle.label | ConvertToNonVirtualBase: (A)... |
30-
| test.cpp:12:9:12:9 | CopyValue: (reference dereference) | semmle.label | CopyValue: (reference dereference) |
31-
| test.cpp:12:9:12:9 | Load: b | semmle.label | Load: b |
32-
| test.cpp:15:2:15:3 | InitializeParameter: ~B | semmle.label | InitializeParameter: ~B |
33-
| test.cpp:16:3:16:3 | Load: this | semmle.label | Load: this |
34-
| test.cpp:21:2:21:2 | InitializeParameter: C | semmle.label | InitializeParameter: C |
35-
| test.cpp:21:12:21:12 | ConvertToNonVirtualBase: call to B | semmle.label | ConvertToNonVirtualBase: call to B |
36-
| test.cpp:22:10:22:13 | ConvertToNonVirtualBase: (B *)... | semmle.label | ConvertToNonVirtualBase: (B *)... |
37-
| test.cpp:22:10:22:13 | Load: this | semmle.label | Load: this |
38-
| test.cpp:31:5:31:5 | InitializeParameter: D | semmle.label | InitializeParameter: D |
39-
| test.cpp:31:13:31:17 | ConvertToNonVirtualBase: (B)... | semmle.label | ConvertToNonVirtualBase: (B)... |
40-
| test.cpp:31:13:31:17 | CopyValue: (reference to) | semmle.label | CopyValue: (reference to) |
41-
| test.cpp:31:13:31:17 | CopyValue: * ... | semmle.label | CopyValue: * ... |
42-
| test.cpp:31:14:31:17 | Load: this | semmle.label | Load: this |
29+
| test.cpp:7:3:7:3 | InitializeParameter: B | semmle.label | InitializeParameter: B |
30+
| test.cpp:8:12:8:15 | Load: this | semmle.label | Load: this |
31+
| test.cpp:11:8:11:8 | InitializeParameter: b | semmle.label | InitializeParameter: b |
32+
| test.cpp:12:5:12:5 | ConvertToNonVirtualBase: (A)... | semmle.label | ConvertToNonVirtualBase: (A)... |
33+
| test.cpp:12:5:12:5 | CopyValue: (reference dereference) | semmle.label | CopyValue: (reference dereference) |
34+
| test.cpp:12:5:12:5 | Load: b | semmle.label | Load: b |
35+
| test.cpp:15:3:15:4 | InitializeParameter: ~B | semmle.label | InitializeParameter: ~B |
36+
| test.cpp:16:5:16:5 | Load: this | semmle.label | Load: this |
37+
| test.cpp:21:3:21:3 | InitializeParameter: C | semmle.label | InitializeParameter: C |
38+
| test.cpp:21:13:21:13 | ConvertToNonVirtualBase: call to B | semmle.label | ConvertToNonVirtualBase: call to B |
39+
| test.cpp:22:12:22:15 | ConvertToNonVirtualBase: (B *)... | semmle.label | ConvertToNonVirtualBase: (B *)... |
40+
| test.cpp:22:12:22:15 | Load: this | semmle.label | Load: this |
41+
| test.cpp:25:7:25:10 | ConvertToNonVirtualBase: (A *)... | semmle.label | ConvertToNonVirtualBase: (A *)... |
42+
| test.cpp:25:7:25:10 | ConvertToNonVirtualBase: (B *)... | semmle.label | ConvertToNonVirtualBase: (B *)... |
43+
| test.cpp:25:7:25:10 | Load: this | semmle.label | Load: this |
44+
| test.cpp:31:3:31:3 | InitializeParameter: D | semmle.label | InitializeParameter: D |
45+
| test.cpp:31:11:31:15 | ConvertToNonVirtualBase: (B)... | semmle.label | ConvertToNonVirtualBase: (B)... |
46+
| test.cpp:31:11:31:15 | CopyValue: (reference to) | semmle.label | CopyValue: (reference to) |
47+
| test.cpp:31:11:31:15 | CopyValue: * ... | semmle.label | CopyValue: * ... |
48+
| test.cpp:31:12:31:15 | Load: this | semmle.label | Load: this |
4349
| test.cpp:34:16:34:16 | InitializeParameter: x | semmle.label | InitializeParameter: x |
44-
| test.cpp:35:2:35:2 | ConvertToNonVirtualBase: (A *)... | semmle.label | ConvertToNonVirtualBase: (A *)... |
45-
| test.cpp:35:2:35:2 | Load: x | semmle.label | Load: x |
46-
| test.cpp:47:2:47:2 | InitializeParameter: F | semmle.label | InitializeParameter: F |
47-
| test.cpp:48:4:48:11 | ConvertToNonVirtualBase: (A *)... | semmle.label | ConvertToNonVirtualBase: (A *)... |
48-
| test.cpp:48:8:48:11 | ConvertToNonVirtualBase: (E *)... | semmle.label | ConvertToNonVirtualBase: (E *)... |
49-
| test.cpp:48:8:48:11 | Load: this | semmle.label | Load: this |
50+
| test.cpp:35:3:35:3 | ConvertToNonVirtualBase: (A *)... | semmle.label | ConvertToNonVirtualBase: (A *)... |
51+
| test.cpp:35:3:35:3 | Load: x | semmle.label | Load: x |
52+
| test.cpp:47:3:47:3 | InitializeParameter: F | semmle.label | InitializeParameter: F |
53+
| test.cpp:48:6:48:13 | ConvertToNonVirtualBase: (A *)... | semmle.label | ConvertToNonVirtualBase: (A *)... |
54+
| test.cpp:48:10:48:13 | ConvertToNonVirtualBase: (E *)... | semmle.label | ConvertToNonVirtualBase: (E *)... |
55+
| test.cpp:48:10:48:13 | Load: this | semmle.label | Load: this |
5056
#select
51-
| test.cpp:12:11:12:11 | call to f | test.cpp:31:5:31:5 | InitializeParameter: D | test.cpp:12:9:12:9 | ConvertToNonVirtualBase: (A)... | Call to pure virtual function during construction |
52-
| test.cpp:16:3:16:3 | call to f | test.cpp:15:2:15:3 | InitializeParameter: ~B | file://:0:0:0:0 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during destruction |
53-
| test.cpp:35:5:35:5 | call to f | test.cpp:7:2:7:2 | InitializeParameter: B | test.cpp:35:2:35:2 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |
54-
| test.cpp:35:5:35:5 | call to f | test.cpp:21:2:21:2 | InitializeParameter: C | test.cpp:35:2:35:2 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |
55-
| test.cpp:48:15:48:15 | call to f | test.cpp:47:2:47:2 | InitializeParameter: F | test.cpp:48:4:48:11 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |
57+
| test.cpp:12:7:12:7 | call to f | test.cpp:31:3:31:3 | InitializeParameter: D | test.cpp:12:5:12:5 | ConvertToNonVirtualBase: (A)... | Call to pure virtual function during construction |
58+
| test.cpp:16:5:16:5 | call to f | test.cpp:15:3:15:4 | InitializeParameter: ~B | file://:0:0:0:0 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during destruction |
59+
| test.cpp:25:13:25:13 | call to f | test.cpp:21:3:21:3 | InitializeParameter: C | test.cpp:25:7:25:10 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |
60+
| test.cpp:35:6:35:6 | call to f | test.cpp:7:3:7:3 | InitializeParameter: B | test.cpp:35:3:35:3 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |
61+
| test.cpp:35:6:35:6 | call to f | test.cpp:21:3:21:3 | InitializeParameter: C | test.cpp:35:3:35:3 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |
62+
| test.cpp:48:17:48:17 | call to f | test.cpp:47:3:47:3 | InitializeParameter: F | test.cpp:48:6:48:13 | ConvertToNonVirtualBase: (A *)... | Call to pure virtual function during construction |

cpp/ql/test/query-tests/Critical/UnsafeUseOfThis/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct C : public B {
2222
call_f(this);
2323

2424
if(b) {
25-
this->f(); // GOOD: Not a 'must' flow
25+
this->f(); // BAD: undefined behavior
2626
}
2727
}
2828
};
@@ -45,6 +45,6 @@ struct E : public A {
4545

4646
struct F : public E {
4747
F() {
48-
((A*)this)->f(); // BAD: undefined behavior
48+
((A*)this)->f(); // GOOD: Will call `E::f` [FALSE POSITIVE]
4949
}
5050
};

csharp/ql/src/experimental/ir/implementation/raw/IRBlock.qll

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,6 @@ class IRBlock extends IRBlockBase {
151151
*/
152152
final predicate dominates(IRBlock block) { strictlyDominates(block) or this = block }
153153

154-
/**
155-
* Holds if this block immediately post-dominates `block`.
156-
*
157-
* Block `A` immediate post-dominates block `B` if block `A` strictly post-dominates block `B` and
158-
* block `B` is a direct successor of block `A`.
159-
*/
160-
final predicate immediatelyPostDominates(IRBlock block) {
161-
blockImmediatelyPostDominates(this, block)
162-
}
163-
164-
/**
165-
* Holds if this block strictly post-dominates `block`.
166-
*
167-
* Block `A` strictly post-dominates block `B` if block `A` post-dominates block `B` and blocks `A`
168-
* and `B` are not the same block.
169-
*/
170-
private predicate strictlyPostDominates(IRBlock block) {
171-
blockImmediatelyPostDominates+(this, block)
172-
}
173-
174-
/**
175-
* Holds if this block is a post-dominator of `block`.
176-
*
177-
* Block `A` post-dominates block `B` if any control flow path from `B` to the exit block of the
178-
* function must pass through block `A`. A block always post-dominates itself.
179-
*/
180-
predicate postDominates(IRBlock block) { strictlyPostDominates(block) or this = block }
181-
182154
/**
183155
* Gets a block on the dominance frontier of this block.
184156
*
@@ -308,12 +280,3 @@ private module Cached {
308280
}
309281

310282
private Instruction getFirstInstruction(TIRBlock block) { block = MkIRBlock(result) }
311-
312-
private predicate blockFunctionExit(IRBlock exit) {
313-
exit.getLastInstruction() instanceof ExitFunctionInstruction
314-
}
315-
316-
private predicate blockPredecessor(IRBlock src, IRBlock pred) { src.getAPredecessor() = pred }
317-
318-
private predicate blockImmediatelyPostDominates(IRBlock postDominator, IRBlock block) =
319-
idominance(blockFunctionExit/1, blockPredecessor/2)(_, postDominator, block)

0 commit comments

Comments
 (0)