Skip to content

Commit df9e0df

Browse files
committed
make strictlyBefore a member predicate on Location
1 parent d84731b commit df9e0df

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

ql/lib/codeql/Locations.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ class Location extends @location {
5050
filepath = f.getAbsolutePath()
5151
)
5252
}
53-
}
54-
55-
/** Holds if location `one` starts strictly before location `two` */
56-
pragma[inline]
57-
predicate strictlyBefore(Location one, Location two) {
58-
one.getStartLine() < two.getStartLine()
59-
or
60-
one.getStartLine() = two.getStartLine() and one.getStartColumn() < two.getStartColumn()
61-
}
53+
54+
/** Holds if this location starts strictly before the specified location. */
55+
predicate strictlyBefore(Location other) {
56+
this.getStartLine() < other.getStartLine()
57+
or
58+
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
59+
}
60+
}

ql/lib/codeql/ruby/ast/Erb.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
143143
Stmt getTerminalStmt() {
144144
result = this.getAChildStmt() and
145145
forall(Stmt s | s = this.getAChildStmt() and not s = result |
146-
strictlyBefore(s.getLocation(), result.getLocation())
146+
s.getLocation().strictlyBefore(result.getLocation())
147147
)
148148
}
149149

ql/lib/codeql/ruby/ast/internal/Variable.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private module Cached {
288288
name = access.getValue()
289289
|
290290
variable.getDeclaringScope() = scopeOf(access) and
291-
not strictlyBefore(access.getLocation(), variable.getLocation()) and
291+
not access.getLocation().strictlyBefore(variable.getLocation()) and
292292
// In case of overlapping parameter names, later parameters should not
293293
// be considered accesses to the first parameter
294294
if parameterAssignment(_, _, access)
@@ -358,7 +358,7 @@ private predicate inherits(Scope::Range scope, string name, Scope::Range outer)
358358
or
359359
exists(Ruby::Identifier i |
360360
scopeAssigns(outer, name, i) and
361-
strictlyBefore(i.getLocation(), scope.getLocation())
361+
i.getLocation().strictlyBefore(scope.getLocation())
362362
)
363363
)
364364
or

0 commit comments

Comments
 (0)