[clang] fix(clang/**.py): fix invalid escape sequences (PR #94029)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 04:32:04 PDT 2025


================
@@ -55,7 +55,7 @@ def run_test_once(args, extra_args):
     # themselves.  We need to keep the comments to preserve line numbers while
     # avoiding empty lines which could potentially trigger formatting-related
     # checks.
-    cleaned_test = re.sub("// *CHECK-[A-Z0-9\-]*:[^\r\n]*", "//", input_text)
+    cleaned_test = re.sub("// *CHECK-[A-Z0-9\\-]*:[^\r\n]*", "//", input_text)
----------------
NagyDonat wrote:

```suggestion
    cleaned_test = re.sub(r"// *CHECK-[A-Z0-9\-]*:[^\r\n]*", "//", input_text)
```
I would prefer switching to a raw string literal here -- it's functionally equivalent to your change and is more idiomatic to specify a regular expression as a raw string literal.

https://github.com/llvm/llvm-project/pull/94029


More information about the cfe-commits mailing list