summaryrefslogtreecommitdiffstats
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 0c78f7bee2d..336ccb9ba77 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -47,6 +47,7 @@ def invoke_tool(exe, cmd_args, ir):
RUN_LINE_RE = re.compile('^\s*[;#]\s*RUN:\s*(.*)$')
CHECK_PREFIX_RE = re.compile('--?check-prefix(?:es)?[= ](\S+)')
+PREFIX_RE = re.compile('^[a-zA-Z0-9_-]+$')
CHECK_RE = re.compile(r'^\s*[;#]\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:')
OPT_FUNCTION_RE = re.compile(
@@ -264,3 +265,27 @@ def add_ir_checks(output_lines, comment_marker, prefix_list, func_dict, func_nam
def add_analyze_checks(output_lines, comment_marker, prefix_list, func_dict, func_name):
check_label_format = '{} %s-LABEL: \'%s\''.format(comment_marker)
add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, check_label_format, False, True)
+
+
+def check_prefix(prefix):
+ if not PREFIX_RE.match(prefix):
+ hint = ""
+ if ',' in prefix:
+ hint = " Did you mean '--check-prefixes=" + prefix + "'?"
+ print(("WARNING: Supplied prefix '%s' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores." + hint) %
+ (prefix), file=sys.stderr)
+
+
+def verify_filecheck_prefixes(fc_cmd):
+ fc_cmd_parts = fc_cmd.split()
+ for part in fc_cmd_parts:
+ if "check-prefix=" in part:
+ prefix = part.split('=', 1)[1]
+ check_prefix(prefix)
+ elif "check-prefixes=" in part:
+ prefixes = part.split('=', 1)[1].split(',')
+ for prefix in prefixes:
+ check_prefix(prefix)
+ if prefixes.count(prefix) > 1:
+ print("WARNING: Supplied prefix '%s' is not unique in the prefix list." %
+ (prefix,), file=sys.stderr)
OpenPOWER on IntegriCloud