Skip to content

Commit fa1bb82

Browse files
authored
Merge pull request #8610 from github/nickrolfe/re-fix-location-join-order
Ruby: undo accidental revert of #8538
2 parents 9675f34 + 10b75bf commit fa1bb82

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ruby/ql/lib/codeql/ruby/regexp/RegExpTreeView.qll

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,22 @@ class RegExpTerm extends RegExpParent {
194194
*/
195195
Location getLocation() { result = re.getLocation() }
196196

197+
pragma[noinline]
198+
private predicate componentHasLocationInfo(
199+
int i, string filepath, int startline, int startcolumn, int endline, int endcolumn
200+
) {
201+
re.getComponent(i)
202+
.getLocation()
203+
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
204+
}
205+
197206
/** Holds if this term is found at the specified location offsets. */
198207
predicate hasLocationInfo(
199208
string filepath, int startline, int startcolumn, int endline, int endcolumn
200209
) {
201210
exists(int re_start, int re_end |
202-
re.getComponent(0).getLocation().hasLocationInfo(filepath, startline, re_start, _, _) and
203-
re.getComponent(re.getNumberOfComponents() - 1)
204-
.getLocation()
205-
.hasLocationInfo(filepath, _, _, endline, re_end)
206-
|
211+
this.componentHasLocationInfo(0, filepath, startline, re_start, _, _) and
212+
this.componentHasLocationInfo(re.getNumberOfComponents() - 1, filepath, _, _, endline, re_end) and
207213
startcolumn = re_start + start and
208214
endcolumn = re_start + end - 1
209215
)

0 commit comments

Comments
 (0)