Skip to content

Commit 7956172

Browse files
committed
Add support for broader range of input files in generate-test-checks.py
1 parent e0c8fc7 commit 7956172

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

mlir/utils/generate-test-checks.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def process_attribute_references(line, attribute_namer):
227227
components = ATTR_RE.split(line)
228228
for component in components:
229229
m = ATTR_RE.match(component)
230-
if m:
230+
# Only use attribute alias if one exists.
231+
if m and attribute_namer.get_name(m.group(1)) != '?':
231232
output_line += '#[[' + attribute_namer.get_name(m.group(1)) + ']]'
232233
output_line += component[len(m.group()):]
233234
else:
@@ -237,9 +238,12 @@ def process_attribute_references(line, attribute_namer):
237238
# Pre-process a line of input to remove any character sequences that will be
238239
# problematic with FileCheck.
239240
def preprocess_line(line):
241+
# If input line has `{{` i.e. in a StrAttr with serialized proto.
242+
output_line = line.replace("{{", "{{\\{\\{}}")
243+
240244
# Replace any double brackets, '[[' with escaped replacements. '[['
241245
# corresponds to variable names in FileCheck.
242-
output_line = line.replace("[[", "{{\\[\\[}}")
246+
output_line = output_line.replace("[[", "{{\\[\\[}}")
243247

244248
# Replace any single brackets that are followed by an SSA identifier, the
245249
# identifier will be replace by a variable; Creating the same situation as
@@ -328,6 +332,11 @@ def main():
328332
if not input_line:
329333
continue
330334

335+
# When using `--starts_from_scope=0` to capture module lines, the file
336+
# split needs to be skipped, otherwise a `CHECK: // -----` is inserted.
337+
if input_line.startswith("// -----"):
338+
continue
339+
331340
# Check if this is an attribute definition and process it
332341
process_attribute_definition(input_line, attribute_namer, output)
333342

0 commit comments

Comments
 (0)