mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Merge pull request #14656 from aschackmull/shared/range-utils
Rangeanalysis: Share ssaRead predicate
This commit is contained in:
@@ -150,6 +150,8 @@ module Sem implements Semantic {
|
||||
}
|
||||
}
|
||||
|
||||
predicate isAssignOp(BinaryExpr bin) { bin instanceof AssignOp }
|
||||
|
||||
class RelationalExpr = J::ComparisonExpr;
|
||||
|
||||
abstract class UnaryExpr extends Expr {
|
||||
@@ -176,18 +178,34 @@ module Sem implements Semantic {
|
||||
override Expr getOperand() { result = super.getExpr() }
|
||||
}
|
||||
|
||||
// TODO: Implement once utils are properly shared
|
||||
class AddOneExpr extends UnaryExpr {
|
||||
AddOneExpr() { none() }
|
||||
|
||||
override Expr getOperand() { none() }
|
||||
class PreIncExpr extends UnaryExpr instanceof J::PreIncExpr {
|
||||
override Expr getOperand() { result = super.getExpr() }
|
||||
}
|
||||
|
||||
// TODO: Implement once utils are properly shared
|
||||
class SubOneExpr extends UnaryExpr {
|
||||
SubOneExpr() { none() }
|
||||
class PreDecExpr extends UnaryExpr instanceof J::PreDecExpr {
|
||||
override Expr getOperand() { result = super.getExpr() }
|
||||
}
|
||||
|
||||
override Expr getOperand() { none() }
|
||||
class PostIncExpr extends UnaryExpr instanceof J::PostIncExpr {
|
||||
override Expr getOperand() { result = super.getExpr() }
|
||||
}
|
||||
|
||||
class PostDecExpr extends UnaryExpr instanceof J::PostDecExpr {
|
||||
override Expr getOperand() { result = super.getExpr() }
|
||||
}
|
||||
|
||||
class CopyValueExpr extends UnaryExpr {
|
||||
CopyValueExpr() {
|
||||
this instanceof J::PlusExpr or
|
||||
this instanceof J::AssignExpr or
|
||||
this instanceof LocalVariableDeclExpr
|
||||
}
|
||||
|
||||
override Expr getOperand() {
|
||||
result = this.(J::PlusExpr).getExpr() or
|
||||
result = this.(J::AssignExpr).getSource() or
|
||||
result = this.(J::LocalVariableDeclExpr).getInit()
|
||||
}
|
||||
}
|
||||
|
||||
class ConditionalExpr = J::ConditionalExpr;
|
||||
@@ -228,7 +246,9 @@ module Sem implements Semantic {
|
||||
|
||||
class SsaPhiNode extends SsaVariable instanceof SSA::SsaPhiNode { }
|
||||
|
||||
class SsaExplicitUpdate extends SsaVariable instanceof SSA::SsaExplicitUpdate { }
|
||||
class SsaExplicitUpdate extends SsaVariable instanceof SSA::SsaExplicitUpdate {
|
||||
Expr getDefiningExpr() { result = super.getDefiningExpr() }
|
||||
}
|
||||
|
||||
final private class FinalSsaReadPosition = SsaReadPos::SsaReadPosition;
|
||||
|
||||
@@ -295,8 +315,6 @@ module IntDelta implements DeltaSig {
|
||||
}
|
||||
|
||||
module JavaLangImpl implements LangSig<Sem, IntDelta> {
|
||||
predicate ignoreSsaReadCopy(Sem::Expr e) { none() }
|
||||
|
||||
/**
|
||||
* Holds if `e >= bound` (if `upper = false`) or `e <= bound` (if `upper = true`).
|
||||
*/
|
||||
@@ -355,14 +373,6 @@ module JavaLangImpl implements LangSig<Sem, IntDelta> {
|
||||
|
||||
predicate ignoreExprBound(Sem::Expr e) { none() }
|
||||
|
||||
predicate ignoreZeroLowerBound(Sem::Expr e) { none() }
|
||||
|
||||
predicate ignoreSsaReadArithmeticExpr(Sem::Expr e) { none() }
|
||||
|
||||
predicate ignoreSsaReadAssignment(Sem::SsaVariable v) { none() }
|
||||
|
||||
Sem::Expr specificSsaRead(Sem::SsaVariable v, int delta) { none() }
|
||||
|
||||
predicate additionalValueFlowStep(Sem::Expr dest, Sem::Expr src, int delta) { none() }
|
||||
|
||||
Sem::Type getAlternateType(Sem::Expr e) { none() }
|
||||
@@ -376,8 +386,6 @@ module Utils implements UtilSig<Sem, IntDelta> {
|
||||
private import RangeUtils as RU
|
||||
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::Guard semEqFlowCond(
|
||||
Sem::SsaVariable v, Sem::Expr e, int delta, boolean isEq, boolean testIsTrue
|
||||
) {
|
||||
@@ -411,7 +419,7 @@ module Bounds implements BoundSig<Location, Sem, IntDelta> {
|
||||
class SemZeroBound = ZeroBound;
|
||||
|
||||
class SemSsaBound extends SsaBound {
|
||||
Sem::SsaVariable getAVariable() { result = super.getSsa() }
|
||||
Sem::SsaVariable getVariable() { result = super.getSsa() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user