Rangeanalysis/Java/C++: Address some ql4ql findings.

This commit is contained in:
Anders Schack-Mulligen
2023-10-25 14:06:35 +02:00
parent 2592c94c54
commit 283d6efdf8
3 changed files with 11 additions and 11 deletions

View File

@@ -511,13 +511,13 @@ module SignAnalysis<DeltaSig D, UtilSig<Sem, D> Utils> {
/** /**
* Holds if `e` may have positive values. This does not rule out the * Holds if `e` may have positive values. This does not rule out the
* possibilty for negative values. * possibility for negative values.
*/ */
predicate semMayBePositive(SemExpr e) { semExprSign(e) = TPos() } predicate semMayBePositive(SemExpr e) { semExprSign(e) = TPos() }
/** /**
* Holds if `e` may have negative values. This does not rule out the * Holds if `e` may have negative values. This does not rule out the
* possibilty for positive values. * possibility for positive values.
*/ */
predicate semMayBeNegative(SemExpr e) { semExprSign(e) = TNeg() } predicate semMayBeNegative(SemExpr e) { semExprSign(e) = TNeg() }
} }

View File

@@ -81,7 +81,7 @@ module Sem implements Semantic {
private import java as J private import java as J
private import SSA as SSA private import SSA as SSA
private import RangeUtils as RU private import RangeUtils as RU
private import semmle.code.java.dataflow.internal.rangeanalysis.SsaReadPositionCommon as SSAReadPos private import semmle.code.java.dataflow.internal.rangeanalysis.SsaReadPositionCommon as SsaReadPos
private import semmle.code.java.controlflow.internal.GuardsLogic as GL private import semmle.code.java.controlflow.internal.GuardsLogic as GL
class Expr = J::Expr; class Expr = J::Expr;
@@ -230,18 +230,18 @@ module Sem implements Semantic {
class SsaExplicitUpdate extends SsaVariable instanceof SSA::SsaExplicitUpdate { } class SsaExplicitUpdate extends SsaVariable instanceof SSA::SsaExplicitUpdate { }
final private class FinalSsaReadPosition = SSAReadPos::SsaReadPosition; final private class FinalSsaReadPosition = SsaReadPos::SsaReadPosition;
class SsaReadPosition extends FinalSsaReadPosition { class SsaReadPosition extends FinalSsaReadPosition {
predicate hasReadOfVar(SsaVariable v) { super.hasReadOfVar(v) } predicate hasReadOfVar(SsaVariable v) { super.hasReadOfVar(v) }
} }
class SsaReadPositionPhiInputEdge extends SsaReadPosition instanceof SSAReadPos::SsaReadPositionPhiInputEdge class SsaReadPositionPhiInputEdge extends SsaReadPosition instanceof SsaReadPos::SsaReadPositionPhiInputEdge
{ {
predicate phiInput(SsaPhiNode phi, SsaVariable inp) { super.phiInput(phi, inp) } predicate phiInput(SsaPhiNode phi, SsaVariable inp) { super.phiInput(phi, inp) }
} }
class SsaReadPositionBlock extends SsaReadPosition instanceof SSAReadPos::SsaReadPositionBlock { class SsaReadPositionBlock extends SsaReadPosition instanceof SsaReadPos::SsaReadPositionBlock {
BasicBlock getBlock() { result = super.getBlock() } BasicBlock getBlock() { result = super.getBlock() }
} }
@@ -374,7 +374,7 @@ module JavaLangImpl implements LangSig<Sem, IntDelta> {
module Utils implements UtilSig<Sem, IntDelta> { module Utils implements UtilSig<Sem, IntDelta> {
private import RangeUtils as RU private import RangeUtils as RU
private import semmle.code.java.dataflow.internal.rangeanalysis.SsaReadPositionCommon as SSAReadPos private import semmle.code.java.dataflow.internal.rangeanalysis.SsaReadPositionCommon as SsaReadPos
Sem::Expr semSsaRead(Sem::SsaVariable v, int delta) { result = RU::ssaRead(v, delta) } Sem::Expr semSsaRead(Sem::SsaVariable v, int delta) { result = RU::ssaRead(v, delta) }
@@ -399,10 +399,10 @@ module Utils implements UtilSig<Sem, IntDelta> {
predicate rankedPhiInput( predicate rankedPhiInput(
Sem::SsaPhiNode phi, Sem::SsaVariable inp, Sem::SsaReadPositionPhiInputEdge edge, int r Sem::SsaPhiNode phi, Sem::SsaVariable inp, Sem::SsaReadPositionPhiInputEdge edge, int r
) { ) {
SSAReadPos::rankedPhiInput(phi, inp, edge, r) SsaReadPos::rankedPhiInput(phi, inp, edge, r)
} }
predicate maxPhiInputRank(Sem::SsaPhiNode phi, int rix) { SSAReadPos::maxPhiInputRank(phi, rix) } predicate maxPhiInputRank(Sem::SsaPhiNode phi, int rix) { SsaReadPos::maxPhiInputRank(phi, rix) }
} }
module Bounds implements BoundSig<Location, Sem, IntDelta> { module Bounds implements BoundSig<Location, Sem, IntDelta> {

View File

@@ -202,13 +202,13 @@ signature module SignAnalysisSig<Semantic Sem> {
/** /**
* Holds if `e` may have positive values. This does not rule out the * Holds if `e` may have positive values. This does not rule out the
* possibilty for negative values. * possibility for negative values.
*/ */
predicate semMayBePositive(Sem::Expr e); predicate semMayBePositive(Sem::Expr e);
/** /**
* Holds if `e` may have negative values. This does not rule out the * Holds if `e` may have negative values. This does not rule out the
* possibilty for positive values. * possibility for positive values.
*/ */
predicate semMayBeNegative(Sem::Expr e); predicate semMayBeNegative(Sem::Expr e);
} }