mirror of
https://github.com/github/codeql.git
synced 2026-06-02 20:30:15 +02:00
formatting
This commit is contained in:
@@ -11,24 +11,4 @@ private import codeql.rangeanalysis.Bound as SharedBound
|
||||
|
||||
private module BoundImpl = SharedBound::Bound<CS::Location, BoundSpecific::BoundDefs>;
|
||||
|
||||
/**
|
||||
* A bound that may be inferred for an expression plus/minus an integer delta.
|
||||
*/
|
||||
class Bound = BoundImpl::Bound;
|
||||
|
||||
/**
|
||||
* The bound that corresponds to the integer 0. This is used to represent all
|
||||
* integer bounds as bounds are always accompanied by an added integer delta.
|
||||
*/
|
||||
class ZeroBound = BoundImpl::ZeroBound;
|
||||
|
||||
/**
|
||||
* A bound corresponding to the value of an SSA variable.
|
||||
*/
|
||||
class SsaBound = BoundImpl::SsaBound;
|
||||
|
||||
/**
|
||||
* A bound that corresponds to the value of a specific expression that might be
|
||||
* interesting, but isn't otherwise represented by the value of an SSA variable.
|
||||
*/
|
||||
class ExprBound = BoundImpl::ExprBound;
|
||||
import BoundImpl
|
||||
|
||||
@@ -10,23 +10,19 @@ private import semmle.code.csharp.dataflow.internal.rangeanalysis.SsaUtils as SU
|
||||
private import codeql.rangeanalysis.Bound as SharedBound
|
||||
|
||||
/** Holds if `e` is a bound expression and it is not an SSA variable read. */
|
||||
|
||||
|
||||
module BoundDefs implements SharedBound::BoundDefinitions<CS::Location> {
|
||||
class Type = CS::Type;
|
||||
class Type = CS::Type;
|
||||
|
||||
class SsaVariable = SU::SsaVariable;
|
||||
|
||||
class SsaSourceVariable = Ssa::SourceVariable;
|
||||
class SsaVariable = SU::SsaVariable;
|
||||
|
||||
class Expr = CS::ControlFlowNodes::ExprNode;
|
||||
class SsaSourceVariable = Ssa::SourceVariable;
|
||||
|
||||
class IntegralType = CS::IntegralType;
|
||||
class Expr = CS::ControlFlowNodes::ExprNode;
|
||||
|
||||
class ConstantIntegerExpr = CU::ConstantIntegerExpr;
|
||||
class IntegralType = CS::IntegralType;
|
||||
|
||||
class ConstantIntegerExpr = CU::ConstantIntegerExpr;
|
||||
|
||||
/** Holds if `e` is a bound expression and it is not an SSA variable read. */
|
||||
predicate interestingExprBound(Expr e) {
|
||||
CU::systemArrayLengthAccess(e.getExpr())
|
||||
}
|
||||
predicate interestingExprBound(Expr e) { CU::systemArrayLengthAccess(e.getExpr()) }
|
||||
}
|
||||
|
||||
@@ -10,24 +10,4 @@ private import codeql.rangeanalysis.Bound as SharedBound
|
||||
|
||||
private module BoundImpl = SharedBound::Bound<J::Location, BoundSpecific::BoundDefs>;
|
||||
|
||||
/**
|
||||
* A bound that may be inferred for an expression plus/minus an integer delta.
|
||||
*/
|
||||
class Bound = BoundImpl::Bound;
|
||||
|
||||
/**
|
||||
* The bound that corresponds to the integer 0. This is used to represent all
|
||||
* integer bounds as bounds are always accompanied by an added integer delta.
|
||||
*/
|
||||
class ZeroBound = BoundImpl::ZeroBound;
|
||||
|
||||
/**
|
||||
* A bound corresponding to the value of an SSA variable.
|
||||
*/
|
||||
class SsaBound = BoundImpl::SsaBound;
|
||||
|
||||
/**
|
||||
* A bound that corresponds to the value of a specific expression that might be
|
||||
* interesting, but isn't otherwise represented by the value of an SSA variable.
|
||||
*/
|
||||
class ExprBound = BoundImpl::ExprBound;
|
||||
import BoundImpl
|
||||
|
||||
@@ -29,4 +29,4 @@ module BoundDefs implements SharedBound::BoundDefinitions<J::Location> {
|
||||
predicate interestingExprBound(Expr e) {
|
||||
e.(J::FieldRead).getField() instanceof J::ArrayLengthField
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,48 +5,53 @@
|
||||
private import codeql.util.Location
|
||||
|
||||
signature module BoundDefinitions<LocationSig Location> {
|
||||
class Type;
|
||||
class IntegralType extends Type;
|
||||
class Type;
|
||||
|
||||
class ConstantIntegerExpr extends Expr {
|
||||
int getIntValue();
|
||||
}
|
||||
class IntegralType extends Type;
|
||||
|
||||
class SsaSourceVariable {
|
||||
Type getType();
|
||||
}
|
||||
class ConstantIntegerExpr extends Expr {
|
||||
int getIntValue();
|
||||
}
|
||||
|
||||
class SsaVariable {
|
||||
SsaSourceVariable getSourceVariable();
|
||||
string toString();
|
||||
Location getLocation();
|
||||
Expr getAUse();
|
||||
}
|
||||
class SsaSourceVariable {
|
||||
Type getType();
|
||||
}
|
||||
|
||||
class Expr {
|
||||
string toString();
|
||||
Location getLocation();
|
||||
}
|
||||
class SsaVariable {
|
||||
SsaSourceVariable getSourceVariable();
|
||||
|
||||
predicate interestingExprBound(Expr e);
|
||||
string toString();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
Expr getAUse();
|
||||
}
|
||||
|
||||
class Expr {
|
||||
string toString();
|
||||
|
||||
Location getLocation();
|
||||
}
|
||||
|
||||
predicate interestingExprBound(Expr e);
|
||||
}
|
||||
|
||||
overlay[local?]
|
||||
module Bound<LocationSig Location, BoundDefinitions<Location> Defs> {
|
||||
private import Defs
|
||||
private import Defs
|
||||
|
||||
private newtype TBound =
|
||||
private newtype TBound =
|
||||
TBoundZero() or
|
||||
TBoundSsa(SsaVariable v) { v.getSourceVariable().getType() instanceof IntegralType } or
|
||||
TBoundExpr(Expr e) {
|
||||
interestingExprBound(e) and
|
||||
not exists(SsaVariable v | e = v.getAUse())
|
||||
interestingExprBound(e) and
|
||||
not exists(SsaVariable v | e = v.getAUse())
|
||||
}
|
||||
|
||||
/**
|
||||
* A bound that may be inferred for an expression plus/minus an integer delta.
|
||||
*/
|
||||
abstract class Bound extends TBound {
|
||||
/**
|
||||
* A bound that may be inferred for an expression plus/minus an integer delta.
|
||||
*/
|
||||
abstract class Bound extends TBound {
|
||||
/** Gets a textual representation of this bound. */
|
||||
abstract string toString();
|
||||
|
||||
@@ -58,24 +63,24 @@ module Bound<LocationSig Location, BoundDefinitions<Location> Defs> {
|
||||
|
||||
/** Gets the location of this bound. */
|
||||
abstract Location getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The bound that corresponds to the integer 0. This is used to represent all
|
||||
* integer bounds as bounds are always accompanied by an added integer delta.
|
||||
*/
|
||||
class ZeroBound extends Bound, TBoundZero {
|
||||
/**
|
||||
* The bound that corresponds to the integer 0. This is used to represent all
|
||||
* integer bounds as bounds are always accompanied by an added integer delta.
|
||||
*/
|
||||
class ZeroBound extends Bound, TBoundZero {
|
||||
override string toString() { result = "0" }
|
||||
|
||||
override Expr getExpr(int delta) { result.(ConstantIntegerExpr).getIntValue() = delta }
|
||||
|
||||
override Location getLocation() { result.hasLocationInfo("", 0, 0, 0, 0) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A bound corresponding to the value of an SSA variable.
|
||||
*/
|
||||
class SsaBound extends Bound, TBoundSsa {
|
||||
/**
|
||||
* A bound corresponding to the value of an SSA variable.
|
||||
*/
|
||||
class SsaBound extends Bound, TBoundSsa {
|
||||
/** Gets the SSA variable that equals this bound. */
|
||||
SsaVariable getSsa() { this = TBoundSsa(result) }
|
||||
|
||||
@@ -84,17 +89,17 @@ module Bound<LocationSig Location, BoundDefinitions<Location> Defs> {
|
||||
override Expr getExpr(int delta) { result = this.getSsa().getAUse() and delta = 0 }
|
||||
|
||||
override Location getLocation() { result = this.getSsa().getLocation() }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A bound that corresponds to the value of a specific expression that might be
|
||||
* interesting, but isn't otherwise represented by the value of an SSA variable.
|
||||
*/
|
||||
class ExprBound extends Bound, TBoundExpr {
|
||||
/**
|
||||
* A bound that corresponds to the value of a specific expression that might be
|
||||
* interesting, but isn't otherwise represented by the value of an SSA variable.
|
||||
*/
|
||||
class ExprBound extends Bound, TBoundExpr {
|
||||
override string toString() { result = this.getExpr().toString() }
|
||||
|
||||
override Expr getExpr(int delta) { this = TBoundExpr(result) and delta = 0 }
|
||||
|
||||
override Location getLocation() { result = this.getExpr().getLocation() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user