From 6be7265da83af031e2f440600152b999ee0eae02 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 25 Mar 2026 14:00:27 +0000 Subject: [PATCH 1/2] Go: fix bad join order Previously the optimizer was, in some cases, making a table of the file corresponding to all locations and only then limiting to locations corresponding to diagnostics. This pragma forces it to start from a list of diagnostics, get the locations and then the files. --- go/ql/lib/semmle/go/DiagnosticsReporting.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/ql/lib/semmle/go/DiagnosticsReporting.qll b/go/ql/lib/semmle/go/DiagnosticsReporting.qll index c7d0b547a867..b062598aafca 100644 --- a/go/ql/lib/semmle/go/DiagnosticsReporting.qll +++ b/go/ql/lib/semmle/go/DiagnosticsReporting.qll @@ -21,7 +21,7 @@ private class Diagnostic extends @diagnostic { string getMessage() { diagnostics(this, _, _, result, _, _) } /** Gets the file that this error is associated with, if any. */ - File getFile() { result = this.getLocation().getFile() } + File getFile() { result = pragma[only_bind_into](this).getLocation().getFile() } /** Gets the location for this error. */ Location getLocation() { diagnostics(this, _, _, _, _, result) } From a1caae871310f5d3a0321117a74c5b22c3e412aa Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:49:41 +0000 Subject: [PATCH 2/2] Change pragma Co-authored-by: Anders Schack-Mulligen --- go/ql/lib/semmle/go/DiagnosticsReporting.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/ql/lib/semmle/go/DiagnosticsReporting.qll b/go/ql/lib/semmle/go/DiagnosticsReporting.qll index b062598aafca..d9617034f9f8 100644 --- a/go/ql/lib/semmle/go/DiagnosticsReporting.qll +++ b/go/ql/lib/semmle/go/DiagnosticsReporting.qll @@ -21,7 +21,7 @@ private class Diagnostic extends @diagnostic { string getMessage() { diagnostics(this, _, _, result, _, _) } /** Gets the file that this error is associated with, if any. */ - File getFile() { result = pragma[only_bind_into](this).getLocation().getFile() } + File getFile() { result = pragma[only_bind_out](this.getLocation()).getFile() } /** Gets the location for this error. */ Location getLocation() { diagnostics(this, _, _, _, _, result) }