Skip to content

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Oct 16, 2025

Add explicit condition basic blocks in the control flow graph for logical
expressions and logical assignment operators. This improves CFG accuracy by
representing condition evaluation as distinct nodes.

Changes:

  • Create condition basic blocks before evaluating left operands of logical expressions (&&, ||, ??)
  • Record and attach AST nodes to condition blocks for better traceability
  • Add edges from preceding blocks to condition blocks
  • Apply same treatment to logical assignment operators (&&=, ||=, ??=)

This affects CFG generation for:

  • LogicalExpression nodes
  • AssignmentExpression nodes with logical operators

@github-actions github-actions bot added A-semantic Area - Semantic C-bug Category - Bug labels Oct 16, 2025
Copy link
Contributor Author

camc314 commented Oct 16, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@camc314 camc314 marked this pull request as ready for review October 16, 2025 15:37
@camc314 camc314 requested a review from Dunqing as a code owner October 16, 2025 15:37
Copilot AI review requested due to automatic review settings October 16, 2025 15:37
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 16, 2025

CodSpeed Performance Report

Merging #14671 will not alter performance

Comparing c/10-16-fix_semantic_add_condition_basic_blocks_to_cfg_for_logical_expressions (2ce7edd) with main (d161729)

Summary

✅ 37 untouched

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 enhances the control flow graph (CFG) generation for logical expressions by adding explicit condition basic blocks. Previously, logical expressions (&&, ||, ??) and their assignment operator equivalents (&&=, ||=, ??=) lacked distinct condition nodes in the CFG, which reduced traceability and accuracy.

Key changes:

  • Added condition basic blocks before evaluating left operands of logical expressions
  • Extended the same treatment to logical assignment operators
  • Updated CFG snapshots to reflect the new basic block structure

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

File Description
crates/oxc_semantic/src/builder.rs Core implementation adding condition block creation and edge connections for logical expressions and assignments
crates/oxc_semantic/tests/integration/snapshots/*.snap Updated test snapshots reflecting additional basic blocks and edges in CFG output

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

camc314

This comment was marked as resolved.

@camc314 camc314 assigned camc314 and unassigned Dunqing Oct 17, 2025
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Oct 17, 2025
Copy link
Contributor Author

camc314 commented Oct 17, 2025

Merge activity

…ons (#14671)

Add explicit condition basic blocks in the control flow graph for logical
expressions and logical assignment operators. This improves CFG accuracy by
representing condition evaluation as distinct nodes.

Changes:
- Create condition basic blocks before evaluating left operands of logical expressions (&&, ||, ??)
- Record and attach AST nodes to condition blocks for better traceability
- Add edges from preceding blocks to condition blocks
- Apply same treatment to logical assignment operators (&&=, ||=, ??=)

This affects CFG generation for:
- LogicalExpression nodes
- AssignmentExpression nodes with logical operators
@graphite-app graphite-app bot force-pushed the c/10-16-fix_semantic_add_condition_basic_blocks_to_cfg_for_logical_expressions branch from 2ce7edd to cdf2d07 Compare October 17, 2025 10:46
@graphite-app graphite-app bot merged commit cdf2d07 into main Oct 17, 2025
20 checks passed
@graphite-app graphite-app bot deleted the c/10-16-fix_semantic_add_condition_basic_blocks_to_cfg_for_logical_expressions branch October 17, 2025 10:52
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants