Skip to content

cl: compileFuncOrMethod creatorCheck use ctx.cstyleToGo; mod: github.com/llarhub/clang-c v0.9.0 - #962

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

xushiwei merged 2 commits into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

@xushiwei xushiwei commented Oct 7, 2026

Copy link
Copy Markdown
Member

No description provided.

@xushiwei xushiwei changed the title cl: compileFuncOrMethod creatorCheck use ctx.cstyleToGo; mod: github.com/llarhub/clang-c v0.9.0 @xushiwei cl: compileFuncOrMethod creatorCheck use ctx.cstyleToGo; mod: github.com/llarhub/clang-c v0.9.0 Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.09%. Comparing base (08fbeff) to head (690938b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #962   +/-   ##
=======================================
  Coverage   88.08%   88.09%           
=======================================
  Files          23       23           
  Lines        2686     2687    +1     
=======================================
+ Hits         2366     2367    +1     
  Misses        320      320           
Flag Coverage Δ
llgo-tests 88.09% <100.00%> (+<0.01%) ⬆️

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.

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

Review: PR #962 — creatorCheck normalizes creator name via cstyleToGo

Summary. This PR adds one line in cl/func.go that routes the config-derived creator token through ctx.cstyleToGo(...) before it becomes the generated Go function/method name, plus a clang-c dependency bump (v0.8.0 → v0.9.0). The change is correct and safe to merge: it makes the creator path consistent with every other name-producing path in the tool (globalName, localName, varName, typeName, funcName all end in cstyleToGo), which previously was the lone path emitting raw rule text. For the existing Python test corpus the $N captures are already PascalCase, so cstyleToGo is a no-op and no golden output changes — verified cl builds cleanly against clang-c v0.9.0.

Verified:

  • go build ./cl/... succeeds; clang-c v0.9.0 resolves and downloads.
  • Dependency hashes checked against the Go checksum database: both the module-zip hash and the go.mod hash for v0.9.0 match sum.golang.org. The unchanged go.mod hash across v0.8.0→v0.9.0 is expected (module metadata didn't change) and benign — the zip hash still changed and would catch tampering.
  • No security concern: creator originates from the developer-authored NewCheck config (a local codegen trust model); normalization reduces the chance of malformed content landing in generated source, and a bad name produces non-compiling Go, not injection.
  • No performance concern: one bounded per-function string op on a codegen path.

The findings below are minor/consistency-level and non-blocking.

Additional findings

  • tool/config.go:42: [P3] NewCheck doc now understates behavior (creator names are normalized): NewCheck is documented only as "Type Creator Detection (optional). See .../issues/960." With this PR, the creator token in a rule (e.g. .As$1) is now run through cstyleToGo, so a token containing lowercase-initial segments, underscores, or :: is capitalized/camel-cased rather than emitted verbatim — a user-visible contract shift for rule authors not reflected in any comment or doc. Optional: add a one-line clarification here (e.g. "the creator name in the rule is normalized to a Go-style identifier, same conversion as other generated names") to keep the referenced documentation accurate.

Comment thread cl/func.go
if creator != "" {
if newResults, ok := tryNewResults(pkgTypes, obj, results); ok {
results = newResults
creator = ctx.cstyleToGo(creator, false, true)

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.

[P3] Co-locate creator normalization in name.go with creatorCheck

Every other Go-name derivation co-locates cstyleToGo with its derivation in cl/name.go (globalName, localName, varName, typeName, funcName all return a ready-to-use identifier). Here the token is derived in creatorCheck (name.go) but normalized in func.go, so the caller must remember to normalize. Consider moving this cstyleToGo call into creatorCheck (or a small creatorName helper) so it returns an already-normalized creator, matching the established pattern and keeping func.go focused on compilation logic. Non-blocking — current placement is functionally correct (it sits after results = newResults and before both fnName = creator consumers, and only runs when tryNewResults succeeds).

Comment thread cl/func.go
if creator != "" {
if newResults, ok := tryNewResults(pkgTypes, obj, results); ok {
results = newResults
creator = ctx.cstyleToGo(creator, false, true)

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.

[P3] underscoreStart hardcoded to false diverges from other callers

Every other cstyleToGo caller computes underscoreStart (via rmPrefixAndUnderscoreStart / checkUnderscoreStart) so a leading _ is preserved through goNameOf. This call pins it to false. For the intended use (an exported creator such as AsByteArray) false is correct, but if a $N wildcard expansion ever yields a creator starting with _, that underscore would be silently dropped unlike every other name path. Low probability given creators are author-controlled exported names. If false is intentional, a one-line comment stating creators are always treated as exported, non-underscore names would prevent a future reader from assuming it's a copy-paste oversight.

@xushiwei
xushiwei merged commit d8daab4 into goplus:main Oct 7, 2026
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