[clang] [llvm] Make sanitizer special case list slash-agnostic (PR #149886)
Devon Loehr via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 6 15:56:21 PDT 2025
DKLoehr wrote:
> how to match "foo\[bar]" ?
I'm not sure if I'm interpreting the question correctly, but if you're asking about a file named `[bar]` in a directory `foo` on a windows, then:
1. With LLVM trunk, you would write `src:foo\\\[bar]` (I think you don't need to escape the `]`)
2. With the current PR, you would write `src:foo/\[bar]`, OR `src:foo\\\[bar]` if you know the path will be windows-style (it will fail to match unix-style paths)
3. If we canonicalized file names before matching them, you would have to write `src:foo/\[bar]` (`src:foo\\\[bar]` would not work, and you'd have to update your special case files to use the new syntax)
4. If we "canonicalized" globs, you could write either `src:foo/\[bar]` OR `src:foo\\\[bar]`, but the latter would also (incorrectly) match unix-style paths. This is ok as long as you're canonicalizing your paths, but if you apply it to something that isn't a path (or which shouldn't be canonicalized for some reason) then it's wrong.
Basically, if you manipulate the globs you're effectively adding a new rule that `\\` matches either `/` or `\`, but that contradicts with the existing rule that it should only match exactly `\`.
I'm entirely ok with option (3); it's simple to implement, simple to state how it works, and doesn't make the glob parser slower or more complicated. The downside is it puts burden on downstream folks to change their files to the new syntax.
That burden might not be that large, because it only applies to files which are windows-specific. If you support multiple platforms, you'll have to use a workaround anyway (in chromium we use `{\\,/}` to match either separator). So only a subset of people will actually be impacted, but I don't know how to evaluate that so I'd like to get opinions from more experienced community members.
https://github.com/llvm/llvm-project/pull/149886
More information about the llvm-commits
mailing list