[PATCH] D142473: [UTC] Add --version argument

2023-02-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Sorry, I did not interpret those comments as blocking concerns. Happy to revert 
this if they were intended as such -- this is effectively an NFC patch until 
DEFAULT_VERSION gets bumped, so we can still backtrack to a different approach 
(though I'm not aware of any that would have less maintenance burden).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142473/new/

https://reviews.llvm.org/D142473

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142473: [UTC] Add --version argument

2023-02-06 Thread Justin Bogner via Phabricator via cfe-commits
bogner added a comment.

Multiple people had concerns with the added complexity of having to maintain 
historical versions of behaviour here (a concern which I share), and absolutely 
none of them accepted the revision or commented after the comment that you 
don’t think it’ll be too bad in practice (with little explanation as to why).

I really don’t think it was appropriate to commit this without further 
discussion here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142473/new/

https://reviews.llvm.org/D142473

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142473: [UTC] Add --version argument

2023-01-30 Thread Nikita Popov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5375b638be87: [UTC] Add --version argument (authored by 
nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142473/new/

https://reviews.llvm.org/D142473

Files:
  clang/test/utils/update_cc_test_checks/lit.local.cfg
  llvm/test/tools/UpdateTestChecks/lit.local.cfg
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -18,6 +18,13 @@
 _verbose = False
 _prefix_filecheck_ir_name = ''
 
+"""
+Version changelog:
+
+1: Initial version, used by tests that don't specify --version explicitly.
+"""
+DEFAULT_VERSION = 1
+
 class Regex(object):
   """Wrap a compiled regular expression object to allow deep copy of a regexp.
   This is required for the deep copy done in do_scrub.
@@ -138,6 +145,10 @@
   dest='gen_unused_prefix_body',
   default=True,
   help='Generate a function body that always matches for 
unused prefixes. This is useful when unused prefixes are desired, and it avoids 
needing to annotate each FileCheck as allowing them.')
+  # This is the default when regenerating existing tests. The default when
+  # generating new tests is determined by DEFAULT_VERSION.
+  parser.add_argument('--version', type=int, default=1,
+  help='The version of output format')
   args = parser.parse_args()
   global _verbose, _global_value_regex, _global_hex_value_regex
   _verbose = args.verbose
@@ -226,12 +237,18 @@
 for test in tests_list:
   with open(test) as f:
 input_lines = [l.rstrip() for l in f]
-  args = parser.parse_args()
+  first_line = input_lines[0] if input_lines else ""
+  is_regenerate = UTC_ADVERT in first_line
+
+  # If we're generating a new test, set the default version to the latest.
+  argv = sys.argv[:]
+  if not is_regenerate:
+argv.insert(1, '--version=' + str(DEFAULT_VERSION))
+
+  args = parser.parse_args(argv[1:])
   if argparse_callback is not None:
 argparse_callback(args)
-  argv = sys.argv[:]
-  first_line = input_lines[0] if input_lines else ""
-  if UTC_ADVERT in first_line:
+  if is_regenerate:
 if script_name not in first_line and not args.force_update:
   warn("Skipping test which wasn't autogenerated by " + script_name, 
test)
   continue
Index: llvm/test/tools/UpdateTestChecks/lit.local.cfg
===
--- llvm/test/tools/UpdateTestChecks/lit.local.cfg
+++ llvm/test/tools/UpdateTestChecks/lit.local.cfg
@@ -15,6 +15,10 @@
 assert name.startswith('%')
 script_path = os.path.join(config.llvm_src_root, 'utils', name[1:] + '.py')
 assert os.path.isfile(script_path)
+# Specify an explicit default version in UTC tests, so that the --version
+# embedded in UTC_ARGS does not change in all test expectations every time
+# the default is bumped.
+extra_args += ' --version=1'
 config.substitutions.append(
 (name, "'%s' %s %s" % (python_exe, script_path, extra_args)))
 
Index: clang/test/utils/update_cc_test_checks/lit.local.cfg
===
--- clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -26,6 +26,10 @@
 extra_args = '--clang ' + shell_quote(clang_path)
 opt_path = os.path.join(config.llvm_tools_dir, 'opt')
 extra_args += ' --opt ' + shell_quote(opt_path)
+# Specify an explicit default version in UTC tests, so that the --version
+# embedded in UTC_ARGS does not change in all test expectations every time
+# the default is bumped.
+extra_args += ' --version=1'
 script_path = os.path.join(config.llvm_src_root, 'utils',
'update_cc_test_checks.py')
 assert os.path.isfile(script_path)


Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -18,6 +18,13 @@
 _verbose = False
 _prefix_filecheck_ir_name = ''
 
+"""
+Version changelog:
+
+1: Initial version, used by tests that don't specify --version explicitly.
+"""
+DEFAULT_VERSION = 1
+
 class Regex(object):
   """Wrap a compiled regular expression object to allow deep copy of a regexp.
   This is required for the deep copy done in do_scrub.
@@ -138,6 +145,10 @@
   dest='gen_unused_prefix_body',
   default=True,
   help='Generate a functio