From ef6e973831b74ef4a7722a96a4f9dd37742ec88e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 31 Mar 2026 09:07:37 +0000 Subject: [PATCH] Fix compiler errors and warnings: remove redundant type checks and isIn guards, mark implicitFieldSelection as additional Agent-Logs-Url: https://github.com/github/codeql/sessions/8d96128c-44db-4ba1-9eca-1a5b37f54442 Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com> --- .../semmle/go/controlflow/ControlFlowGraphShared.qll | 2 +- go/ql/lib/semmle/go/controlflow/IR.qll | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll index 389274be215..c92ede1e9b9 100644 --- a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll +++ b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll @@ -524,7 +524,7 @@ module GoCfg { private predicate notBlankIdent(Go::Expr e) { not e instanceof Go::BlankIdent } /** Helper: implicit field selection for promoted selectors */ - predicate implicitFieldSelection(Ast::AstNode e, int index, Go::Field implicitField) { + additional predicate implicitFieldSelection(Ast::AstNode e, int index, Go::Field implicitField) { exists(Go::StructType baseType, Go::PromotedField child, int implicitFieldDepth | baseType = e.(Go::PromotedSelector).getSelectedStructType() and ( diff --git a/go/ql/lib/semmle/go/controlflow/IR.qll b/go/ql/lib/semmle/go/controlflow/IR.qll index 0dd57d11c7d..0a2b07859ff 100644 --- a/go/ql/lib/semmle/go/controlflow/IR.qll +++ b/go/ql/lib/semmle/go/controlflow/IR.qll @@ -26,9 +26,9 @@ module IR { or this.isAdditional(_, _) or - this.isAfterTrue(_) and not this.isIn(_) + this.isAfterTrue(_) or - this.isAfterFalse(_) and not this.isIn(_) + this.isAfterFalse(_) } /** Holds if this instruction reads the value of variable or constant `v`. */ @@ -164,9 +164,9 @@ module IR { /** A condition guard instruction, representing a known boolean outcome for a condition. */ private class ConditionGuardInstruction extends Instruction { ConditionGuardInstruction() { - this.isAfterTrue(_) and not this.isIn(_) + this.isAfterTrue(_) or - this.isAfterFalse(_) and not this.isIn(_) + this.isAfterFalse(_) } } @@ -176,7 +176,7 @@ module IR { class EvalInstruction extends Instruction { Expr e; - EvalInstruction() { this.isIn(e) and e instanceof Expr } + EvalInstruction() { this.isIn(e) } /** Gets the expression underlying this instruction. */ Expr getExpr() { result = e } @@ -778,7 +778,7 @@ module IR { class DeclareFunctionInstruction extends Instruction { FuncDecl fd; - DeclareFunctionInstruction() { this.isIn(fd) and fd instanceof FuncDecl } + DeclareFunctionInstruction() { this.isIn(fd) } override Type getResultType() { result = fd.getType() } }