Skip to content

Commit 439872b

Browse files
committed
Java: Simplify Guards instantiation a bit.
1 parent 5cd03b4 commit 439872b

File tree

1 file changed

+14
-16
lines changed
  • java/ql/lib/semmle/code/java/controlflow

1 file changed

+14
-16
lines changed

java/ql/lib/semmle/code/java/controlflow/Guards.qll

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,17 @@ private module LogicInputCommon {
392392
NullGuards::nullCheckMethod(call.getMethod(), val.asBooleanValue(), isNull)
393393
)
394394
}
395+
396+
predicate additionalImpliesStep(
397+
GuardsImpl::PreGuard g1, GuardValue v1, GuardsImpl::PreGuard g2, GuardValue v2
398+
) {
399+
exists(MethodCall check, int argIndex |
400+
g1 = check and
401+
v1.getDualValue().isThrowsException() and
402+
conditionCheckArgument(check, argIndex, v2.asBooleanValue()) and
403+
g2 = check.getArgument(argIndex)
404+
)
405+
}
395406
}
396407

397408
private module LogicInput_v1 implements GuardsImpl::LogicInputSig {
@@ -422,16 +433,7 @@ private module LogicInput_v1 implements GuardsImpl::LogicInputSig {
422433

423434
predicate additionalNullCheck = LogicInputCommon::additionalNullCheck/4;
424435

425-
predicate additionalImpliesStep(
426-
GuardsImpl::PreGuard g1, GuardValue v1, GuardsImpl::PreGuard g2, GuardValue v2
427-
) {
428-
exists(MethodCall check, int argIndex |
429-
g1 = check and
430-
v1.getDualValue().isThrowsException() and
431-
conditionCheckArgument(check, argIndex, v2.asBooleanValue()) and
432-
g2 = check.getArgument(argIndex)
433-
)
434-
}
436+
predicate additionalImpliesStep = LogicInputCommon::additionalImpliesStep/4;
435437
}
436438

437439
private module LogicInput_v2 implements GuardsImpl::LogicInputSig {
@@ -462,11 +464,7 @@ private module LogicInput_v2 implements GuardsImpl::LogicInputSig {
462464

463465
predicate additionalNullCheck = LogicInputCommon::additionalNullCheck/4;
464466

465-
predicate additionalImpliesStep(
466-
GuardsImpl::PreGuard g1, GuardValue v1, GuardsImpl::PreGuard g2, GuardValue v2
467-
) {
468-
LogicInput_v1::additionalImpliesStep(g1, v1, g2, v2)
469-
}
467+
predicate additionalImpliesStep = LogicInputCommon::additionalImpliesStep/4;
470468
}
471469

472470
private module LogicInput_v3 implements GuardsImpl::LogicInputSig {
@@ -479,7 +477,7 @@ private module LogicInput_v3 implements GuardsImpl::LogicInputSig {
479477

480478
predicate additionalNullCheck = LogicInputCommon::additionalNullCheck/4;
481479

482-
predicate additionalImpliesStep = LogicInput_v2::additionalImpliesStep/4;
480+
predicate additionalImpliesStep = LogicInputCommon::additionalImpliesStep/4;
483481
}
484482

485483
class GuardValue = GuardsImpl::GuardValue;

0 commit comments

Comments
 (0)