diff --git a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c --- a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c +++ b/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) {} diff --git a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected --- a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected +++ b/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) {} diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py --- a/llvm/utils/update_cc_test_checks.py +++ b/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']