mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-26 13:26:22 +00:00
[UpdateTestChecks][NFC] Share the code to get CHECK prefix between all scripts
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D143307
This commit is contained in:
parent
abbd4da204
commit
ae691c3812
@ -1142,6 +1142,12 @@ def check_prefix(prefix):
|
||||
warn(("Supplied prefix '%s' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores." + hint) %
|
||||
(prefix))
|
||||
|
||||
def get_check_prefixes(filecheck_cmd):
|
||||
check_prefixes = [item for m in CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
return check_prefixes
|
||||
|
||||
def verify_filecheck_prefixes(fc_cmd):
|
||||
fc_cmd_parts = fc_cmd.split()
|
||||
|
@ -83,11 +83,7 @@ def main():
|
||||
|
||||
tool_cmd_args = tool_cmd[len(opt_basename):].strip()
|
||||
tool_cmd_args = tool_cmd_args.replace('< %s', '').replace('%s', '').strip()
|
||||
|
||||
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
check_prefixes = common.get_check_prefixes(filecheck_cmd)
|
||||
|
||||
# FIXME: We should use multiple check prefixes to common check lines. For
|
||||
# now, we just ignore all but the last.
|
||||
|
@ -287,10 +287,7 @@ def main():
|
||||
run_list.append((None, exe, None, None))
|
||||
continue
|
||||
|
||||
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
check_prefixes = common.get_check_prefixes(filecheck_cmd)
|
||||
run_list.append((check_prefixes, clang_args, commands[1:-1], triple_in_cmd))
|
||||
|
||||
# Execute clang, generate LLVM IR, and extract functions.
|
||||
|
@ -98,10 +98,7 @@ def main():
|
||||
llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
|
||||
if ti.path.endswith('.mir'):
|
||||
llc_cmd_args += ' -x mir'
|
||||
check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
check_prefixes = common.get_check_prefixes(filecheck_cmd)
|
||||
|
||||
# FIXME: We should use multiple check prefixes to common check lines. For
|
||||
# now, we just ignore all but the last.
|
||||
|
@ -107,11 +107,7 @@ def _get_run_infos(run_lines, args):
|
||||
tool_cmd_args = tool_cmd[len(tool_basename):].strip()
|
||||
tool_cmd_args = tool_cmd_args.replace('< %s', '').replace('%s', '').strip()
|
||||
|
||||
check_prefixes = [item
|
||||
for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
check_prefixes = common.get_check_prefixes(filecheck_cmd)
|
||||
|
||||
run_infos.append((check_prefixes, tool_cmd_args))
|
||||
|
||||
|
@ -135,13 +135,7 @@ def build_run_list(test, run_lines, verbose=False):
|
||||
|
||||
cmd_args = llc_cmd[len('llc'):].strip()
|
||||
cmd_args = cmd_args.replace('< %s', '').replace('%s', '').strip()
|
||||
|
||||
check_prefixes = [
|
||||
item
|
||||
for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
check_prefixes = common.get_check_prefixes(filecheck_cmd)
|
||||
all_prefixes += check_prefixes
|
||||
|
||||
run_list.append(Run(check_prefixes, cmd_args, triple))
|
||||
|
@ -106,12 +106,7 @@ def main():
|
||||
|
||||
tool_cmd_args = tool_cmd[len(tool_basename):].strip()
|
||||
tool_cmd_args = tool_cmd_args.replace('< %s', '').replace('%s', '').strip()
|
||||
|
||||
check_prefixes = [item for m in
|
||||
common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
|
||||
for item in m.group(1).split(',')]
|
||||
if not check_prefixes:
|
||||
check_prefixes = ['CHECK']
|
||||
check_prefixes = common.get_check_prefixes(filecheck_cmd)
|
||||
|
||||
# FIXME: We should use multiple check prefixes to common check lines. For
|
||||
# now, we just ignore all but the last.
|
||||
|
Loading…
x
Reference in New Issue
Block a user