[clang] [clang-format] Add an fnmatch-like function for .clang-format-ignore (PR #76021)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 22 14:15:13 PST 2023


owenca wrote:

> Are we going to use this specific implementation on all platforms for parity?

Yes, similar to [this](https://github.com/owenca/llvm-project/commit/52866dcfe31cf5a43d86b27ec1f0420077034780#diff-0cfce704bac218438436bd4388319d112780509ea474d5b3253d45746a62713aR123).

> The logic on its own looks good as far as I can tell, but, for example, POSIX Section 2.13 mentions that a leading period (hidden files) isn't matched by `*`.

`matchFilePath(Pattern, FilePath)` is roughly equivalent to `!fnmatch(Pattern, FilePath, FNM_PATHNAME)`, similar to how I used `fnmatch()` [before](https://github.com/owenca/llvm-project/commit/efc1f1b582c014bdb2b5ef31d3fbafa77c143d05#diff-e3dfffecb8a56cc7fc60530acb5047c79903e66221d2b5b605f0486ac04c3cd3R629). To be consistent with the [spec](https://github.com/llvm/llvm-project/issues/52975#issuecomment-1848386526), I intentionally didn't use the `FNM_PERIOD` flag, which would prevent a leading period from being matched by `*`.

https://github.com/llvm/llvm-project/pull/76021


More information about the cfe-commits mailing list