1 // RUN: %clang_cc1 %s -ast-print | FileCheck %s
2 // RUN: %clang -emit-ast -o %t.ast %s
3 // RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s
4 
5 // CHECK: void xla(int a) __attribute__((xray_log_args(1)));
6 void xla(int a) __attribute__((xray_log_args(1)));
7 
8 // CHECK: void *as2(int, int) __attribute__((alloc_size(1, 2)));
9 void *as2(int, int) __attribute__((alloc_size(1, 2)));
10 // CHECK: void *as1(void *, int) __attribute__((alloc_size(2)));
11 void *as1(void *, int) __attribute__((alloc_size(2)));
12 
13 // CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
14 void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));
15 
16 // CHECK: char *fmta(int, const char *) __attribute__((format_arg(2)));
17 char *fmta(int, const char *) __attribute__((format_arg(2)));
18 
19 // CHECK: void nn(int *, int *) __attribute__((nonnull(1, 2)));
20 void nn(int *, int *) __attribute__((nonnull(1, 2)));
21 
22 // CHECK: int *aa(int i) __attribute__((alloc_align(1)));
23 int *aa(int i) __attribute__((alloc_align(1)));
24 
25 // CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
26 void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));
27 // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
28 void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));
29 // CHECK: void ownr(int) __attribute__((ownership_returns(foo, 1)));
30 void ownr(int) __attribute__((ownership_returns(foo, 1)));
31 
32 // CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));
33 void 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)));
35 void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));
36 
37 class 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 };
70