[llvm] [clang] Fix python escapes (PR #71170)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 3 09:30:34 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nathan Sidwell (urnathan)

<details>
<summary>Changes</summary>

With Fedora 39, I encountered 2 new python warnings:

/home/nathan/gh/llvm/push/strict-aliasing/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py:28: SyntaxWarning: invalid escape sequence '\*'
  self.implementationContent += """

/home/nathan/gh/llvm/push/strict-aliasing/llvm/test/lit.cfg.py:274: SyntaxWarning: invalid escape sequence '\d'
  match = re.search("release (\d+)\.(\d+)", ptxas_out)

Use raw strings here. I guess python got pickier or something?


---
Full diff: https://github.com/llvm/llvm-project/pull/71170.diff


2 Files Affected:

- (modified) clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py (+1-1) 
- (modified) llvm/test/lit.cfg.py (+1-1) 


``````````diff
diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index dafb332961ede86..7671f9691c09610 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -25,7 +25,7 @@ def __init__(self, templateClasses):
 
     def GeneratePrologue(self):
 
-        self.implementationContent += """
+        self.implementationContent += r"""
 /*===- Generated file -------------------------------------------*- C++ -*-===*\
 |*                                                                            *|
 |* Introspection of available AST node SourceLocations                        *|
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..5f4cff424f073b8 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -271,7 +271,7 @@ def ptxas_version(ptxas):
     ptxas_cmd = subprocess.Popen([ptxas, "--version"], stdout=subprocess.PIPE)
     ptxas_out = ptxas_cmd.stdout.read().decode("ascii")
     ptxas_cmd.wait()
-    match = re.search("release (\d+)\.(\d+)", ptxas_out)
+    match = re.search(r"release (\d+)\.(\d+)", ptxas_out)
     if match:
         return (int(match.group(1)), int(match.group(2)))
     print("couldn't determine ptxas version")

``````````

</details>


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


More information about the cfe-commits mailing list