https://github.com/melver requested changes to this pull request. In general LGTM. But double-check if it doesn't introduce regression without -Wthread-safety-beta (see comment). https://github.com/llvm/llvm-project/pull/178952