Skip to content

Commit

Permalink
Rangeanalysis/Java/C++: Address some ql4ql findings.
Browse files Browse the repository at this point in the history
  • Loading branch information
aschackmull committed Oct 25, 2023
1 parent 2592c94 commit 283d6ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
* possibilty for negative values.
* possibility for negative values.
*/
predicate semMayBePositive(SemExpr e) { semExprSign(e) = TPos() }

/**
* 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() }
}
14 changes: 7 additions & 7 deletions java/ql/lib/semmle/code/java/dataflow/RangeAnalysis.qll
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module Sem implements Semantic {
private import java as J
private import SSA as SSA
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

class Expr = J::Expr;
Expand Down Expand Up @@ -230,18 +230,18 @@ module Sem implements Semantic {

class SsaExplicitUpdate extends SsaVariable instanceof SSA::SsaExplicitUpdate { }

final private class FinalSsaReadPosition = SSAReadPos::SsaReadPosition;
final private class FinalSsaReadPosition = SsaReadPos::SsaReadPosition;

class SsaReadPosition extends FinalSsaReadPosition {
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) }
}

class SsaReadPositionBlock extends SsaReadPosition instanceof SSAReadPos::SsaReadPositionBlock {
class SsaReadPositionBlock extends SsaReadPosition instanceof SsaReadPos::SsaReadPositionBlock {
BasicBlock getBlock() { result = super.getBlock() }
}

Expand Down Expand Up @@ -374,7 +374,7 @@ module JavaLangImpl implements LangSig<Sem, IntDelta> {

module Utils implements UtilSig<Sem, IntDelta> {
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) }

Expand All @@ -399,10 +399,10 @@ module Utils implements UtilSig<Sem, IntDelta> {
predicate rankedPhiInput(
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> {
Expand Down
4 changes: 2 additions & 2 deletions shared/rangeanalysis/codeql/rangeanalysis/RangeAnalysis.qll
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,13 @@ signature module SignAnalysisSig<Semantic Sem> {

/**
* 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);

/**
* 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);
}
Expand Down

0 comments on commit 283d6ef

Please sign in to comment.