]> granicus.if.org Git - llvm/commit
Regex: Make "match" and "sub" const member functions
authorThomas Preud'homme <thomasp@graphcore.ai>
Tue, 24 Sep 2019 14:42:36 +0000 (14:42 +0000)
committerThomas Preud'homme <thomasp@graphcore.ai>
Tue, 24 Sep 2019 14:42:36 +0000 (14:42 +0000)
commit2c032d2797d5dc7fa6574ab935212633f320441b
tree07c0643695d234ecf31164d36c51c061e6999329
parent3a0728c761fab367ed8b5d452fe22c978daca410
Regex: Make "match" and "sub" const member functions

Summary:
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.

Patch by Nicolas Guillemot

Reviewers: jankratochvil, thopre

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67241

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372764 91177308-0d34-0410-b5e6-96231b3b80d8
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