Skip to content

Commit eee7211

Browse files
authored
[CodeGen][test][NFC] Refactor ObjC attribute tests (#156519)
Some downstream work broke these tests because the attribute number changed. Refactor these tests to be more resilient in the face of changes like this * `instrument-objc-method.m` * `#1` was never checked, I think it was trying to check that `__cyg_profile_func_enter` was not used, so I added `--implicit-check-not="__cyg_profile_func_enter"` * Use `[[#ATTR:]]` so the test doesn't fail if the number changes * `address-safety-attr.mm` * Check attributes in `Function Attrs:` so it's independent of the attribute number
1 parent c51db9f commit eee7211

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
1-
// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck -check-prefix=PREINLINE %s
2-
// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare | FileCheck -check-prefix=BARE %s
1+
// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions | FileCheck --check-prefix=PREINLINE --implicit-check-not="__cyg_profile_func_enter" %s
2+
// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-apple-darwin10 -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare | FileCheck --check-prefix=BARE --implicit-check-not="__cyg_profile_func_enter" %s
33

44
@interface ObjCClass
55
@end
66

77
@implementation ObjCClass
88

9-
// PREINLINE: @"\01+[ObjCClass initialize]"{{\(.*\)}} #0
10-
// BARE: @"\01+[ObjCClass initialize]"{{\(.*\)}} #0
9+
// PREINLINE: define {{.*}}@"\01+[ObjCClass initialize]"{{\(.*\)}} #[[#ATTR:]]
10+
// BARE: define {{.*}}@"\01+[ObjCClass initialize]"{{\(.*\)}} #[[#ATTR:]]
1111
+ (void)initialize {
1212
}
1313

14-
// BARE: @"\01+[ObjCClass load]"{{\(.*\)}} #1
1514
+ (void)load __attribute__((no_instrument_function)) {
1615
}
1716

18-
// PREINLINE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #1
19-
// BARE: @"\01-[ObjCClass dealloc]"{{\(.*\)}} #1
2017
- (void)dealloc __attribute__((no_instrument_function)) {
2118
}
2219

23-
// PREINLINE: attributes #0 = { {{.*}}"instrument-function-entry"="__cyg_profile_func_enter"
24-
// PREINLINE-NOT: attributes #0 = { {{.*}}"instrument-function-entry"="__cyg_profile_func_enter_bare"
25-
// PREINLINE-NOT: attributes #2 = { {{.*}}"__cyg_profile_func_enter"
26-
// BARE: attributes #0 = { {{.*}}"instrument-function-entry-inlined"="__cyg_profile_func_enter_bare"
27-
// BARE-NOT: attributes #0 = { {{.*}}"__cyg_profile_func_enter"
28-
// BARE-NOT: attributes #2 = { {{.*}}"__cyg_profile_func_enter_bare"
20+
// PREINLINE: attributes #[[#ATTR]] =
21+
// PREINLINE-SAME: "instrument-function-entry"="__cyg_profile_func_enter"
22+
// BARE: attributes #[[#ATTR]] =
23+
// BARE-SAME: "instrument-function-entry-inlined"="__cyg_profile_func_enter_bare"
2924
@end
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
2-
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=address | FileCheck -check-prefix=ASAN %s
1+
// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s --implicit-check-not=sanitize_address
2+
// RUN: %clang_cc1 -emit-llvm -o - %s -fsanitize=address | FileCheck %s --check-prefixes=CHECK,ASAN
33

44
@interface MyClass
55
+ (int) addressSafety:(int*)a;
66
@end
77

88
@implementation MyClass
99

10-
// WITHOUT: +[MyClass load]{{.*}}#0
11-
// ASAN: +[MyClass load]{{.*}}#0
10+
// ASAN: ; Function Attrs:
11+
// ASAN-SAME: sanitize_address
12+
// CHECK-LABEL: define {{.*}}+[MyClass load]
1213
+(void) load { }
1314

14-
// WITHOUT: +[MyClass addressSafety:]{{.*}}#0
15-
// ASAN: +[MyClass addressSafety:]{{.*}}#0
15+
// ASAN: ; Function Attrs:
16+
// ASAN-SAME: sanitize_address
17+
// CHECK-LABEL: define {{.*}}+[MyClass addressSafety:]
1618
+ (int) addressSafety:(int*)a { return *a; }
1719

1820
@end
19-
20-
// ASAN: attributes #0 = {{.*}}sanitize_address
21-
// WITHOUT-NOT: attributes #0 = {{.*}}sanitize_address

0 commit comments

Comments
 (0)