diff options
author | Mircea Trofin <mtrofin@google.com> | 2020-12-16 10:20:12 -0800 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2020-12-16 21:12:06 -0800 |
commit | ed1e565aaff6a2b6ad9064bcc58c50a46100a836 (patch) | |
tree | 893cfe12b044b97839d5b3c3556862472e9de192 /llvm/utils/UpdateTestChecks/common.py | |
parent | 541e476fc0682e71d70f6cfc7a42592910acf2a5 (diff) | |
download | llvm-ed1e565aaff6a2b6ad9064bcc58c50a46100a836.zip llvm-ed1e565aaff6a2b6ad9064bcc58c50a46100a836.tar.gz llvm-ed1e565aaff6a2b6ad9064bcc58c50a46100a836.tar.bz2 |
[NFC] factor update test function test builder as a class
This allows us to have shared logic over multiple test runs, e.g. do we
have unused prefixes, or which function bodies have conflicting outputs
for a prefix appearing in different RUN lines.
This patch is just wrapping existing functionality, and replacing its uses.
A subsequent patch would then fold the current functionality into the newly
introduced class.
Differential Revision: https://reviews.llvm.org/D93413
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r-- | llvm/utils/UpdateTestChecks/common.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 21878e8..128792d 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -322,7 +322,32 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too func_dict[prefix][func] = function_body(scrubbed_body, scrubbed_extra, args_and_sig, attrs) func_order[prefix].append(func) - warn_on_failed_prefixes(func_dict) + +class FunctionTestBuilder: + def __init__(self, run_list, flags, scrubber_args): + self._verbose = flags.verbose + self._record_args = flags.function_signature + self._check_attributes = flags.check_attributes + self._scrubber_args = scrubber_args + self._func_dict = {} + self._func_order = {} + for tuple in run_list: + for prefix in tuple[0]: + self._func_dict.update({prefix:dict()}) + self._func_order.update({prefix: []}) + + def finish_and_get_func_dict(self): + warn_on_failed_prefixes(self._func_dict) + return self._func_dict + + def func_order(self): + return self._func_order + + def process_run_line(self, function_re, scrubber, raw_tool_output, prefixes): + build_function_body_dictionary(function_re, scrubber, self._scrubber_args, + raw_tool_output, prefixes, self._func_dict, + self._func_order, self._verbose, + self._record_args, self._check_attributes) ##### Generator of LLVM IR CHECK lines |