[llvm] [Sample Profile] Expand functionality of llvm-profdata function filter (PR #101615)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 17:26:51 PDT 2024
ellishg wrote:
> > > Would you consider using globs (https://llvm.org/doxygen/classllvm_1_1GlobPattern.html) instead of regex? I believe globs are powerful enough for function names and they are much simpler to write/understand than regex. I'll leave it up to you.
> >
> >
> > I agree, I don't think we should be adding new uses of regular expressions unless absolutely necessary since they tend to be more error prone. In this case globs should be sufficient.
>
> No particular preference, but why should regular expression be avoided and why it is error prone? Do you mean there are different flavors of regexp to make it hard to use?
Regexes usually require excessive escaping, even though most of the features aren't used very often. For example, in a regex `.` will match any character and needs to be escaped to match the literal `.`, while in a glob it doesn't need to be escaped (`?` matches a single character in a glob). In SpecialCaseList, I remember there was some code to replace `*` with `.*` so users can have a glob-like experience, but this ended up confusing users.
Now that I've looked at your tests, I see the pattern `[0-9]+` to match any number. I'm not sure this can be expressed with globs currently. Is this test case important and useful?
https://github.com/llvm/llvm-project/pull/101615
More information about the llvm-commits
mailing list