Use glob instead of regex for SpecialCaseLists

I’ve just submitted ⚙ D154014 [SpecialCaseList] Use Globs instead of Regex for review which is a breaking change for special case lists (SCL) that greatly improves their usability. Here are the users of SCL that I could find:

  • Sanitizers (AddressSanitizer, ThreadSanitizer, MemorySanitizer, DataFlowSanitizer)
  • Clang and LLVM instrumentation
  • XRay
  • sancov
  • llvm-cov

The hope is that most of these uses only need to specify simple source files (*/src/foo.{c,cpp}) or functions (*_unsafe_*) which are easily specified with globs. Most of the functionality of regular expressions are not used for SCLs and in fact it may require excessive escaping. For example, the line .?(\-|\+)(\[|<)* is needed to match Objective-C functions with a regex, but as a glob it’s simply ?[-+][[>]*.

If anyone is using regular expressions in any of the above SCLs, they will need to be translated if this patch lands. So please let me know if anyone knows of a SCL that is difficult or impossible to migrate to using globs.

I think the main breakages are:

  • patterns using ( and ). Our users don’t have such patterns.
  • patterns using \. to mean a literal ., e.g. src:a\.c. Our users don’t use \. Such a pattern needs to changed to src:a.c (which used to match other files like axc)
  • patterns like src:a.pb.* that match other files like src:axpbx.c. This pattern can be changed to glob src:a?pb?*.

I think all of these are likely uncommon. While \. is technically the correct way to match a literal . before this patch, most people likely just use ..

In summary I think this patch is moving toward the right direction and making the patterns less error-prone.

I’ve just landed ⚙ D154014 [SpecialCaseList] Add option to use Globs instead of Regex to match patterns but it is no longer a breaking change. If the first line in the file is #!special-case-list-v2 then it will use Globs to parse the list, otherwise it will default to Regex. Eventually I want to remove Regex support to simplify implementation so users should update to the new version.

1 Like