From 52c510bfea20f4ff94ea9902a895284c8712d2b7 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 28 Jan 2026 16:41:37 +0000 Subject: [PATCH] Use shared `getScope` instead of `getRoot` --- go/ql/lib/semmle/go/controlflow/BasicBlocks.qll | 5 +---- go/ql/lib/semmle/go/dataflow/SSA.qll | 2 +- go/ql/lib/semmle/go/dataflow/SsaImpl.qll | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/go/ql/lib/semmle/go/controlflow/BasicBlocks.qll b/go/ql/lib/semmle/go/controlflow/BasicBlocks.qll index 4352312e1b8..43b8c7e8dd3 100644 --- a/go/ql/lib/semmle/go/controlflow/BasicBlocks.qll +++ b/go/ql/lib/semmle/go/controlflow/BasicBlocks.qll @@ -42,10 +42,7 @@ private module Input implements BB::InputSig { private module BbImpl = BB::Make; -class BasicBlock extends BbImpl::BasicBlock { - /** Gets the innermost function or file to which this basic block belongs. */ - ControlFlow::Root getRoot() { result = this.getScope() } -} +class BasicBlock = BbImpl::BasicBlock; class EntryBasicBlock = BbImpl::EntryBasicBlock; diff --git a/go/ql/lib/semmle/go/dataflow/SSA.qll b/go/ql/lib/semmle/go/dataflow/SSA.qll index 2c36051e3a7..69fffa393c1 100644 --- a/go/ql/lib/semmle/go/dataflow/SSA.qll +++ b/go/ql/lib/semmle/go/dataflow/SSA.qll @@ -144,7 +144,7 @@ class SsaDefinition extends TSsaDefinition { abstract string prettyPrintRef(); /** Gets the innermost function or file to which this SSA definition belongs. */ - ControlFlow::Root getRoot() { result = this.getBasicBlock().getRoot() } + ControlFlow::Root getRoot() { result = this.getBasicBlock().getScope() } /** Gets a textual representation of this element. */ string toString() { result = this.prettyPrintDef() } diff --git a/go/ql/lib/semmle/go/dataflow/SsaImpl.qll b/go/ql/lib/semmle/go/dataflow/SsaImpl.qll index a5db316b601..026c8114f9f 100644 --- a/go/ql/lib/semmle/go/dataflow/SsaImpl.qll +++ b/go/ql/lib/semmle/go/dataflow/SsaImpl.qll @@ -86,7 +86,7 @@ private module Internal { /** Holds if the `i`th node of `bb` in function `f` is an entry node. */ private predicate entryNode(FuncDef f, ReachableBasicBlock bb, int i) { - f = bb.getRoot() and + f = bb.getScope() and bb.getNode(i).isEntryNode() } @@ -94,7 +94,7 @@ private module Internal { * Holds if the `i`th node of `bb` in function `f` is a function call. */ private predicate callNode(FuncDef f, ReachableBasicBlock bb, int i) { - f = bb.getRoot() and + f = bb.getScope() and bb.getNode(i).(IR::EvalInstruction).getExpr() instanceof CallExpr }