Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 1eeb11c

Browse files
committed
utils: add a helper class to lit for captured substitutions
On Windows, if the substitution contains a back reference, it would removed due to the replacement of the escape character in lit. Create a helper class to avoid this which will simply ignore the replacement and mark the substitution as having capture groups being referenced. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327082 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent cef3fe6 commit 1eeb11c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

utils/lit/lit/TestingConfig.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,22 @@ def root(self):
152152
else:
153153
return self.parent.root
154154

155+
class SubstituteCaptures:
156+
"""
157+
Helper class to indicate that the substitutions contains backreferences.
158+
159+
This can be used as the following in lit.cfg to mark subsitutions as having
160+
back-references::
161+
162+
config.substutions.append(('\b[^ ]*.cpp', SubstituteCaptures('\0.txt')))
163+
164+
"""
165+
def __init__(self, substitution):
166+
self.substitution = substitution
167+
168+
def replace(self, pattern, replacement):
169+
return self.substitution
170+
171+
def __str__(self):
172+
return self.substitution
173+

0 commit comments

Comments
 (0)