Skip to content

// llgo:link => //llgo:link - #1106

Merged
xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q
Oct 26, 2026
Merged

xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

@fennoai fennoai Bot 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.

Summary

This PR changes the emitted llgo directive from // llgo:link (with a space) to //llgo:link (no space) in cl/func.go, updates the matching doc example in cl/doc.go, and regenerates all golden test outputs. The change is correct: Go-style compiler directives require no space between // and the directive name, otherwise the line is treated as an ordinary comment rather than a recognized directive. The regeneration is applied uniformly — a repo-wide search for the old // llgo:link (spaced) form returns zero matches, and directiveComments (cl/doc.go:177-186) preserves the no-space form on both the doc and no-doc paths. Security and performance review surfaced no issues.

One consistency gap below is worth addressing before merge.

Findings

[P2] cl/vtable.go:140 emits // llgo:type C with a space — same defect this PR fixes for llgo:link, left unfixed

cl/vtable.go:140 still emits {Text: "\n// llgo:type C"} with a space after //. This is the identical defect the PR corrects for //llgo:link: with the space, // llgo:type C is parsed as an ordinary comment, not an llgo directive, so the directive controlling the C vtable layout would not actually be applied. The inconsistency is now directly visible side-by-side in this PR's own regenerated output — e.g. cl/_testcpp/virtual_method/out.go has the fixed //llgo:link (lines 69, 74, 89, 94, 128) sitting next to the still-spaced // llgo:type C (lines 57, 78, 98, 115). Every other directive emitter in the package already uses the no-space form (//llgo:cdecl///llgo:stdcall at cl/doc.go:200,202; //go:linkname at cl/func.go:218).

Recommend changing line 140 to "\n//llgo:type C" and regenerating the affected golden outputs, so the fix is complete and internally consistent. If llgo:type with a space is intentional, the surrounding comments that describe it as a load-bearing directive (cl/vtable.go:36 and cl/vtable.go:131-134, which assert it "keeps the struct laid out exactly as the C++ vtable") should be corrected instead, since they would otherwise misdescribe actual behavior.

[P3] Stale doc references to the spaced form in cl/vtable.go

Independently of the code fix, cl/vtable.go:36 (annotated `// llgo:type C` ) and cl/vtable.go:131 (// `llgo:type C` keeps the struct...) quote the directive with a space, which is now inconsistent with the no-space convention this PR establishes in cl/doc.go:160. Worth updating alongside the fix above to avoid future contributors copying the spaced form.

Additional findings

  • /workspace/llcppg/cl/vtable.go:140: [P2] llgo:type C directive still emitted with a space: cl/vtable.go:140 emits {Text: "\n// llgo:type C"} with a space after //, which is the same defect this PR fixes for //llgo:link. With the space, // llgo:type C is treated as a plain comment, not an llgo directive, so the C vtable layout directive is not actually applied. This inconsistency is visible in this PR's own output (e.g. cl/_testcpp/virtual_method/out.go has fixed //llgo:link lines next to still-spaced // llgo:type C lines). Recommend changing line 140 to "\n//llgo:type C" and regenerating affected golden outputs, or if the spaced form is intentional, correcting the comments at cl/vtable.go:36 and :131-134 that describe it as a load-bearing directive.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.27%. Comparing base (e20afa5) to head (536a2c7).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
cl/doc.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1106   +/-   ##
=======================================
  Coverage   90.27%   90.27%           
=======================================
  Files          26       26           
  Lines        3279     3279           
=======================================
  Hits         2960     2960           
  Misses        319      319           
Flag Coverage Δ
llgo-tests 90.27% <75.00%> (ø)

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.

@xushiwei
xushiwei merged commit e9fad19 into goplus:main Oct 26, 2026
3 of 4 checks passed
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.

1 participant