tool: cfg.Files; tool test: TestCpp_LLVMSystem - #878
Conversation
Codecov Report❌ Patch coverage is
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
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:
|
There was a problem hiding this comment.
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.
| return | ||
| } | ||
|
|
||
| func listHeaderFiles(selFiles []string, headerDir string) (topHeaders []string) { |
There was a problem hiding this comment.
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:
TopHeadersiterates a map and is inherently unique; here a duplicate entry inFilesproduces a duplicate top header fed intoParseSources/cl.NewPackage. - No containment check: because
filepath.Joincleans..and strips a leading separator, entries like../../foo.hor absolute paths resolve outsideheaderDir. 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.
No description provided.