[PATCH] D22454: FileCheck Enhancement - repeats in regular expressions
Elena Lepilkina via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 18 01:22:38 PDT 2016
eklepilkina created this revision.
eklepilkina added reviewers: jyknight, vsk, dblaikie, dexonsmith, probinson.
eklepilkina added subscribers: aprantl, llvm-commits.
eklepilkina changed the edit policy of this Differential Revision from "All Users" to "Administrators".
Repeat with current number should become available by using {n}, {n,m} , {,n}, {n,}
https://reviews.llvm.org/D22454
Files:
docs/CommandGuide/FileCheck.rst
test/FileCheck/repeat-in-regex.txt
utils/FileCheck/FileCheck.cpp
Index: utils/FileCheck/FileCheck.cpp
===================================================================
--- utils/FileCheck/FileCheck.cpp
+++ utils/FileCheck/FileCheck.cpp
@@ -237,6 +237,14 @@
return true;
}
+ // Find end of pattern in case of quantifiers of the form {n,m}
+ size_t NextChar = End + 2;
+ while (NextChar < PatternStr.size() && PatternStr[NextChar] == '}') {
+ NextChar++;
+ }
+
+ End = NextChar - 2;
+
// Enclose {{}} patterns in parens just like [[]] even though we're not
// capturing the result for any purpose. This is required in case the
// expression contains an alternation like: CHECK: abc{{x|z}}def. We
Index: test/FileCheck/repeat-in-regex.txt
===================================================================
--- /dev/null
+++ test/FileCheck/repeat-in-regex.txt
@@ -0,0 +1,13 @@
+// RUN: FileCheck -input-file %s %s
+
+text to be matchedmatchedmatchedmatchedmatched
+// CHECK: {{(matched){5}}}
+
+r1, is register is register is register is register is register
+// CHECK: [[REG:r[0-9]{1,2}]]
+// CHECK-SAME: {{(is register ){1,}}}
+
+r2r13r1
+dag
+// CHECK-DAG: {{dag{1}}}
+// CHECK-DAG: {{[[REG]]{0,2}}}
Index: docs/CommandGuide/FileCheck.rst
===================================================================
--- docs/CommandGuide/FileCheck.rst
+++ docs/CommandGuide/FileCheck.rst
@@ -480,3 +480,19 @@
letting us set the :program:`FileCheck` variable ``DLOC`` to the desired value
``0x00000233``, extracted from the line immediately preceding "``intd``".
+
+Repeat in regular expressions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can use quantifiers with numbers in regular expressions such as {n}, {n,m}, {n,}.
+For example:
+
+.. code-block:: llvm
+
+ // CHECK : {{matched{5}}}
+
+It’s equal to
+
+.. code-block:: llvm
+
+ // CHECK : {{matchedmatchedmatchedmatchedmatched}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22454.64284.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160718/3f1c74cd/attachment.bin>
More information about the llvm-commits
mailing list