Skip to content

Go: Recognize more non-returning logging functions#21929

Merged
owen-mc merged 12 commits into
github:mainfrom
owen-mc:go/no-ret-functions
Jun 2, 2026
Merged

Go: Recognize more non-returning logging functions#21929
owen-mc merged 12 commits into
github:mainfrom
owen-mc:go/no-ret-functions

Conversation

@owen-mc
Copy link
Copy Markdown
Contributor

@owen-mc owen-mc commented Jun 1, 2026

Also improve some tests, which will be useful for the new shared CFG as that doesn't make CFG nodes for non-reachable AST nodes.

Copilot AI review requested due to automatic review settings June 1, 2026 23:19
@owen-mc owen-mc requested a review from a team as a code owner June 1, 2026 23:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands Go’s modeling of non-returning / panicking logging APIs (stdlib log, glog/klog-style APIs, logrus, zap, and heuristic logger interfaces), and updates library tests and stubs to cover the new behavior (including avoiding reliance on unreachable AST nodes).

Changes:

  • Extend framework models to mark additional fatal/exit/panic logging functions as non-returning or panicking.
  • Update Go library-tests (expected outputs and logger-call fixtures) to reflect qualified names and additional logging API variants.
  • Bump the vendored github.com/golang/glog test dependency/stubs to v1.2.5 and expand stubs accordingly.
Show a summary per file
File Description
go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph/NoretFunctions.ql Switch test output to use qualified names for non-returning functions.
go/ql/test/library-tests/semmle/go/controlflow/ControlFlowGraph/NoretFunctions.expected Update expected results to match qualified naming and additional modeled functions.
go/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/modules.txt Update vendored module version for github.com/golang/glog.
go/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/k8s.io/klog/stub.go Expand klog stub surface (Level/Verbose and V()/Verbose methods) for tests.
go/ql/test/library-tests/semmle/go/concepts/LoggerCall/vendor/github.com/golang/glog/stub.go Expand glog stub surface (context variants, depth variants, V/VDepth, etc.) for tests.
go/ql/test/library-tests/semmle/go/concepts/LoggerCall/main.go Ensure glog test fixture is exercised/compiled by calling glogTest.
go/ql/test/library-tests/semmle/go/concepts/LoggerCall/go.mod Bump github.com/golang/glog dependency to v1.2.5 for the test module.
go/ql/test/library-tests/semmle/go/concepts/LoggerCall/glog.go Expand fixture calls to cover newly modeled glog/klog API variants and avoid unreachable-code dependence.
go/ql/lib/semmle/go/frameworks/Zap.qll Adjust zap fatal/panic modeling classes to use the shared zap function abstraction.
go/ql/lib/semmle/go/frameworks/stdlib/Log.qll Extend stdlib log modeling (formatters and Logger receiver methods) for non-returning behavior.
go/ql/lib/semmle/go/frameworks/Logrus.qll Add non-returning behavior modeling for fatal/panic-like logrus methods.
go/ql/lib/semmle/go/frameworks/Glog.qll Refine glog/klog family modeling (including context/depth variants and non-returning behavior).
go/ql/lib/semmle/go/Concepts.qll Factor heuristic logger modeling into a method class with non-returning/panic behavior hooks.
go/ql/lib/change-notes/2026-06-01-non-returning-functions.md Add change note describing expanded recognition of non-returning/panicking logging functions.

Copilot's findings

  • Files reviewed: 11/14 changed files
  • Comments generated: 1

Comment thread go/ql/lib/semmle/go/Concepts.qll
@owen-mc owen-mc force-pushed the go/no-ret-functions branch from 75cf6ff to 703cea2 Compare June 2, 2026 00:32
@owen-mc owen-mc merged commit aaa3b36 into github:main Jun 2, 2026
19 checks passed
@owen-mc owen-mc deleted the go/no-ret-functions branch June 2, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants