diff options
author | Joel E. Denny <jdenny.ornl@gmail.com> | 2021-06-21 15:53:57 -0400 |
---|---|---|
committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2021-06-21 17:01:17 -0400 |
commit | 2bfe0536e5143caad80f7a9691fa775cf451317b (patch) | |
tree | af9d7c85310c66b517ece73cec532b0dfa3848a0 /llvm/utils/UpdateTestChecks/common.py | |
parent | 4cf74469a0f58c01a7fcf140a028b2a68f71df58 (diff) | |
download | llvm-2bfe0536e5143caad80f7a9691fa775cf451317b.zip llvm-2bfe0536e5143caad80f7a9691fa775cf451317b.tar.gz llvm-2bfe0536e5143caad80f7a9691fa775cf451317b.tar.bz2 |
[UpdateCCTestChecks] Fix --replace-value-regex across RUN lines
Without this patch, llvm/utils/update_cc_test_checks.py fails to
perform `--replace-value-regex` replacements when two RUN lines
produce the same output and use the same single FileCheck prefix. The
problem is that replacements in a RUN line's output are not performed
until after comparing against previous RUN lines' output, where
replacements have already been performed. This patch fixes that.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D104566
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r-- | llvm/utils/UpdateTestChecks/common.py | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 80b0c84..3f3682c 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -351,27 +351,6 @@ class FunctionTestBuilder: for l in scrubbed_body.splitlines(): print(' ' + l, file=sys.stderr) for prefix in prefixes: - if func in self._func_dict[prefix]: - if (self._func_dict[prefix][func] is None or - str(self._func_dict[prefix][func]) != scrubbed_body or - self._func_dict[prefix][func].args_and_sig != args_and_sig or - self._func_dict[prefix][func].attrs != attrs): - if (self._func_dict[prefix][func] is not None and - self._func_dict[prefix][func].is_same_except_arg_names( - scrubbed_extra, - args_and_sig, - attrs)): - self._func_dict[prefix][func].scrub = scrubbed_extra - self._func_dict[prefix][func].args_and_sig = args_and_sig - continue - else: - # This means a previous RUN line produced a body for this function - # that is different from the one produced by this current RUN line, - # so the body can't be common accross RUN lines. We use None to - # indicate that. - self._func_dict[prefix][func] = None - continue - # Replace function names matching the regex. for regex in self._replace_value_regex: # Pattern that matches capture groups in the regex in leftmost order. @@ -394,7 +373,29 @@ class FunctionTestBuilder: func_repl = group_regex.sub(re.escape(g), func_repl, count=1) # Substitute function call names that match the regex with the same # capture groups set. - scrubbed_body = re.sub(func_repl, '{{' + func_repl + '}}', scrubbed_body) + scrubbed_body = re.sub(func_repl, '{{' + func_repl + '}}', + scrubbed_body) + + if func in self._func_dict[prefix]: + if (self._func_dict[prefix][func] is None or + str(self._func_dict[prefix][func]) != scrubbed_body or + self._func_dict[prefix][func].args_and_sig != args_and_sig or + self._func_dict[prefix][func].attrs != attrs): + if (self._func_dict[prefix][func] is not None and + self._func_dict[prefix][func].is_same_except_arg_names( + scrubbed_extra, + args_and_sig, + attrs)): + self._func_dict[prefix][func].scrub = scrubbed_extra + self._func_dict[prefix][func].args_and_sig = args_and_sig + continue + else: + # This means a previous RUN line produced a body for this function + # that is different from the one produced by this current RUN line, + # so the body can't be common accross RUN lines. We use None to + # indicate that. + self._func_dict[prefix][func] = None + continue self._func_dict[prefix][func] = function_body( scrubbed_body, scrubbed_extra, args_and_sig, attrs) |