Skip to content

tool: cfg.Files; tool test: TestCpp_LLVMSystem - #878

Merged
xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:q
Sep 30, 2026
Merged

xushiwei merged 1 commit into
goplus:mainfrom
xushiwei:q

Conversation

@xushiwei

Copy link
Copy Markdown
Member

No description provided.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.32%. Comparing base (c4406d2) to head (a91158e).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
tool/gen.go 82.35% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #878      +/-   ##
==========================================
+ Coverage   86.65%   87.32%   +0.67%     
==========================================
  Files          22       22              
  Lines        1866     1878      +12     
==========================================
+ Hits         1617     1640      +23     
+ Misses        249      238      -11     
Flag Coverage Δ
llgo-tests 87.32% <82.35%> (+0.67%) ⬆️

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.

Code Review: PR #878 — selectable header files via Files config

This PR adds a Files config field so a package config can select specific header files instead of scanning the whole Dir, and threads an explicit pkgName through NewPackage (with a backward-compatible fallback to path.Base(cfg.Name)). The core change is clean and the selected-files path is a net performance win over the full TopHeaders scan (no directory walk, no per-header include parsing).

A few small, non-blocking points are noted inline. No security or performance regressions were found — the path-traversal note is defense-in-depth only, since llcppg.cfg is a locally trusted, same-author input for this codegen tool.

I also checked the pkgName[len(pkgPrefix):] slice in gen_test.go: pkgPrefix is captured from conf.Name before Apply prepends the parent name, so for llvm + /system it correctly yields "system" with no out-of-range risk. Not a bug.

Comment thread tool/gen.go
return
}

func listHeaderFiles(selFiles []string, headerDir string) (topHeaders []string) {

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.

listHeaderFiles passes each cfg.Files entry straight to filepath.Join(headerDir, selFile) with no validation or de-duplication. Two things differ from the pputil.TopHeaders path it replaces:

  • No dedup: TopHeaders iterates a map and is inherently unique; here a duplicate entry in Files produces a duplicate top header fed into ParseSources/cl.NewPackage.
  • No containment check: because filepath.Join cleans .. and strips a leading separator, entries like ../../foo.h or absolute paths resolve outside headerDir. For this local, trusted-config tool that's low risk, but rejecting absolute/escaping entries (and de-duping) would be a cheap hardening and keep the two code paths consistent.

Comment thread tool/gen.go
Comment thread tool/config.go
Comment thread tool/config.go
@xushiwei
xushiwei merged commit 1502b8f into goplus:main Sep 30, 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