Skip to content

C++: Fix IR for chained member access on temporaries - #22580

Open
MathiasVP wants to merge 3 commits into
github:mainfrom
MathiasVP:fix-ir-consistency
Open

MathiasVP wants to merge 3 commits into
github:mainfrom
MathiasVP:fix-ir-consistency

Conversation

@MathiasVP

Copy link
Copy Markdown
Contributor

Consider the test added in this PR:

get_wrapper().point.x

This PR fixes a case of invalid IR for chained field accesses where the qualifier is a prvalue.

Prvalue field accesses can require implicit loads without being having a lvalue-to-rvalue conversion from the extractor. On main IR construction recognizes these when inserting loads, but not when suppressing loads or deciding whether to materialize a temporary. As a result, get_wrapper().point generated both a TranslatedLoad and a TranslatedSyntheticTemporaryObject which was generating duplicated parents.

The fix is to treat implicit field loads like extractor-marked loads in both ignoreLoad and hasTranslatedSyntheticTemporaryObject.

@github-actions github-actions Bot added the C++ label Sep 15, 2026
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Sep 15, 2026
@MathiasVP
MathiasVP marked this pull request as ready for review September 15, 2026 23:08
Copilot AI balanced review requested due to automatic review settings September 15, 2026 23:08
@MathiasVP
MathiasVP requested a review from a team as a code owner September 15, 2026 23:08

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.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review tier: Lite (auto)
Findings: None

Note

Copilot is running an experiment and ran this review at Lite.

What changed in this PR

Fixes invalid IR for chained member access on prvalue temporaries.

Changes:

  • Corrects implicit field-load and synthetic-temporary handling.
  • Adds regression coverage for get_wrapper().point.x.
  • Updates IR and AST expectations.
File Description
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​implementation/​raw/​internal/​TranslatedElement.qll Adjusts load suppression and temporary materialization.
cpp/​ql/​test/​library-tests/​ir/​ir/​ir.cpp Adds the chained-access regression case.
cpp/​ql/​test/​library-tests/​ir/​ir/​raw_ir.expected Updates raw IR expectations.
cpp/​ql/​test/​library-tests/​ir/​ir/​aliased_ir.expected Updates aliased IR expectations.
cpp/​ql/​test/​library-tests/​ir/​ir/​PrintAST.expected Updates AST expectations.

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

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