Repository navigation
C++: Ignore compiler-generated variables in unused-static-variable query - #22961
Merged
Merged
Conversation
Extend the unused static variable query test with a minimal variadic sum instantiated with empty and non-empty packs. Record the spurious alert on the compiler-generated empty-pack variable reported in #22931. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jketema
force-pushed
the
copilot/unused-static-empty-pack-22931
branch
from
October 30, 2026 14:49
bad7a6a to
b43b7c3
Compare
Exclude synthetic variables from cpp/unused-static-variable so empty parameter pack placeholders do not trigger alerts. Update the regression expectation and document the analysis change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jketema
marked this pull request as ready for review
October 30, 2026 15:09
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported, and the change targets false positives with corresponding regression coverage and documentation.
No open issues 🎉
What changed in this PR
Updates cpp/unused-static-variable to ignore compiler-generated variables, preventing false positives for synthetic placeholders created for empty abbreviated parameter packs.
Changes:
- Adds a C++20 regression test for empty and nonempty abbreviated parameter packs.
- Excludes compiler-generated variables from the unused-static-variable query.
- Adds a minor analysis change note.
| File | Description |
|---|---|
cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedStaticVariables/test.cpp |
Adds a C++20 regression case for abbreviated parameter packs. |
cpp/ql/src/change-notes/2026-10-30-unused-static-compiler-generated.md |
Documents the query behavior change. |
cpp/ql/src/Best Practices/Unused Entities/UnusedStaticVariables.ql |
Filters compiler-generated variables from query results. |
Review effort: Lite (auto)
geoffw0
approved these changes
Oct 30, 2026
geoffw0
left a comment
Contributor
There was a problem hiding this comment.
LGTM, but please check any result changes on DCA look reasonable before merging. 👍
Contributor
Author
|
Yup, will not merge until I've seen that the DCA results are good. |
Contributor
Author
|
DCA was uneventful. |
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.
Fixes #22931.
Exclude compiler-generated variables from
cpp/unused-static-variable. Our frontend creates a synthetic static variable as a placeholder for an empty function parameter pack; it is not user-declared storage and should not trigger an unused-variable alert.The first commit adds a minimal reproducer to the existing
UnusedStaticVariablestest, capturing the spurious alert. The second commit adds the exclusion, updates the expected result, and includes a change note.