llvm.org GIT mirror llvm / 4fc3c08
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 Saleem Abdulrasool 2 years ago
1 changed file(s) with 19 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
151151 else:
152152 return self.parent.root
153153
154 class SubstituteCaptures:
155 """
156 Helper class to indicate that the substitutions contains backreferences.
157
158 This can be used as the following in lit.cfg to mark subsitutions as having
159 back-references::
160
161 config.substutions.append(('\b[^ ]*.cpp', SubstituteCaptures('\0.txt')))
162
163 """
164 def __init__(self, substitution):
165 self.substitution = substitution
166
167 def replace(self, pattern, replacement):
168 return self.substitution
169
170 def __str__(self):
171 return self.substitution
172