Java: Add support for BarrierGuards as parameterised modules.

This commit is contained in:
Anders Schack-Mulligen
2022-05-24 16:36:03 +02:00
parent 1075a141a4
commit a3177368f0
2 changed files with 30 additions and 13 deletions

View File

@@ -304,6 +304,27 @@ class ContentSet instanceof Content {
}
}
/**
* Holds if `g` validates the `e` upon evaluating to `branch`.
*
* The expression `e` is expected to be a syntactic part of the guard `g`.
* For example, the guard `g` might be a call `isSafe(x)` and the expression `e`
* the argument `x`.
*/
signature predicate guardChecksSig(Guard g, Expr e, boolean branch);
module BarrierGuard<guardChecksSig/3 guardChecks> {
/** Gets a node that is safely guarded by the given guard. */
Node getABarrierNode() {
exists(Guard g, SsaVariable v, boolean branch, RValue use |
guardChecks(g, v.getAUse(), branch) and
use = v.getAUse() and
g.controls(use.getBasicBlock(), branch) and
result.asExpr() = use
)
}
}
/**
* A guard that validates some expression.
*