This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb309041f0c3: [UTC] Enable --function-signature by default 
(authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D145149?vs=502650&id=502952#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145149

Files:
  
clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.v2.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test
  llvm/utils/UpdateTestChecks/common.py

Index: llvm/utils/UpdateTestChecks/common.py
===================================================================
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -22,9 +22,10 @@
 Version changelog:
 
 1: Initial version, used by tests that don't specify --version explicitly.
-2: --function-signature now also checks return type/attributes.
+2: --function-signature is now enabled by default and also checks return
+   type/attributes.
 """
-DEFAULT_VERSION = 1
+DEFAULT_VERSION = 2
 
 class Regex(object):
   """Wrap a compiled regular expression object to allow deep copy of a regexp.
@@ -157,6 +158,11 @@
   _global_hex_value_regex = args.global_hex_value_regex
   return args
 
+def parse_args(parser, argv):
+  args = parser.parse_args(argv)
+  if args.version >= 2:
+    args.function_signature = True
+  return args
 
 class InputLineInfo(object):
   def __init__(self, line, line_number, args, argv):
@@ -246,7 +252,7 @@
       if not is_regenerate:
         argv.insert(1, '--version=' + str(DEFAULT_VERSION))
 
-      args = parser.parse_args(argv[1:])
+      args = parse_args(parser, argv[1:])
       if argparse_callback is not None:
         argparse_callback(args)
       if is_regenerate:
@@ -1199,6 +1205,8 @@
         continue
     if parser.get_default(action.dest) == value:
       continue  # Don't add default values
+    if action.dest == 'function_signature' and args.version >= 2:
+      continue # Enabled by default in version 2
     if action.dest == 'filters':
       # Create a separate option for each filter element.  The value is a list
       # of Filter objects.
@@ -1225,7 +1233,7 @@
     for option in shlex.split(cmd_m.group('cmd').strip()):
       if option:
         argv.append(option)
-    args = parser.parse_args(filter(lambda arg: arg not in args.tests, argv))
+    args = parse_args(parser, filter(lambda arg: arg not in args.tests, argv))
     if argparse_callback is not None:
       argparse_callback(args)
   return args, argv
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test
===================================================================
--- llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test
@@ -14,3 +14,8 @@
 ## added to the update invocation below.
 # RUN: %update_test_checks %t.ll
 # RUN: diff -u %t.ll %S/Inputs/basic.ll.funcsig.expected
+## Restore the original file without --function-signature and check that
+## --version 2 will implicitly enable it and also check the return type.
+# RUN: cp -f %S/Inputs/basic.ll %t.ll
+# RUN: %update_test_checks %t.ll --version 2
+# RUN: diff -u %t.ll %S/Inputs/basic.ll.v2.expected
Index: llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.v2.expected
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/basic.ll.v2.expected
@@ -0,0 +1,65 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll)
+; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
+
+define i32 @common_sub_operand(i32 %X, i32 %Y) {
+; CHECK-LABEL: define i32 @common_sub_operand
+; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) {
+; CHECK-NEXT:    ret i32 [[X]]
+;
+  %Z = sub i32 %X, %Y
+  %Q = add i32 %Z, %Y
+  ret i32 %Q
+}
+
+define i32 @negated_operand(i32 %x) {
+; CHECK-LABEL: define i32 @negated_operand
+; CHECK-SAME: (i32 [[X:%.*]]) {
+; CHECK-NEXT:    ret i32 0
+;
+  %negx = sub i32 0, %x
+  %r = add i32 %negx, %x
+  ret i32 %r
+}
+
+define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) {
+; CHECK-LABEL: define <2 x i32> @negated_operand_commute_vec
+; CHECK-SAME: (<2 x i32> [[X:%.*]]) {
+; CHECK-NEXT:    ret <2 x i32> zeroinitializer
+;
+  %negx = sub <2 x i32> zeroinitializer, %x
+  %r = add <2 x i32> %x, %negx
+  ret <2 x i32> %r
+}
+
+define i8 @knownnegation(i8 %x, i8 %y) {
+; CHECK-LABEL: define i8 @knownnegation
+; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT:    ret i8 0
+;
+  %xy = sub i8 %x, %y
+  %yx = sub i8 %y, %x
+  %r = add i8 %xy, %yx
+  ret i8 %r
+}
+
+define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: define <2 x i8> @knownnegation_commute_vec
+; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
+; CHECK-NEXT:    ret <2 x i8> zeroinitializer
+;
+  %xy = sub <2 x i8> %x, %y
+  %yx = sub <2 x i8> %y, %x
+  %r = add <2 x i8> %yx, %xy
+  ret <2 x i8> %r
+}
+
+define i32 @nameless_value(i32 %X) {
+; CHECK-LABEL: define i32 @nameless_value
+; CHECK-SAME: (i32 [[X:%.*]]) {
+; CHECK-NEXT:    [[TMP1:%.*]] = sub i32 42, [[X]]
+; CHECK-NEXT:    ret i32 [[TMP1]]
+;
+  %1 = sub i32 42, %X
+  ret i32 %1
+}
Index: clang/test/utils/update_cc_test_checks/mangled_names.test
===================================================================
--- clang/test/utils/update_cc_test_checks/mangled_names.test
+++ clang/test/utils/update_cc_test_checks/mangled_names.test
@@ -19,3 +19,8 @@
 ## Also try --version 2
 # RUN: %update_cc_test_checks %t.c --function-signature --version 2
 # RUN: diff -u %t.c %S/Inputs/mangled_names.c.funcsig.v2.expected
+## Restore the original file without --function-signature and check that
+## --version 2 will implicitly enable it.
+# RUN: cp -f %S/Inputs/mangled_names.c %t.c
+# RUN: %update_cc_test_checks %t.c --version 2
+# RUN: diff -u %t.c %S/Inputs/mangled_names.c.v2.expected
Index: clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected
===================================================================
--- clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.v2.expected
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --version 2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
 // Example input for update_cc_test_checks
 // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
 
Index: clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
===================================================================
--- clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.v2.expected
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --version 2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
 // Example input for update_cc_test_checks
 // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to