Go: Recognize more non-returning logging functions#21929
Merged
Conversation
Contributor
There was a problem hiding this comment.
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/glogtest 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
75cf6ff to
703cea2
Compare
BazookaMusic
approved these changes
Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.