mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-15 20:51:35 +00:00
Add a preprocess pass to remove sequences that are problematic with FileCheck
Add a preprocess phase to rewrite parts of the input line that may be problematic with filecheck. This change adds preprocessing to escape '[[' bracket sequences, as these are used by FileCheck for variables. PiperOrigin-RevId: 269648490
This commit is contained in:
parent
b991e8b1e4
commit
3e2ac62b7d
@ -98,6 +98,21 @@ def process_line(line_chunks, variable_namer):
|
||||
return output_line + '\n'
|
||||
|
||||
|
||||
# Pre-process a line of input to remove any character sequences that will be
|
||||
# problematic with FileCheck.
|
||||
def preprocess_line(line):
|
||||
# Replace any double brackets, '[[' with escaped replacements. '[['
|
||||
# corresponds to variable names in FileCheck.
|
||||
output_line = line.replace('[[', '{{\\[\\[}}')
|
||||
|
||||
# Replace any single brackets that are followed by an SSA identifier, the
|
||||
# identifier will be replace by a variable; Creating the same situation as
|
||||
# above.
|
||||
output_line = output_line.replace('[%', '{{\\[}}%')
|
||||
|
||||
return output_line
|
||||
|
||||
|
||||
def main():
|
||||
from argparse import RawTextHelpFormatter
|
||||
parser = argparse.ArgumentParser(
|
||||
@ -153,6 +168,10 @@ def main():
|
||||
if input_line[-1] == '{':
|
||||
variable_namer.push_name_scope()
|
||||
|
||||
# Preprocess the input to remove any sequences that may be problematic with
|
||||
# FileCheck.
|
||||
input_line = preprocess_line(input_line)
|
||||
|
||||
# Split the line at the each SSA value name.
|
||||
ssa_split = input_line.split('%')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user