Skip to content

Conversation

@jketema
Copy link
Contributor

@jketema jketema commented Nov 27, 2025

See the internal PR for further details.

Observe that the frontend now does less constant folding, which has an impact on cpp/constant-comparison. I've addressed this by excluding expressions from contexts where a constant is required. The programmer likely made a deliberate choice in that case and expects the comparison to be constant. DCA shows one new alert on Boost, which I have not been able to capture as a test case. QA does not show a significant change in alerts for cpp/constant-comparison with the changes made here.

@jketema jketema force-pushed the jketema/frontend-update branch 4 times, most recently from 55f33b7 to 809d440 Compare December 5, 2025 16:54
@jketema jketema force-pushed the jketema/frontend-update branch 4 times, most recently from a0260cc to 9e3d772 Compare December 11, 2025 14:47
@jketema jketema added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Dec 11, 2025
@jketema jketema force-pushed the jketema/frontend-update branch 2 times, most recently from 84743fd to 97afb1e Compare December 18, 2025 19:26
@jketema jketema force-pushed the jketema/frontend-update branch from 094636d to 18c9049 Compare January 2, 2026 16:29
@jketema jketema marked this pull request as ready for review January 3, 2026 14:51
@jketema jketema requested review from a team as code owners January 3, 2026 14:51
Copilot AI review requested due to automatic review settings January 3, 2026 14:51
Copy link
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 updates C++ test expectations following a frontend change that reduces constant folding behavior. The changes ensure that constant comparisons in required-constant contexts (static asserts, template arguments, constexpr initializers, and enum constants) are excluded from the cpp/constant-comparison query, as these represent deliberate programmer choices.

Key changes:

  • Updated compiler version support documentation (Clang 19.1.0 → 21, GCC 15.0 → 15)
  • Modified cpp/constant-comparison query to exclude comparisons in constant-required contexts
  • Updated test expectations across multiple test suites to reflect reduced constant folding

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
docs/codeql/reusables/supported-versions-compilers.rst Updated supported Clang and GCC versions
cpp/ql/test/query-tests/Likely Bugs/Arithmetic/PointlessComparison/RegressionTests.cpp Added test cases for comparisons in constant-required contexts
cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedLocals/code2.cpp Corrected comment about false positive (now fixed)
cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedLocals/UnusedLocals.expected Removed false positive for v2 used as template parameter
cpp/ql/test/query-tests/Best Practices/SloppyGlobal/SloppyGlobal.expected Updated location spans for global variables
cpp/ql/test/library-tests/templates/variables/template_variables.expected Updated location spans for template variable declarations
cpp/ql/test/library-tests/templates/isfromtemplateinstantiation/isfromuninstantiatedtemplate.expected Updated location spans for var_template
cpp/ql/test/library-tests/scopes/parents/parents.expected Updated location spans for template variable var
cpp/ql/test/library-tests/ir/ir/raw_ir.expected Reordered IR instructions for lambda field initialization
cpp/ql/test/library-tests/ir/ir/aliased_ir.expected Reordered aliased IR instructions for lambda field initialization
cpp/ql/test/library-tests/ir/ir/PrintAST.expected Added assignment operators and changed ValueCategory for x
cpp/ql/test/library-tests/constants/addresses/addresses.expected Added baseline for newly detected non-constant address expressions
cpp/ql/test/library-tests/constants/addresses/addresses.cpp Uncommented stmtexpr_int test case
cpp/ql/src/change-notes/2026-01-02-constant-comparison.md Added change note for query update
cpp/ql/src/Likely Bugs/Arithmetic/PointlessComparison.ql Added exclusions for constant-required contexts
cpp/ql/lib/change-notes/2026-01-02-constant-folding.md Added change note for constant folding behavior change

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant