[llvm] r327082 - utils: add a helper class to lit for captured substitutions

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 16:06:10 PST 2018


Author: compnerd
Date: Thu Mar  8 16:06:10 2018
New Revision: 327082

URL: http://llvm.org/viewvc/llvm-project?rev=327082&view=rev
Log:
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.

Modified:
    llvm/trunk/utils/lit/lit/TestingConfig.py

Modified: llvm/trunk/utils/lit/lit/TestingConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestingConfig.py?rev=327082&r1=327081&r2=327082&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestingConfig.py (original)
+++ llvm/trunk/utils/lit/lit/TestingConfig.py Thu Mar  8 16:06:10 2018
@@ -152,3 +152,22 @@ class TestingConfig:
         else:
             return self.parent.root
 
+class SubstituteCaptures:
+    """
+    Helper class to indicate that the substitutions contains backreferences.
+
+    This can be used as the following in lit.cfg to mark subsitutions as having
+    back-references::
+
+        config.substutions.append(('\b[^ ]*.cpp', SubstituteCaptures('\0.txt')))
+
+    """
+    def __init__(self, substitution):
+        self.substitution = substitution
+
+    def replace(self, pattern, replacement):
+        return self.substitution
+
+    def __str__(self):
+        return self.substitution
+




More information about the llvm-commits mailing list