aboutsummaryrefslogtreecommitdiff
path: root/clang/test/ExtractAPI/objc_interface.m
diff options
context:
space:
mode:
authorZixu Wang <zixu_wang@apple.com>2022-03-24 18:19:30 -0700
committerZixu Wang <zixu_wang@apple.com>2022-03-29 14:29:39 -0700
commit9b36e126fdb1da4d7e255e089ef225dfb130ef63 (patch)
tree1b7b71ed8d09993adad441b97bb918d16bbb75b0 /clang/test/ExtractAPI/objc_interface.m
parent686dcbe8b018759b5443c05bfeeb7abf4d9cf09c (diff)
downloadllvm-9b36e126fdb1da4d7e255e089ef225dfb130ef63.zip
llvm-9b36e126fdb1da4d7e255e089ef225dfb130ef63.tar.gz
llvm-9b36e126fdb1da4d7e255e089ef225dfb130ef63.tar.bz2
[clang][extract-api] Add Objective-C interface support
Add support for Objective-C interface declarations in ExtractAPI. Depends on D122495 Differential Revision: https://reviews.llvm.org/D122446
Diffstat (limited to 'clang/test/ExtractAPI/objc_interface.m')
-rw-r--r--clang/test/ExtractAPI/objc_interface.m402
1 files changed, 402 insertions, 0 deletions
diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m
new file mode 100644
index 0000000..1e903cf
--- /dev/null
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -0,0 +1,402 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+@protocol Protocol;
+
+@interface Super <Protocol>
+@property(readonly, getter=getProperty) unsigned Property;
++ (id)getWithProperty:(unsigned) Property;
+@end
+
+@interface Derived : Super {
+ char Ivar;
+}
+- (char)getIvar;
+@end
+
+//--- reference.output.json.in
+{
+ "metadata": {
+ "formatVersion": {
+ "major": 0,
+ "minor": 5,
+ "patch": 3
+ },
+ "generator": "?"
+ },
+ "module": {
+ "name": "",
+ "platform": {
+ "architecture": "arm64",
+ "operatingSystem": {
+ "minimumVersion": {
+ "major": 11,
+ "minor": 0,
+ "patch": 0
+ },
+ "name": "macosx"
+ },
+ "vendor": "apple"
+ }
+ },
+ "relationhips": [
+ {
+ "kind": "memberOf",
+ "source": "c:objc(cs)Super(cm)getWithProperty:",
+ "target": "c:objc(cs)Super"
+ },
+ {
+ "kind": "memberOf",
+ "source": "c:objc(cs)Super(py)Property",
+ "target": "c:objc(cs)Super"
+ },
+ {
+ "kind": "conformsTo",
+ "source": "c:objc(cs)Super",
+ "target": "c:objc(pl)Protocol"
+ },
+ {
+ "kind": "memberOf",
+ "source": "c:objc(cs)Derived@Ivar",
+ "target": "c:objc(cs)Derived"
+ },
+ {
+ "kind": "memberOf",
+ "source": "c:objc(cs)Derived(im)getIvar",
+ "target": "c:objc(cs)Derived"
+ },
+ {
+ "kind": "inheritsFrom",
+ "source": "c:objc(cs)Derived",
+ "target": "c:objc(cs)Super"
+ }
+ ],
+ "symbols": [
+ {
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "@interface"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Super"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "objective-c",
+ "precise": "c:objc(cs)Super"
+ },
+ "kind": {
+ "displayName": "Class",
+ "identifier": "objective-c.class"
+ },
+ "location": {
+ "character": 12,
+ "line": 3,
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Super"
+ }
+ ],
+ "title": "Super"
+ }
+ },
+ {
+ "declarationFragments": [
+ {
+ "kind": "text",
+ "spelling": "+ ("
+ },
+ {
+ "kind": "keyword",
+ "spelling": "id"
+ },
+ {
+ "kind": "text",
+ "spelling": ")"
+ },
+ {
+ "kind": "identifier",
+ "spelling": "getWithProperty"
+ },
+ {
+ "kind": "text",
+ "spelling": ":"
+ },
+ {
+ "kind": "text",
+ "spelling": "("
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:i",
+ "spelling": "unsigned int"
+ },
+ {
+ "kind": "text",
+ "spelling": ")"
+ },
+ {
+ "kind": "internalParam",
+ "spelling": "Property"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "objective-c",
+ "precise": "c:objc(cs)Super(cm)getWithProperty:"
+ },
+ "kind": {
+ "displayName": "Type Method",
+ "identifier": "objective-c.type.method"
+ },
+ "location": {
+ "character": 1,
+ "line": 5,
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "subHeading": [
+ {
+ "kind": "text",
+ "spelling": "+ "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "getWithProperty:"
+ }
+ ],
+ "title": "getWithProperty:"
+ }
+ },
+ {
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "@property"
+ },
+ {
+ "kind": "text",
+ "spelling": " ("
+ },
+ {
+ "kind": "keyword",
+ "spelling": "atomic"
+ },
+ {
+ "kind": "text",
+ "spelling": ", "
+ },
+ {
+ "kind": "keyword",
+ "spelling": "readonly"
+ },
+ {
+ "kind": "text",
+ "spelling": ", "
+ },
+ {
+ "kind": "keyword",
+ "spelling": "getter"
+ },
+ {
+ "kind": "text",
+ "spelling": "="
+ },
+ {
+ "kind": "identifier",
+ "spelling": "getProperty"
+ },
+ {
+ "kind": "text",
+ "spelling": ")"
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:i",
+ "spelling": "unsigned int"
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Property"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "objective-c",
+ "precise": "c:objc(cs)Super(py)Property"
+ },
+ "kind": {
+ "displayName": "Instance Property",
+ "identifier": "objective-c.property"
+ },
+ "location": {
+ "character": 50,
+ "line": 4,
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Property"
+ }
+ ],
+ "title": "Property"
+ }
+ },
+ {
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "@interface"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Derived"
+ },
+ {
+ "kind": "text",
+ "spelling": " : "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:objc(cs)Super",
+ "spelling": "Super"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "objective-c",
+ "precise": "c:objc(cs)Derived"
+ },
+ "kind": {
+ "displayName": "Class",
+ "identifier": "objective-c.class"
+ },
+ "location": {
+ "character": 12,
+ "line": 8,
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Derived"
+ }
+ ],
+ "title": "Derived"
+ }
+ },
+ {
+ "declarationFragments": [
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:C",
+ "spelling": "char"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Ivar"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "objective-c",
+ "precise": "c:objc(cs)Derived@Ivar"
+ },
+ "kind": {
+ "displayName": "Instance Variable",
+ "identifier": "objective-c.ivar"
+ },
+ "location": {
+ "character": 8,
+ "line": 9,
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Ivar"
+ }
+ ],
+ "title": "Ivar"
+ }
+ },
+ {
+ "declarationFragments": [
+ {
+ "kind": "text",
+ "spelling": "- ("
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:C",
+ "spelling": "char"
+ },
+ {
+ "kind": "text",
+ "spelling": ")"
+ },
+ {
+ "kind": "identifier",
+ "spelling": "getIvar"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "objective-c",
+ "precise": "c:objc(cs)Derived(im)getIvar"
+ },
+ "kind": {
+ "displayName": "Instance Method",
+ "identifier": "objective-c.method"
+ },
+ "location": {
+ "character": 1,
+ "line": 11,
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "subHeading": [
+ {
+ "kind": "text",
+ "spelling": "- "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "getIvar"
+ }
+ ],
+ "title": "getIvar"
+ }
+ }
+ ]
+}