Skip to content

C++: Replace recursive string builders with concat - #22836

Open
jketema wants to merge 1 commit into
github:mainfrom
jketema:refactor-cpp-recursive-string-concats
Open

jketema wants to merge 1 commit into
github:mainfrom
jketema:refactor-cpp-recursive-string-concats

Conversation

@jketema

@jketema jketema commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

This is all test code, so no need to run DCA.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the C++ label Oct 16, 2026
@jketema
jketema marked this pull request as ready for review October 16, 2026 13:40
@jketema
jketema requested a review from a team as a code owner October 16, 2026 13:40
Copilot AI max review requested due to automatic review settings October 16, 2026 13:40
@jketema jketema added the no-change-note-required This PR does not need a change note label Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The refactors preserve output formatting, with only optional cleanup remaining.

1 open finding
What changed in this PR

Simplifies C++ test-output and IR-printing helpers by replacing recursive string construction with concat.

Changes:

  • Use ordered concatenation for parameters, template arguments, and macro reasons.
  • Replace recursive star and padding builders with repetition aggregates.
File Description
cpp/​ql/​test/​library-tests/​sideEffects/​functions/​sideEffects.ql Concatenate function parameter types.
cpp/​ql/​test/​library-tests/​preprocessor/​macroinvocations/​getanaffectedelement.ql Concatenate sorted macro reasons.
cpp/​ql/​test/​library-tests/​dataflow/​dataflow-tests/​has-parameter-flow-out.ql Simplify indirection-star generation.
cpp/​ql/​test/​library-tests/​cpp11_g/​cfg.ql Concatenate template arguments.
cpp/​ql/​test/​library-tests/​blocks/​cpp/​code_blocks.ql Concatenate C++ block parameters.
cpp/​ql/​test/​library-tests/​blocks/​c/​code_blocks.ql Concatenate C block parameters.
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​implementation/​unaliased_ssa/​PrintIR.qll Simplify unaliased SSA padding.
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​implementation/​raw/​PrintIR.qll Simplify raw IR padding.
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​implementation/​aliased_ssa/​PrintIR.qll Simplify aliased SSA padding.

🧠 Review effort: Max


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

private string stars(int k) {
k = [0 .. max(DataFlow::Node n, int i | n.isFinalValueOfParameter(_, i) | i)] and
(if k = 0 then result = "" else result = "*" + stars(k - 1))
result = concat(int i | i in [1 .. k] | "*")

This branch has not been deployed

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

Labels

C++ no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants