Skip to content

Commit

Permalink
C#: Sync Bound.qll
Browse files Browse the repository at this point in the history
  • Loading branch information
aschackmull committed Oct 25, 2023
1 parent 283d6ef commit 5ded55c
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions csharp/ql/lib/semmle/code/csharp/dataflow/Bound.qll
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ abstract class Bound extends TBound {
/** Gets an expression that equals this bound. */
Expr getExpr() { result = this.getExpr(0) }

/**
* Holds if this element is at the specified location.
* The location spans column `sc` of line `sl` to
* column `ec` of line `el` in file `path`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
path = "" and sl = 0 and sc = 0 and el = 0 and ec = 0
}
/** Gets the location of this bound. */
abstract Location getLocation();
}

/**
Expand All @@ -45,6 +37,8 @@ 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) }
}

/**
Expand All @@ -58,9 +52,7 @@ class SsaBound extends Bound, TBoundSsa {

override Expr getExpr(int delta) { result = this.getSsa().getAUse() and delta = 0 }

override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
this.getSsa().getLocation().hasLocationInfo(path, sl, sc, el, ec)
}
override Location getLocation() { result = this.getSsa().getLocation() }
}

/**
Expand All @@ -72,7 +64,5 @@ class ExprBound extends Bound, TBoundExpr {

override Expr getExpr(int delta) { this = TBoundExpr(result) and delta = 0 }

override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
this.getExpr().getLocation().hasLocationInfo(path, sl, sc, el, ec)
}
override Location getLocation() { result = this.getExpr().getLocation() }
}

0 comments on commit 5ded55c

Please sign in to comment.