This revision was automatically updated to reflect the committed changes. Closed by commit rG2f5b2ea6cd85: [UpdateCCTestChecks] Implement --global-value-regex (authored by jdenny).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104742/new/ https://reviews.llvm.org/D104742 Files: clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected clang/test/utils/update_cc_test_checks/global-value-regex.test llvm/utils/UpdateTestChecks/common.py
Index: llvm/utils/UpdateTestChecks/common.py =================================================================== --- llvm/utils/UpdateTestChecks/common.py +++ llvm/utils/UpdateTestChecks/common.py @@ -36,9 +36,12 @@ help='List of regular expressions to replace matching value names') parser.add_argument('--prefix-filecheck-ir-name', default='', help='Add a prefix to FileCheck IR value names to avoid conflicts with scripted names') + parser.add_argument('--global-value-regex', nargs='+', default=[], + help='List of regular expressions that a global value declaration must match to generate a check (has no effect if checking globals is not enabled)') args = parser.parse_args() - global _verbose + global _verbose, _global_value_regex _verbose = args.verbose + _global_value_regex = args.global_value_regex return args @@ -796,13 +799,27 @@ if not glob_val_dict[checkprefix][nameless_value.check_prefix]: continue - output_lines.append(comment_marker + SEPARATOR) - + check_lines = [] global_vars_seen_before = [key for key in global_vars_seen.keys()] for line in glob_val_dict[checkprefix][nameless_value.check_prefix]: + if _global_value_regex: + matched = False + for regex in _global_value_regex: + if re.match('^@' + regex + ' = ', line): + matched = True + break + if not matched: + continue tmp = generalize_check_lines([line], is_analyze, set(), global_vars_seen) check_line = '%s %s: %s' % (comment_marker, checkprefix, tmp[0]) + check_lines.append(check_line) + if not check_lines: + continue + + output_lines.append(comment_marker + SEPARATOR) + for check_line in check_lines: output_lines.append(check_line) + printed_prefixes.add((checkprefix, nameless_value.check_prefix)) # Remembe new global variables we have not seen before Index: clang/test/utils/update_cc_test_checks/global-value-regex.test =================================================================== --- /dev/null +++ clang/test/utils/update_cc_test_checks/global-value-regex.test @@ -0,0 +1,18 @@ +RUN: rm -rf %t && mkdir %t + +# Check --global-value-regex. +RUN: cp %S/Inputs/global-value-regex.c %t/test.c +RUN: %update_cc_test_checks %t/test.c --check-globals \ +RUN: --global-value-regex "foo\.." +RUN: diff -u %S/Inputs/global-value-regex.c.expected %t/test.c + +# Check that the generated directives actually work correctly. +RUN: cp %S/Inputs/lit.cfg.example %t/lit.cfg +# Show lit failures while avoiding confusing FileCheck input dump nesting. +RUN: %lit %t +# Lit was successful. Sanity-check the results with deterministic test order. +RUN: rm %t/.lit_test_times.txt +RUN: %lit %t 2>&1 | FileCheck %s + +CHECK: Testing: 1 tests +CHECK: PASS: {{.*}} test.c Index: clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected =================================================================== --- /dev/null +++ clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c.expected @@ -0,0 +1,21 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-globals --global-value-regex "foo\.." +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s + +//. +// CHECK: @foo.i = internal global i32 0, align 4 +// CHECK: @foo.j = internal global i32 0, align 4 +//. +// CHECK-LABEL: @foo( +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +// +void foo() { + static int i, j; +} +// CHECK-LABEL: @bar( +// CHECK-NEXT: entry: +// CHECK-NEXT: ret void +// +void bar() { + static int i, j; +} Index: clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c =================================================================== --- /dev/null +++ clang/test/utils/update_cc_test_checks/Inputs/global-value-regex.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s + +void foo() { + static int i, j; +} +void bar() { + static int i, j; +}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits