This revision was automatically updated to reflect the committed changes.
Closed by commit rGead7a8beccc1: [update_cc_test_checks.py] Correctly skip
function definitions (authored by arichardson).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80913/new/
https://reviews.llvm.org/D80913
Files:
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
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,8 +76,18 @@
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:
+
+ # If there is no 'inner' object, it is a function declaration and we can
+ # skip it. However, function declarations may also contain an 'inner' list,
+ # but in that case it will only contains ParmVarDecls. If we find an entry
+ # that is not a ParmVarDecl, we know that this is a function definition.
+ has_body = False
+ if 'inner' in node:
+ for i in node['inner']:
+ if i.get('kind', 'ParmVarDecl') != 'ParmVarDecl':
+ has_body = True
+ break
+ if not has_body:
common.debug('Skipping function without body:', node['name'], '@', node['loc'])
return
spell = node['name']
Index: clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
===================================================================
--- clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
@@ -2,33 +2,36 @@
// 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();
+int foo(int arg);
-void empty_function();
+void empty_function(void);
// 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: [[CALL:%.*]] = call i32 @foo(i32 1)
// CHECK-NEXT: ret i32 [[CALL]]
//
int main() {
empty_function();
- return foo();
+ return foo(1);
}
// CHECK-LABEL: @foo(
// CHECK-NEXT: entry:
-// CHECK-NEXT: ret i32 1
+// CHECK-NEXT: [[ARG_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT: store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT: ret i32 [[TMP0]]
//
-int foo() {
- return 1;
+int foo(int arg) {
+ return arg;
}
// CHECK-LABEL: @empty_function(
// CHECK-NEXT: entry:
// CHECK-NEXT: ret void
//
-void empty_function() {}
+void empty_function(void) {}
Index: clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
===================================================================
--- clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
+++ clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
@@ -1,17 +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();
+int foo(int arg);
-void empty_function();
+void empty_function(void);
int main() {
empty_function();
- return foo();
+ return foo(1);
}
-int foo() {
- return 1;
+int foo(int arg) {
+ return arg;
}
-void empty_function() {}
+void empty_function(void) {}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits