1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[update_cc_test_checks] Don't attach CHECK lines to function declarations

Previously we were adding the CHECK lines to both definitions and
declarations. Update the JSON AST dump parsing code to skip all
FunctionDecls without an "inner" node (i.e. no body).

Reviewed By: MaskRay, greened
Differential Revision: https://reviews.llvm.org/D73708
This commit is contained in:
Alex Richardson 2020-02-04 08:40:56 +00:00
parent d3ab7b3c38
commit 13b3bdf322
4 changed files with 62 additions and 0 deletions

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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

View File

@ -76,6 +76,10 @@ def get_line2spell_and_mangled(args, clang_args):
if line is None: if line is None:
common.debug('Skipping function without line number:', node['name'], '@', node['loc']) common.debug('Skipping function without line number:', node['name'], '@', node['loc'])
return 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'] spell = node['name']
mangled = node.get('mangledName', spell) mangled = node.get('mangledName', spell)
ret[int(line)-1] = (spell, mangled) ret[int(line)-1] = (spell, mangled)