[PATCH] D67241: Regex: Make "match" and "sub" const member functions

Nicolas Guillemot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 14:59:57 PDT 2019


nlguillemot created this revision.
nlguillemot added a reviewer: jankratochvil.
Herald added subscribers: llvm-commits, thopre, kristina, javed.absar.
Herald added a project: LLVM.

The Regex "match" and "sub" member functions were previously not "const"
because they wrote to the "error" member variable. This commit removes those
assignments, and instead assumes that the validity of the regex is already
 known after the initial compilation of the regular expression. As a result, these
member functions were possible to make "const". This makes it easier to do things like
pre-compile Regexes up-front, and makes "match" and "sub" thread-safe.
The error status is now returned as an optional output, which also makes the API of
"match" and "sub" more consistent with each other.

Also, some uses of Regex that could be refactored to be const were made const.


Repository:
  rL LLVM

https://reviews.llvm.org/D67241

Files:
  include/llvm/Support/Regex.h
  lib/IR/AutoUpgrade.cpp
  lib/Passes/PassBuilder.cpp
  lib/Support/FileCheck.cpp
  lib/Support/Regex.cpp
  lib/Target/AArch64/Utils/AArch64BaseInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67241.218988.patch
Type: text/x-patch
Size: 6913 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190905/41f39ed9/attachment.bin>


More information about the llvm-commits mailing list