[PATCH] D73708: [update_cc_test_checks] Don't attach CHECK lines to function declarations
Alexander Richardson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 02:56:18 PST 2020
arichardson updated this revision to Diff 241669.
arichardson marked an inline comment as done.
arichardson added a comment.
Address feedback
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73708/new/
https://reviews.llvm.org/D73708
Files:
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
llvm/utils/update_cc_test_checks.py
Index: llvm/utils/update_cc_test_checks.py
===================================================================
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -76,6 +76,10 @@
if line is None:
common.debug('Skipping function without line number:', node['name'], '@', node['loc'])
return
+ # If there is no 'inner' object, it is a function declaration -> skip
+ if 'inner' not in node:
+ common.debug('Skipping function without body:', node['name'], '@', node['loc'])
+ return
spell = node['name']
mangled = node.get('mangledName', spell)
ret[int(line)-1] = (spell, mangled)
Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_cc_test_checks/def-and-decl.test
@@ -0,0 +1,7 @@
+## Test that CHECK lines are generated before the definion and not the declaration
+
+# RUN: cp %S/Inputs/def-and-decl.c %t.c && %update_cc_test_checks %t.c
+# RUN: diff -u %S/Inputs/def-and-decl.c.expected %t.c
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t.c
+# RUN: diff -u %S/Inputs/def-and-decl.c.expected %t.c
Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c.expected
@@ -0,0 +1,34 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Check that the CHECK lines are generated before the definition and not the declaration
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+
+int foo();
+
+void empty_function();
+
+// CHECK-LABEL: @main(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
+// CHECK-NEXT: store i32 0, i32* [[RETVAL]], align 4
+// CHECK-NEXT: call void @empty_function()
+// CHECK-NEXT: [[CALL:%.*]] = call i32 @foo()
+// CHECK-NEXT: ret i32 [[CALL]]
+//
+int main() {
+ empty_function();
+ return foo();
+}
+
+// CHECK-LABEL: @foo(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret i32 1
+//
+int foo() {
+ return 1;
+}
+
+// CHECK-LABEL: @empty_function(
+// CHECK-NEXT: entry:
+// CHECK-NEXT: ret void
+//
+void empty_function() {}
Index: llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c
===================================================================
--- /dev/null
+++ llvm/test/tools/UpdateTestChecks/update_cc_test_checks/Inputs/def-and-decl.c
@@ -0,0 +1,17 @@
+// Check that the CHECK lines are generated before the definition and not the declaration
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+
+int foo();
+
+void empty_function();
+
+int main() {
+ empty_function();
+ return foo();
+}
+
+int foo() {
+ return 1;
+}
+
+void empty_function() {}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73708.241669.patch
Type: text/x-patch
Size: 3052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200131/1881c6ae/attachment.bin>
More information about the llvm-commits
mailing list