Repository navigation
// llgo:link => //llgo:link - #1106
Conversation
There was a problem hiding this comment.
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:140emits{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 Cis 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.gohas fixed//llgo:linklines next to still-spaced// llgo:type Clines). Recommend changing line 140 to"\n//llgo:type C"and regenerating affected golden outputs, or if the spaced form is intentional, correcting the comments atcl/vtable.go:36and:131-134that describe it as a load-bearing directive.
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.