xref: /llvm-project/clang/test/ExtractAPI/availability.c (revision 05c1447b3eabe9cc4a27866094e46c57350c5d5a)
1 // RUN: rm -rf %t
2 // RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing -triple arm64-apple-macosx \
3 // RUN:   -x c-header %s -o %t/output.symbols.json -verify
4 
5 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix A
6 void a(void) __attribute__((availability(macos, introduced=12.0)));
7 // A-LABEL: "!testLabel": "c:@F@a"
8 // A:      "availability": [
9 // A-NEXT:   {
10 // A-NEXT:     "domain": "macos",
11 // A-NEXT:     "introduced": {
12 // A-NEXT:       "major": 12,
13 // A-NEXT:       "minor": 0,
14 // A-NEXT:       "patch": 0
15 // A-NEXT:     }
16 // A-NEXT:   }
17 // A-NEXT: ]
18 
19 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix B
20 void b(void) __attribute__((availability(macos, introduced=11.0, deprecated=12.0, obsoleted=20.0)));
21 // B-LABEL: "!testLabel": "c:@F@b"
22 // B:      "availability": [
23 // B-NEXT:   {
24 // B-NEXT:     "deprecated": {
25 // B-NEXT:       "major": 12,
26 // B-NEXT:       "minor": 0,
27 // B-NEXT:       "patch": 0
28 // B-NEXT:     },
29 // B-NEXT:     "domain": "macos",
30 // B-NEXT:     "introduced": {
31 // B-NEXT:       "major": 11,
32 // B-NEXT:       "minor": 0,
33 // B-NEXT:       "patch": 0
34 // B-NEXT:     },
35 // B-NEXT:     "obsoleted": {
36 // B-NEXT:       "major": 20,
37 // B-NEXT:       "minor": 0,
38 // B-NEXT:       "patch": 0
39 // B-NEXT:     }
40 // B-NEXT:   }
41 // B-NEXT: ]
42 
43 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix E
44 void c(void) __attribute__((availability(macos, introduced=11.0, deprecated=12.0, obsoleted=20.0))) __attribute__((availability(ios, introduced=13.0)));
45 // C-LABEL: "!testLabel": "c:@F@c"
46 // C:       "availability": [
47 // C-NEXT:    {
48 // C-NEXT:      "deprecated": {
49 // C-NEXT:        "major": 12,
50 // C-NEXT:        "minor": 0,
51 // C-NEXT:        "patch": 0
52 // C-NEXT:      },
53 // C-NEXT:      "domain": "macos",
54 // C-NEXT:      "introduced": {
55 // C-NEXT:        "major": 11,
56 // C-NEXT:        "minor": 0,
57 // C-NEXT:        "patch": 0
58 // C-NEXT:      },
59 // C-NEXT:      "obsoleted": {
60 // C-NEXT:        "major": 20,
61 // C-NEXT:        "minor": 0,
62 // C-NEXT:        "patch": 0
63 // C-NEXT:      }
64 // C-NEXT:    }
65 // C-NEXT: ]
66 
67 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix D
68 void d(void) __attribute__((deprecated)) __attribute__((availability(macos, introduced=11.0)));
69 // D-LABEL: "!testLabel": "c:@F@d"
70 // D:      "availability": [
71 // D-NEXT:   {
72 // D-NEXT:     "domain": "*",
73 // D-NEXT:     "isUnconditionallyDeprecated": true
74 // D-NEXT:   },
75 // D-NEXT:   {
76 // D-NEXT:     "domain": "macos",
77 // D-NEXT:     "introduced": {
78 // D-NEXT:       "major": 11,
79 // D-NEXT:       "minor": 0,
80 // D-NEXT:       "patch": 0
81 // D-NEXT:     }
82 // D-NEXT:   }
83 // D-NEXT: ]
84 
85 // This symbol should be dropped as it's unconditionally unavailable
86 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix E
87 void e(void) __attribute__((unavailable)) __attribute__((availability(macos, introduced=11.0)));
88 // E-NOT: "!testLabel": "c:@F@e"
89 
90 // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix F
91 void f(void) __attribute__((availability(macos, unavailable)));
92 // F-LABEL: "!testLabel": "c:@F@f"
93 // F:      "availability": [
94 // F-NEXT:   {
95 // F-NEXT:     "domain": "macos",
96 // F-NEXT:     "isUnconditionallyUnavailable": true
97 // F-NEXT:   }
98 // F-NEXT: ]
99 
100 // expected-no-diagnostics
101 
102