aboutsummaryrefslogtreecommitdiff
path: root/clang/test/InstallAPI/objcclasses.test
blob: 7b73dffbe9208b357854c18e8e7bd856e8076795 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json

// RUN: clang-installapi -target arm64-apple-macos13.1 \
// RUN: -F%t -install_name /System/Library/Frameworks/Foo.framework/Foo \
// RUN: %t/inputs.json -o %t/outputs.tbd -v 2>&1 | FileCheck %s --check-prefix=VERBOSE
// RUN: llvm-readtapi -compare %t/outputs.tbd %t/expected.tbd 2>&1 | FileCheck %s --allow-empty

// VERBOSE:       Public Headers: 
// VERBOSE-NEXT:  #import <Foo/Foo.h> 
// CHECK-NOT:     error:  
// CHECK-NOT:     warning:  

//--- Foo.framework/Headers/Foo.h
// Ignore forward declaration. 
@class NSObject;

@interface Visible 
@end

__attribute__((visibility("hidden")))
@interface Hidden
@end

__attribute__((visibility("hidden")))
@interface HiddenWithIvars {
@public 
char _ivar;
}
@end

__attribute__((objc_exception))
@interface Exception 
@end

@interface PublicClass : Visible  {
@package 
  int _internal;
@protected
  int _external;
@private
  int private;
@public
char _public;
}
@end


//--- Foo.framework/PrivateHeaders/Foo_Private.h
#import <Foo/Foo.h>

@interface ClassWithIvars : Visible  {
  char _ivar1;
  char _ivar2;
@private
  int _privateIVar;
@protected
  int _externalIVar;
@package 
  int _internalIVar;
}
@end

@interface Exception () {
@public 
  char _ivarFromExtension;
@private 
  int _privateIvarFromExtension;
}
@end


//--- inputs.json.in
{
  "headers": [ {
    "path" : "DSTROOT/Foo.framework/Headers/Foo.h",
    "type" : "public"
  }, 
  {
    "path" : "DSTROOT/Foo.framework/PrivateHeaders/Foo_Private.h",
    "type" : "private"
  }
  ],
  "version": "3"
}

//--- expected.tbd
{
  "main_library": {
    "compatibility_versions": [
      {
        "version": "0"
      }
    ],
    "current_versions": [
      {
        "version": "0"
      }
    ],
    "exported_symbols": [
      {
        "data": {
          "objc_class": [
            "PublicClass",
            "Exception",
            "Visible",
            "ClassWithIvars"
          ],
          "objc_eh_type": [
            "Exception"
          ],
          "objc_ivar": [
            "Exception._ivarFromExtension",
            "ClassWithIvars._ivar2",
            "PublicClass._external",
            "ClassWithIvars._ivar1",
            "ClassWithIvars._externalIVar",
            "PublicClass._public"
          ]
        }
      }
    ],
    "flags": [
      {
        "attributes": [
          "not_app_extension_safe"
        ]
      }
    ],
    "install_names": [
      {
        "name": "/System/Library/Frameworks/Foo.framework/Foo"
      }
    ],
    "target_info": [
      {
        "min_deployment": "13.1",
        "target": "arm64-macos"
      }
    ]
  },
  "tapi_tbd_version": 5
}