Skip to content

Commit 8905617

Browse files
committed
[UpdateTestChecks] Use common ir function name matcher and extend to accept periods in names (PR37586)
Remove the local versions of the IR_FUNCTION_RE matcher (they weren't doing anything different), and ensure all the function name matchers accept '.' and '-'. We don't need to use '\.' inside python regex sets either, or '\-' as long as thats at the end of the set.
1 parent 180d211 commit 8905617

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

llvm/utils/UpdateTestChecks/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ def invoke_tool(exe, cmd_args, ir):
6767
UTC_ARGS_CMD = re.compile(r'.*' + UTC_ARGS_KEY + '\s*(?P<cmd>.*)\s*$')
6868

6969
OPT_FUNCTION_RE = re.compile(
70-
r'^\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w-]+?)\s*'
71-
r'(?P<args_and_sig>\((\)|(.*?[\w\.\-]+?)\))[^{]*)\{\n(?P<body>.*?)^\}$',
70+
r'^\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w.-]+?)\s*'
71+
r'(?P<args_and_sig>\((\)|(.*?[\w.-]+?)\))[^{]*)\{\n(?P<body>.*?)^\}$',
7272
flags=(re.M | re.S))
7373

7474
ANALYZE_FUNCTION_RE = re.compile(
75-
r'^\s*\'(?P<analysis>[\w\s-]+?)\'\s+for\s+function\s+\'(?P<func>[\w-]+?)\':'
75+
r'^\s*\'(?P<analysis>[\w\s-]+?)\'\s+for\s+function\s+\'(?P<func>[\w.-]+?)\':'
7676
r'\s*\n(?P<body>.*)$',
7777
flags=(re.X | re.S))
7878

79-
IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@([\w.]+)\s*\(')
79+
IR_FUNCTION_RE = re.compile(r'^\s*define\s+(?:internal\s+)?[^@]*@([\w.-]+)\s*\(')
8080
TRIPLE_IR_RE = re.compile(r'^\s*target\s+triple\s*=\s*"([^"]+)"$')
8181
TRIPLE_ARG_RE = re.compile(r'-mtriple[= ]([^ ]+)')
8282
MARCH_ARG_RE = re.compile(r'-march[= ]([^ ]+)')
@@ -215,7 +215,7 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too
215215

216216
# Match things that look at identifiers, but only if they are followed by
217217
# spaces, commas, paren, or end of the string
218-
IR_VALUE_RE = re.compile(r'(\s+)%([\w\.\-]+?)([,\s\(\)]|\Z)')
218+
IR_VALUE_RE = re.compile(r'(\s+)%([\w.-]+?)([,\s\(\)]|\Z)')
219219

220220
# Create a FileCheck variable name based on an IR name.
221221
def get_value_name(var):

llvm/utils/update_analyze_test_checks.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@
4545

4646
ADVERT = '; NOTE: Assertions have been autogenerated by '
4747

48-
# RegEx: this is where the magic happens.
49-
50-
IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@([\w-]+)\s*\(')
51-
5248
def main():
5349
from argparse import RawTextHelpFormatter
5450
parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
@@ -168,7 +164,7 @@ def main():
168164
# If it's outside a function, it just gets copied to the output.
169165
output_lines.append(input_line)
170166

171-
m = IR_FUNCTION_RE.match(input_line)
167+
m = common.IR_FUNCTION_RE.match(input_line)
172168
if not m:
173169
continue
174170
func_name = m.group(1)

llvm/utils/update_test_checks.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@
4545

4646
ADVERT = '; NOTE: Assertions have been autogenerated by '
4747

48-
# RegEx: this is where the magic happens.
49-
50-
IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@([\w-]+)\s*\(')
51-
52-
53-
54-
55-
5648
def main():
5749
from argparse import RawTextHelpFormatter
5850
parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
@@ -203,7 +195,7 @@ def main():
203195
# If it's outside a function, it just gets copied to the output.
204196
output_lines.append(input_line)
205197

206-
m = IR_FUNCTION_RE.match(input_line)
198+
m = common.IR_FUNCTION_RE.match(input_line)
207199
if not m:
208200
continue
209201
func_name = m.group(1)

0 commit comments

Comments
 (0)