summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Regex.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Regex: Make "match" and "sub" const member functionsThomas Preud'homme2019-09-241-12/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 372764
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Fix compilation on Darwin with expensive checks.Jonas Devlieghere2018-03-121-5/+10
| | | | | | | | | | | | | | | | | | After r327219 was landed, the bot with expensive checks on GreenDragon started failing. The problem was missing symbols `regex_t` and `regmatch_t` in `xlocale/_regex.h`. The latter was included because after the change in r327219, `random` is needed, which transitively includes `xlocale.h.` which in turn conditionally includes `xlocale/_regex.h` when _REGEX_H_ is defined. Because this is the header guard in `regex_impl.h` and because `regex_impl.h` was included before the other LLVM includes, `xlocale/_regex.h` was included without the necessary types being available. This commit fixes this by moving the include of `regex_impl.h` all the way down. I also added a comment to stress the significance of its position. llvm-svn: 327256
* Add const to a const method. NFCGeorge Burgess IV2017-04-181-1/+1
| | | | llvm-svn: 300520
* [Support] - Fix possible crash in match() of llvm::Regex.George Rimar2016-09-021-0/+10
| | | | | | | | | | | | Crash was possible if match() method was called on object that was moved or object created with empty constructor. Testcases updated. DIfferential revision: https://reviews.llvm.org/D24123 llvm-svn: 280473
* [Support] Fix a warning introduced in r280339 due to the memberChandler Carruth2016-09-011-1/+1
| | | | | | | | | | | | initializers not being in the same order as the members. Specifically, 'preg' is the first member followed by 'error', so they will be initialized in that order and should be written in the member initializer list in that order. For the constructor in question, there is no change in behavior. llvm-svn: 280345
* [LLVM/Support] - Create no-arguments constructor for llvm::RegexGeorge Rimar2016-09-011-0/+2
| | | | | | | | | This is useful when need to defer the construction, e.g. using Regex as a member of class. Differential revision: https://reviews.llvm.org/D24101 llvm-svn: 280339
* Remove more superfluous .str() and replace std::string concatenation with Twine.Yaron Keren2015-03-301-1/+2
| | | | | | Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev. llvm-svn: 233555
* Purge unused includes throughout libSupport.Benjamin Kramer2015-03-231-2/+1
| | | | | | NFC. llvm-svn: 232976
* [C++11] Make use of 'nullptr' in the Support library.Craig Topper2014-04-071-1/+1
| | | | llvm-svn: 205697
* Make llvm::Regex non-copyable but movable.David Blaikie2014-01-021-2/+4
| | | | | | Based on a patch by Maciej Piechotka. llvm-svn: 198334
* Add missing escape characters to the new Regex::escape() functionAlp Toker2013-12-121-21/+6
| | | | | | | | | The old AddFixedStringToRegEx() it was based on got away with this for the longest time, but the problem became easy to spot after the cleanup in r197096. Also add a quick unit test to cover regex escaping. llvm-svn: 197121
* Expose FileCheck's AddFixedStringToRegEx as Regex::escapeHans Wennborg2013-12-121-0/+29
| | | | | | | Both FileCheck and clang's -verify need to escape strings for regexes, so let's expose this as a utility in the Regex class. llvm-svn: 197096
* Fix off-by-one error in Regex::isValidAlexey Samsonov2013-08-081-1/+1
| | | | llvm-svn: 187992
* Introduce Regex::isLiteralERE function.Peter Collingbourne2013-08-051-0/+7
| | | | | | | | | This will be used to implement an optimisation for literal entries in special case lists. Differential Revision: http://llvm-reviews.chandlerc.com/D1278 llvm-svn: 187731
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+2
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Add backreference matching capabilities to Support/Regex, withEli Bendersky2012-11-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | appropriate unit tests. This change in itself is not expected to affect any functionality at this point, but it will serve as a stepping stone to improve FileCheck's variable matching capabilities. Luckily, our regex implementation already supports backreferences, although a bit of hacking is required to enable it. It supports both Basic Regular Expressions (BREs) and Extended Regular Expressions (EREs), without supporting backrefs for EREs, following POSIX strictly in this respect. And EREs is what we actually use (rightly). This is contrary to many implementations (including the default on Linux) of POSIX regexes, that do allow backrefs in EREs. Adding backref support to our EREs is a very simple change in the regcomp parsing code. I fail to think of significant cases where it would clash with existing things, and can bring more versatility to the regexes we write. There's always the danger of a backref in a specially crafted regex causing exponential matching times, but since we mainly use them for testing purposes I don't think it's a big problem. [it can also be placed behind a flag specific to FileCheck, if needed]. For more details, see: * http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-November/055840.html * http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20121126/156878.html llvm-svn: 168802
* regexes are allowed to match empty things, e.g. {{.*}} in filecheck.Chris Lattner2011-04-091-1/+1
| | | | llvm-svn: 129193
* Don't pass StringRef by reference.Benjamin Kramer2010-07-141-2/+2
| | | | llvm-svn: 108366
* Add Regex::sub, for doing regular expression substitution with backreferences.Daniel Dunbar2010-02-171-0/+76
| | | | llvm-svn: 96503
* remove support for "NoSub" from regex. It seems like a minor optimizationChris Lattner2009-09-261-15/+12
| | | | | | and makes the API more annoying. Add a Regex::getNumMatches() method. llvm-svn: 82877
* add and document regex support for FileCheck. You can now do stuff like:Chris Lattner2009-09-241-2/+3
| | | | | | | | ; CHECK: movl {{%e[a-z][xi]}}, %eax or whatever. llvm-svn: 82717
* tidy up, fix a memory leak in Regex::isValidChris Lattner2009-09-241-13/+10
| | | | llvm-svn: 82707
* Add regular expression matching support, based on OpenBSD regexec()/regcomp()Torok Edwin2009-08-301-0/+97
implementation. llvm-svn: 80493
OpenPOWER on IntegriCloud