summaryrefslogtreecommitdiffstats
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2019-07-29 17:41:00 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2019-07-29 17:41:00 +0000
commit45be5e477e9216363191a8ac9123bea4585cf14f (patch)
treeee9f1fbdc3bb70e7069ac62e253459819dcf98b0 /llvm/utils/UpdateTestChecks/common.py
parent72d00802d848e10ef1fc68564729d02d7a29546d (diff)
downloadbcm5719-llvm-45be5e477e9216363191a8ac9123bea4585cf14f.tar.gz
bcm5719-llvm-45be5e477e9216363191a8ac9123bea4585cf14f.zip
[UpdateTestChecks] Emit warning when invalid value for -check-prefix(es) option
Summary: The script is silent for the following issue: FileCheck %s -check-prefix=CHECK,POPCOUNT FileCheck will catch it later, but I think we can warn here too. Now it warns: ./update_llc_test_checks.py file.ll WARNING: Supplied prefix 'CHECK,POPCOUNT' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores. Did you mean --check-prefixes=CHECK,POPCOUNT? Reviewers: lebedev.ri, spatel, RKSimon, craig.topper, nikic, gbedwell Reviewed By: RKSimon Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64589 llvm-svn: 367244
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