diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-09 21:23:09 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-09 21:23:09 +0000 |
commit | 909545a822eef491158f831688066f0ec2866938 (patch) | |
tree | 5b0bf0e81294007a9b462b21031b3df272c655c3 /utils | |
parent | 7e7b6700743285c0af506ac6299ddf82ebd434b9 (diff) |
Notes
Diffstat (limited to 'utils')
-rw-r--r-- | utils/unittest/CMakeLists.txt | 4 | ||||
-rwxr-xr-x | utils/update_test_checks.py | 51 |
2 files changed, 29 insertions, 26 deletions
diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt index dadca65b3aee6..16a3545127411 100644 --- a/utils/unittest/CMakeLists.txt +++ b/utils/unittest/CMakeLists.txt @@ -21,10 +21,10 @@ if(WIN32) add_definitions(-DGTEST_OS_WINDOWS=1) endif() -if(SUPPORTS_NO_VARIADIC_MACROS_FLAG) +if(SUPPORTS_VARIADIC_MACROS_FLAG) add_definitions("-Wno-variadic-macros") endif() -if(SUPPORTS_NO_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG) +if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG) add_definitions("-Wno-gnu-zero-variadic-macro-arguments") endif() if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG) diff --git a/utils/update_test_checks.py b/utils/update_test_checks.py index a7529af0109aa..92ab5ef6599cc 100755 --- a/utils/update_test_checks.py +++ b/utils/update_test_checks.py @@ -64,11 +64,13 @@ LLC_FUNCTION_RE = re.compile( flags=(re.M | re.S)) OPT_FUNCTION_RE = re.compile( r'^\s*define\s+(?:internal\s+)?[^@]*@(?P<func>[\w-]+?)\s*\(' - r'(\s+)?[^{]*\{\n(?P<body>.*?)^\}$', + r'(\s+)?[^)]*[^{]*\{\n(?P<body>.*?)^\}$', flags=(re.M | re.S)) CHECK_PREFIX_RE = re.compile('--check-prefix=(\S+)') CHECK_RE = re.compile(r'^\s*;\s*([^:]+?)(?:-NEXT|-NOT|-DAG|-LABEL)?:') -IR_VALUE_DEF_RE = re.compile(r'\s+%(.*) =') +# Match things that look at identifiers, but only if they are followed by +# spaces, commas, paren, or end of the string +IR_VALUE_RE = re.compile(r'(\s+)%(.+?)([,\s\(\)]|\Z)') # Invoke the tool that is being tested. @@ -156,33 +158,34 @@ def get_value_definition(var): def get_value_use(var): return '[[' + get_value_name(var) + ']]' - # Replace IR value defs and uses with FileCheck variables. def genericize_check_lines(lines): + # This gets called for each match that occurs in + # a line. We transform variables we haven't seen + # into defs, and variables we have seen into uses. + def transform_line_vars(match): + var = match.group(2) + if var in vars_seen: + rv = get_value_use(var) + else: + vars_seen.add(var) + rv = get_value_definition(var) + # re.sub replaces the entire regex match + # with whatever you return, so we have + # to make sure to hand it back everything + # including the commas and spaces. + return match.group(1) + rv + match.group(3) + + vars_seen = set() lines_with_def = [] - vars_seen = [] - for line in lines: + + for i, line in enumerate(lines): # An IR variable named '%.' matches the FileCheck regex string. line = line.replace('%.', '%dot') - m = IR_VALUE_DEF_RE.match(line) - if m: - vars_seen.append(m.group(1)) - line = line.replace('%' + m.group(1), get_value_definition(m.group(1))) - - lines_with_def.append(line) - - # A single def isn't worth replacing? - #if len(vars_seen) < 2: - # return lines - - output_lines = [] - vars_seen.sort(key=len, reverse=True) - for line in lines_with_def: - for var in vars_seen: - line = line.replace('%' + var, get_value_use(var)) - output_lines.append(line) - - return output_lines + # Ignore any comments, since the check lines will too. + scrubbed_line = SCRUB_IR_COMMENT_RE.sub(r'', line) + lines[i] = IR_VALUE_RE.sub(transform_line_vars, scrubbed_line) + return lines def add_checks(output_lines, prefix_list, func_dict, func_name, tool_basename): |