[llvm] [clang] Fix python escapes (PR #71170)
Nathan Sidwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 04:44:26 PDT 2023
https://github.com/urnathan updated https://github.com/llvm/llvm-project/pull/71170
>From 9b5cb1ac8d4b9a2aaa4c06e41620e38b6c3cae8c Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Thu, 2 Nov 2023 18:14:05 -0400
Subject: [PATCH 1/2] Fix python escapes
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?
May as well fix the blank line caused by """NEWLINE
...
"""
---
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 4 ++--
llvm/test/lit.cfg.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index dafb332961ede86..54cfd0741f9d122 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 *|
@@ -58,7 +58,7 @@ def GeneratePrologue(self):
private:
std::vector<clang::TypeLoc> &TLRG;
};
-"""
+"""[1:]
def GenerateBaseGetLocationsDeclaration(self, CladeName):
InstanceDecoration = "*"
diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index ab245b71cdd16a5..cf050bbfe3b1413 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")
>From 0cf6eb5b293752525cace1dee1ba26e143386809 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell <nathan at acm.org>
Date: Fri, 3 Nov 2023 07:44:11 -0400
Subject: [PATCH 2/2] Lower case raw string
---
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py | 2 +-
llvm/test/lit.cfg.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index 54cfd0741f9d122..a6843f70adedae9 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 += R"""
+ 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 cf050bbfe3b1413..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(R"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")
More information about the llvm-commits
mailing list