mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
make strictlyBefore a member predicate on Location
This commit is contained in:
@@ -50,12 +50,11 @@ class Location extends @location {
|
||||
filepath = f.getAbsolutePath()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds if location `one` starts strictly before location `two` */
|
||||
pragma[inline]
|
||||
predicate strictlyBefore(Location one, Location two) {
|
||||
one.getStartLine() < two.getStartLine()
|
||||
or
|
||||
one.getStartLine() = two.getStartLine() and one.getStartColumn() < two.getStartColumn()
|
||||
}
|
||||
/** Holds if this location starts strictly before the specified location. */
|
||||
predicate strictlyBefore(Location other) {
|
||||
this.getStartLine() < other.getStartLine()
|
||||
or
|
||||
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
|
||||
Stmt getTerminalStmt() {
|
||||
result = this.getAChildStmt() and
|
||||
forall(Stmt s | s = this.getAChildStmt() and not s = result |
|
||||
strictlyBefore(s.getLocation(), result.getLocation())
|
||||
s.getLocation().strictlyBefore(result.getLocation())
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -288,7 +288,7 @@ private module Cached {
|
||||
name = access.getValue()
|
||||
|
|
||||
variable.getDeclaringScope() = scopeOf(access) and
|
||||
not strictlyBefore(access.getLocation(), variable.getLocation()) and
|
||||
not access.getLocation().strictlyBefore(variable.getLocation()) and
|
||||
// In case of overlapping parameter names, later parameters should not
|
||||
// be considered accesses to the first parameter
|
||||
if parameterAssignment(_, _, access)
|
||||
@@ -358,7 +358,7 @@ private predicate inherits(Scope::Range scope, string name, Scope::Range outer)
|
||||
or
|
||||
exists(Ruby::Identifier i |
|
||||
scopeAssigns(outer, name, i) and
|
||||
strictlyBefore(i.getLocation(), scope.getLocation())
|
||||
i.getLocation().strictlyBefore(scope.getLocation())
|
||||
)
|
||||
)
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user