forked from OSchip/llvm-project
[update_cc_test_checks.py] Correctly skip function definitions
Function declarations can in fact have an 'inner' node that lists the ParmVarDecls. It seems like either the JSON output has changed or that I tested the original JSON parsing change with test files that only have function definitions without arguments. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D80913
This commit is contained in:
parent
5fac474fad
commit
ead7a8becc
|
@ -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) {}
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -76,8 +76,18 @@ def get_line2spell_and_mangled(args, clang_args):
|
|||
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']
|
||||
|
|
Loading…
Reference in New Issue