Skip to content

Commit c568a8d

Browse files
committed
C#: Disjunctive barrier guards for free
1 parent e74c8f8 commit c568a8d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,18 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
11141114
}
11151115
}
11161116

1117+
class AndGuard extends Guard instanceof LogicalAndExpr {
1118+
Guard getLeftOperand() { result = LogicalAndExpr.super.getLeftOperand() }
1119+
1120+
Guard getRightOperand() { result = LogicalAndExpr.super.getRightOperand() }
1121+
}
1122+
1123+
class OrGuard extends Guard instanceof LogicalOrExpr {
1124+
Guard getLeftOperand() { result = LogicalOrExpr.super.getLeftOperand() }
1125+
1126+
Guard getRightOperand() { result = LogicalOrExpr.super.getRightOperand() }
1127+
}
1128+
11171129
/** Holds if the guard `guard` controls block `bb` upon evaluating to `branch`. */
11181130
predicate guardControlsBlock(Guard guard, ControlFlow::BasicBlock bb, boolean branch) {
11191131
exists(ConditionBlock conditionBlock, ControlFlow::SuccessorTypes::ConditionalSuccessor s |

csharp/ql/test/library-tests/dataflow/barrier-guards/barrier-flow.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edges
88
| BarrierFlow.cs:86:13:86:13 | access to local variable x : Object | BarrierFlow.cs:103:18:103:18 | access to local variable x | provenance | |
99
| BarrierFlow.cs:86:13:86:13 | access to local variable x : Object | BarrierFlow.cs:112:18:112:18 | access to local variable x | provenance | |
1010
| BarrierFlow.cs:86:13:86:13 | access to local variable x : Object | BarrierFlow.cs:117:18:117:18 | access to local variable x | provenance | |
11-
| BarrierFlow.cs:86:13:86:13 | access to local variable x : Object | BarrierFlow.cs:121:18:121:18 | access to local variable x | provenance | |
1211
| BarrierFlow.cs:86:17:86:25 | call to method Source : Object | BarrierFlow.cs:86:13:86:13 | access to local variable x : Object | provenance | |
1312
| BarrierFlow.cs:127:13:127:13 | access to local variable x : Object | BarrierFlow.cs:135:18:135:18 | access to local variable x | provenance | |
1413
| BarrierFlow.cs:127:13:127:13 | access to local variable x : Object | BarrierFlow.cs:140:18:140:18 | access to local variable x | provenance | |
@@ -28,7 +27,6 @@ nodes
2827
| BarrierFlow.cs:103:18:103:18 | access to local variable x | semmle.label | access to local variable x |
2928
| BarrierFlow.cs:112:18:112:18 | access to local variable x | semmle.label | access to local variable x |
3029
| BarrierFlow.cs:117:18:117:18 | access to local variable x | semmle.label | access to local variable x |
31-
| BarrierFlow.cs:121:18:121:18 | access to local variable x | semmle.label | access to local variable x |
3230
| BarrierFlow.cs:127:13:127:13 | access to local variable x : Object | semmle.label | access to local variable x : Object |
3331
| BarrierFlow.cs:127:17:127:25 | call to method Source : Object | semmle.label | call to method Source : Object |
3432
| BarrierFlow.cs:135:18:135:18 | access to local variable x | semmle.label | access to local variable x |
@@ -37,15 +35,13 @@ nodes
3735
| BarrierFlow.cs:158:18:158:18 | access to local variable x | semmle.label | access to local variable x |
3836
subpaths
3937
testFailures
40-
| BarrierFlow.cs:121:18:121:18 | access to local variable x | Unexpected result: hasValueFlow=7 |
4138
#select
4239
| BarrierFlow.cs:12:14:12:14 | access to local variable x | BarrierFlow.cs:10:17:10:25 | call to method Source : Object | BarrierFlow.cs:12:14:12:14 | access to local variable x | $@ | BarrierFlow.cs:10:17:10:25 | call to method Source : Object | call to method Source : Object |
4340
| BarrierFlow.cs:21:18:21:18 | access to local variable x | BarrierFlow.cs:17:17:17:25 | call to method Source : Object | BarrierFlow.cs:21:18:21:18 | access to local variable x | $@ | BarrierFlow.cs:17:17:17:25 | call to method Source : Object | call to method Source : Object |
4441
| BarrierFlow.cs:94:18:94:18 | access to local variable x | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | BarrierFlow.cs:94:18:94:18 | access to local variable x | $@ | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | call to method Source : Object |
4542
| BarrierFlow.cs:103:18:103:18 | access to local variable x | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | BarrierFlow.cs:103:18:103:18 | access to local variable x | $@ | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | call to method Source : Object |
4643
| BarrierFlow.cs:112:18:112:18 | access to local variable x | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | BarrierFlow.cs:112:18:112:18 | access to local variable x | $@ | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | call to method Source : Object |
4744
| BarrierFlow.cs:117:18:117:18 | access to local variable x | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | BarrierFlow.cs:117:18:117:18 | access to local variable x | $@ | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | call to method Source : Object |
48-
| BarrierFlow.cs:121:18:121:18 | access to local variable x | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | BarrierFlow.cs:121:18:121:18 | access to local variable x | $@ | BarrierFlow.cs:86:17:86:25 | call to method Source : Object | call to method Source : Object |
4945
| BarrierFlow.cs:135:18:135:18 | access to local variable x | BarrierFlow.cs:127:17:127:25 | call to method Source : Object | BarrierFlow.cs:135:18:135:18 | access to local variable x | $@ | BarrierFlow.cs:127:17:127:25 | call to method Source : Object | call to method Source : Object |
5046
| BarrierFlow.cs:140:18:140:18 | access to local variable x | BarrierFlow.cs:127:17:127:25 | call to method Source : Object | BarrierFlow.cs:140:18:140:18 | access to local variable x | $@ | BarrierFlow.cs:127:17:127:25 | call to method Source : Object | call to method Source : Object |
5147
| BarrierFlow.cs:149:18:149:18 | access to local variable x | BarrierFlow.cs:127:17:127:25 | call to method Source : Object | BarrierFlow.cs:149:18:149:18 | access to local variable x | $@ | BarrierFlow.cs:127:17:127:25 | call to method Source : Object | call to method Source : Object |

0 commit comments

Comments
 (0)