Java, C#: Refactor implicitSsaDefSign in sign analysis

This commit is contained in:
Tamas Vajk
2020-09-29 12:10:35 +02:00
parent 37fc1d6f0f
commit 7545fe74e3
4 changed files with 31 additions and 12 deletions

View File

@@ -245,6 +245,13 @@ private Sign ssaDefSign(SsaVariable v) {
)
}
/** Returns the sign of implicit SSA definition `v`. */
private Sign implicitSsaDefSign(SsaVariable v) {
result = fieldSign(getImplicitSsaDeclaration(v))
or
anySign(result) and nonFieldImplicitSsaDefinition(v)
}
/** Gets a possible sign for `e`. */
cached
Sign exprSign(Expr e) {

View File

@@ -115,13 +115,15 @@ private module Impl {
)
}
/** Returns the sign of implicit SSA definition `v`. */
Sign implicitSsaDefSign(SsaVariable v) {
result = fieldSign(v.(SsaImplicitUpdate).getSourceVariable().getVariable())
or
result = fieldSign(v.(SsaImplicitInit).getSourceVariable().getVariable())
or
anySign(result) and exists(Parameter p | v.(SsaImplicitInit).isParameterDefinition(p))
/** Gets the variable underlying the implicit SSA variable `v`. */
Variable getImplicitSsaDeclaration(SsaVariable v) {
result = v.(SsaImplicitUpdate).getSourceVariable().getVariable() or
result = v.(SsaImplicitInit).getSourceVariable().getVariable()
}
/** Holds if the variable underlying the implicit SSA variable `v` is not a field. */
predicate nonFieldImplicitSsaDefinition(SsaImplicitInit v) {
exists(Parameter p | v.isParameterDefinition(p))
}
/** Gets a possible sign for `f`. */