blob: cc7413baf10e87a2b4afcf821b742d4dd5c141a5 [file] [log] [blame]
Aaron Ballman48a533d2018-02-27 23:49:28 +00001// RUN: %clang_cc1 %s -ast-print | FileCheck %s
Joel E. Dennyb17a3292018-03-13 22:18:29 +00002// RUN: %clang -emit-ast -o %t.ast %s
3// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
Joel E. Denny81508102018-03-13 14:51:22 +00004
5// CHECK: void xla(int a) __attribute__((xray_log_args(1)));
6void xla(int a) __attribute__((xray_log_args(1)));
7
Aaron Ballman48a533d2018-02-27 23:49:28 +00008// CHECK: void *as2(int, int) __attribute__((alloc_size(1, 2)));
9void *as2(int, int) __attribute__((alloc_size(1, 2)));
10// CHECK: void *as1(void *, int) __attribute__((alloc_size(2)));
11void *as1(void *, int) __attribute__((alloc_size(2)));
Joel E. Denny81508102018-03-13 14:51:22 +000012
13// CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
14void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
15
16// CHECK: char *fmta(int, const char *) __attribute__((format_arg(2)));
17char *fmta(int, const char *) __attribute__((format_arg(2)));
18
19// CHECK: void nn(int *, int *) __attribute__((nonnull(1, 2)));
20void nn(int *, int *) __attribute__((nonnull(1, 2)));
21
22// CHECK: int *aa(int i) __attribute__((alloc_align(1)));
23int *aa(int i) __attribute__((alloc_align(1)));
24
25// CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
26void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
27// CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
28void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
29// CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
30void ownr(int) __attribute__((ownership_returns(foo, 1)));
31
32// CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
33void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
34// CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
35void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
36
37class C {
38 // CHECK: void xla(int a) __attribute__((xray_log_args(2)));
39 void xla(int a) __attribute__((xray_log_args(2)));
40
41 // CHECK: void *as2(int, int) __attribute__((alloc_size(2, 3)));
42 void *as2(int, int) __attribute__((alloc_size(2, 3)));
43 // CHECK: void *as1(void *, int) __attribute__((alloc_size(3)));
44 void *as1(void *, int) __attribute__((alloc_size(3)));
45
46 // CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));
47 void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));
48
49 // CHECK: char *fmta(int, const char *) __attribute__((format_arg(3)));
50 char *fmta(int, const char *) __attribute__((format_arg(3)));
51
52 // CHECK: void nn(int *, int *) __attribute__((nonnull(2, 3)));
53 void nn(int *, int *) __attribute__((nonnull(2, 3)));
54
55 // CHECK: int *aa(int i) __attribute__((alloc_align(2)));
56 int *aa(int i) __attribute__((alloc_align(2)));
57
58 // CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 2, 3)));
59 void ownt(int *, int *) __attribute__((ownership_takes(foo, 2, 3)));
60 // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 3)));
61 void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 3)));
62 // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 2)));
63 void ownr(int) __attribute__((ownership_returns(foo, 2)));
64
65 // CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 4, 3)));
66 void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 4, 3)));
67 // CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 2, 3)));
68 void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 2, 3)));
69};