From: Saleem Abdulrasool Date: Fri, 9 Mar 2018 00:06:10 +0000 (+0000) Subject: utils: add a helper class to lit for captured substitutions X-Git-Tag: android-x86-7.1-r4~4061 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4fc3c08f8805c54071f6fd8c384f93f14d1f1a47;p=android-x86%2Fexternal-llvm.git 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 --- diff --git a/utils/lit/lit/TestingConfig.py b/utils/lit/lit/TestingConfig.py index 80a848b8e94..713baa620a7 100644 --- a/utils/lit/lit/TestingConfig.py +++ b/utils/lit/lit/TestingConfig.py @@ -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 +