Skip to content

fix: omit the synthesized initializer for default-constructed variables#1239

Open
gennaroprota wants to merge 1 commit into
developfrom
fix/omit_the_synthesized_initializer_for_default_constructed_variables
Open

fix: omit the synthesized initializer for default-constructed variables#1239
gennaroprota wants to merge 1 commit into
developfrom
fix/omit_the_synthesized_initializer_for_default_constructed_variables

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Default-constructed variables (T t;) were rendered with a spurious initializer (= t). That's because Clang represents them with an implicit construction expression located at the variable name; so the extracted initializer text was the variable name itself.

Therefore, skip the initializer when it is an implicit default construction.

Closes issue #1238.

Changes

  • Source: ASTVisitor.cpp now skips the synthesized initializer provided by Clang when the variable is default-constructed.

Testing

A new golden test, with XML output, tests a handful of variable declarations.

Documentation

No documentation needed. This is a bug fix.

Default-constructed variables (`T t;`) were rendered with a spurious
initializer (`= t`). That's because Clang represents them with an
implicit construction expression located at the variable name; so the
extracted initializer text was the variable name itself.

Therefore, skip the initializer when it is an implicit default
construction.

Closes issue #1238.
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

✨ Highlights

  • 🧪 New golden tests added

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🥇 Golden Tests 92% 224 224 - 2 2 - - -
🛠️ Source 8% 20 19 1 1 - 1 - -
Total 100% 244 243 1 3 2 1 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • test-files/golden-tests/symbols/variable/default-constructed-instance.xml (Golden Tests): 211 lines Δ (+211 / -0)
  • src/lib/AST/ASTVisitor.cpp (Source): 20 lines Δ (+19 / -1)
  • test-files/golden-tests/symbols/variable/default-constructed-instance.cpp (Golden Tests): 13 lines Δ (+13 / -0)

Generated by 🚫 dangerJS against c0780e7

@gennaroprota gennaroprota linked an issue Jun 25, 2026 that may be closed by this pull request
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (197e765) to head (a405d1a).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1239   +/-   ##
========================================
  Coverage    83.16%   83.16%           
========================================
  Files           35       35           
  Lines         3658     3658           
  Branches       843      843           
========================================
  Hits          3042     3042           
  Misses         409      409           
  Partials       207      207           
Flag Coverage Δ
bootstrap 83.16% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot

cppalliance-bot commented Jun 25, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1239.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-06-25 16:35:42 UTC

@gennaroprota gennaroprota force-pushed the fix/omit_the_synthesized_initializer_for_default_constructed_variables branch 2 times, most recently from a405d1a to c0780e7 Compare June 25, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spurious initializer shown for default-constructed variables

2 participants