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

Skip to content

Commit 421e75d

Browse files
committed
C#: Address review comments
1 parent 16b6791 commit 421e75d

7 files changed

Lines changed: 702 additions & 726 deletions

File tree

csharp/ql/src/semmle/code/csharp/controlflow/ControlFlowGraph.qll

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,16 +1110,28 @@ module ControlFlow {
11101110
c = c0
11111111
or
11121112
rec = TLastRecAbnormalCompletion() and
1113-
c0 instanceof AbnormalCompletion and
1113+
not c0 instanceof NormalCompletion and
11141114
c = c0
11151115
or
11161116
rec = TLastRecBooleanNegationCompletion() and
1117-
c = any(BooleanCompletion bc |
1118-
c0 = any(BooleanCompletion bc0 |
1119-
bc.getOuterValue() = bc0.getOuterValue().booleanNot() and
1120-
bc.getInnerValue() = bc0.getInnerValue()
1121-
)
1122-
)
1117+
(
1118+
c = any(NestedCompletion nc |
1119+
nc.getInnerCompletion() = c0 and
1120+
nc.getOuterCompletion().(BooleanCompletion).getValue() = c0
1121+
.(BooleanCompletion)
1122+
.getValue()
1123+
.booleanNot()
1124+
)
1125+
or
1126+
c = any(BooleanCompletion bc |
1127+
bc.getValue() = c0
1128+
.(NestedCompletion)
1129+
.getInnerCompletion()
1130+
.(BooleanCompletion)
1131+
.getValue() and
1132+
not bc instanceof NestedCompletion
1133+
)
1134+
)
11231135
or
11241136
rec = TLastRecNonBooleanCompletion() and
11251137
not c0 instanceof BooleanCompletion and
@@ -1142,11 +1154,11 @@ module ControlFlow {
11421154
or
11431155
rec = TLastRecInvalidOperationException() and
11441156
(c0.(MatchingCompletion).isNonMatch() or c0 instanceof FalseCompletion) and
1145-
c = any(InheritedCompletion ic |
1146-
ic.getUnderlyingCompletion() = c0 and
1147-
ic
1148-
.getInheritedCompletion()
1149-
.(ThrowCompletionDirect)
1157+
c = any(NestedCompletion nc |
1158+
nc.getInnerCompletion() = c0 and
1159+
nc
1160+
.getOuterCompletion()
1161+
.(ThrowCompletion)
11501162
.getExceptionClass()
11511163
.hasQualifiedName("System.InvalidOperationException")
11521164
)
@@ -1175,18 +1187,18 @@ module ControlFlow {
11751187
exists(MatchingCompletion mc |
11761188
mc.isNonMatch() and
11771189
mc.isValidFor(scc) and
1178-
c = any(InheritedCompletion ic |
1179-
ic.getUnderlyingCompletion() = mc and
1180-
ic.getInheritedCompletion() = tc.getInheritedCompletion()
1190+
c = any(NestedCompletion nc |
1191+
nc.getInnerCompletion() = mc and
1192+
nc.getOuterCompletion() = tc.getOuterCompletion()
11811193
)
11821194
)
11831195
or
11841196
// Incompatible filter
11851197
exists(FalseCompletion fc |
11861198
result = lastSpecificCatchClauseFilterClause(scc, fc) and
1187-
c = any(InheritedCompletion ic |
1188-
ic.getUnderlyingCompletion() = fc and
1189-
ic.getInheritedCompletion() = tc.getInheritedCompletion()
1199+
c = any(NestedCompletion nc |
1200+
nc.getInnerCompletion() = fc and
1201+
nc.getOuterCompletion() = tc.getOuterCompletion()
11901202
)
11911203
)
11921204
)
@@ -1206,9 +1218,8 @@ module ControlFlow {
12061218
or
12071219
// If the `finally` block completes normally, it inherits any non-normal
12081220
// completion that was current before the `finally` block was entered
1209-
c = any(InheritedCompletion ic |
1210-
result = lastTryStmtFinally(ts, ic.getUnderlyingCompletion(),
1211-
ic.getInheritedCompletion())
1221+
c = any(NestedCompletion nc |
1222+
result = lastTryStmtFinally(ts, nc.getInnerCompletion(), nc.getOuterCompletion())
12121223
)
12131224
)
12141225
}
@@ -1285,14 +1296,9 @@ module ControlFlow {
12851296
}
12861297

12871298
pragma[nomagic]
1288-
ControlFlowElement lastTryStmtFinally(
1289-
TryStmt ts, NormalCompletion finally, Completion inherited
1290-
) {
1299+
ControlFlowElement lastTryStmtFinally(TryStmt ts, NormalCompletion finally, Completion outer) {
12911300
result = lastTryStmtFinally0(ts, finally) and
1292-
exists(Completion c0 | exists(getBlockOrCatchFinallyPred(ts, c0)) |
1293-
inherited = c0.(NormalCompletion) or
1294-
inherited = c0.(AbnormalCompletion).getInheritedCompletion()
1295-
)
1301+
exists(getBlockOrCatchFinallyPred(ts, any(Completion c0 | outer = c0.getOuterCompletion())))
12961302
}
12971303

12981304
/**

0 commit comments

Comments
 (0)