aboutsummaryrefslogtreecommitdiff
path: root/clang/test/ExtractAPI/typedef_struct_enum.c
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/ExtractAPI/typedef_struct_enum.c')
-rw-r--r--clang/test/ExtractAPI/typedef_struct_enum.c561
1 files changed, 430 insertions, 131 deletions
diff --git a/clang/test/ExtractAPI/typedef_struct_enum.c b/clang/test/ExtractAPI/typedef_struct_enum.c
index fb6fbe9..15357d5 100644
--- a/clang/test/ExtractAPI/typedef_struct_enum.c
+++ b/clang/test/ExtractAPI/typedef_struct_enum.c
@@ -1,146 +1,445 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing \
-// RUN: -x c-header %s -triple arm64-apple-macos -o %t/output.symbols.json -verify
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
-// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix TEST
+// 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
typedef struct Test {
} Test;
-// TEST-LABEL: "!testLabel": "c:@S@Test"
-// TEST: "declarationFragments": [
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "keyword",
-// TEST-NEXT: "spelling": "typedef"
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "text",
-// TEST-NEXT: "spelling": " "
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "keyword",
-// TEST-NEXT: "spelling": "struct"
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "text",
-// TEST-NEXT: "spelling": " "
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "identifier",
-// TEST-NEXT: "spelling": "Test"
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "text",
-// TEST-NEXT: "spelling": " { ... } "
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "identifier",
-// TEST-NEXT: "spelling": "Test"
-// TEST-NEXT: },
-// TEST-NEXT: {
-// TEST-NEXT: "kind": "text",
-// TEST-NEXT: "spelling": ";"
-// TEST-NEXT: }
-// TEST-NEXT: ],
-// TEST: "displayName": "Structure",
-// TEST: "title": "Test"
-// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix TEST2
typedef enum Test2 {
simple
} Test2;
-// TEST2-LABEL: "!testLabel": "c:@E@Test2"
-// TEST2: "declarationFragments": [
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "keyword",
-// TEST2-NEXT: "spelling": "typedef"
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "text",
-// TEST2-NEXT: "spelling": " "
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "keyword",
-// TEST2-NEXT: "spelling": "enum"
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "text",
-// TEST2-NEXT: "spelling": " "
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "identifier",
-// TEST2-NEXT: "spelling": "Test2"
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "text",
-// TEST2-NEXT: "spelling": ": "
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "typeIdentifier",
-// TEST2-NEXT: "preciseIdentifier": "c:i",
-// TEST2-NEXT: "spelling": "unsigned int"
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "text",
-// TEST2-NEXT: "spelling": " { ... } "
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "identifier",
-// TEST2-NEXT: "spelling": "Test2"
-// TEST2-NEXT: },
-// TEST2-NEXT: {
-// TEST2-NEXT: "kind": "text",
-// TEST2-NEXT: "spelling": ";"
-// TEST2-NEXT: }
-// TEST2-NEXT: ],
-// TEST2: "displayName": "Enumeration",
-// TEST2: "title": "Test2"
-
struct Foo;
-
-// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix TYPEDEF
typedef struct Foo TypedefedFoo;
-// TYPEDEF-LABEL: "!testLabel": "c:typedef_struct_enum.c@T@TypedefedFoo"
-// TYPEDEF: "declarationFragments": [
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "keyword",
-// TYPEDEF-NEXT: "spelling": "typedef"
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "text",
-// TYPEDEF-NEXT: "spelling": " "
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "keyword",
-// TYPEDEF-NEXT: "spelling": "struct"
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "text",
-// TYPEDEF-NEXT: "spelling": " "
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "typeIdentifier",
-// TYPEDEF-NEXT: "preciseIdentifier": "c:@S@Foo",
-// TYPEDEF-NEXT: "spelling": "Foo"
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "text",
-// TYPEDEF-NEXT: "spelling": " "
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "identifier",
-// TYPEDEF-NEXT: "spelling": "TypedefedFoo"
-// TYPEDEF-NEXT: },
-// TYPEDEF-NEXT: {
-// TYPEDEF-NEXT: "kind": "text",
-// TYPEDEF-NEXT: "spelling": ";"
-// TYPEDEF-NEXT: }
-// TYPEDEF-NEXT: ],
-// TYPEDEF: "displayName": "Type Alias",
-// TYPEDEF: "title": "TypedefedFoo"
-// TYPEDEF: "type": "c:@S@Foo"
-
struct Foo {
int bar;
};
-// expected-no-diagnostics
+//--- 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"
+ }
+ },
+ "relationships": [
+ {
+ "kind": "memberOf",
+ "source": "c:@E@Test2@simple",
+ "target": "c:@E@Test2",
+ "targetFallback": "Test2"
+ },
+ {
+ "kind": "memberOf",
+ "source": "c:@S@Foo@FI@bar",
+ "target": "c:@S@Foo",
+ "targetFallback": "Foo"
+ }
+ ],
+ "symbols": [
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "typedef"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "keyword",
+ "spelling": "enum"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Test2"
+ },
+ {
+ "kind": "text",
+ "spelling": ": "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:i",
+ "spelling": "unsigned int"
+ },
+ {
+ "kind": "text",
+ "spelling": " { ... } "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Test2"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c",
+ "precise": "c:@E@Test2"
+ },
+ "kind": {
+ "displayName": "Enumeration",
+ "identifier": "c.enum"
+ },
+ "location": {
+ "position": {
+ "character": 13,
+ "line": 3
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Test2"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Test2"
+ }
+ ],
+ "title": "Test2"
+ },
+ "pathComponents": [
+ "Test2"
+ ]
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "identifier",
+ "spelling": "simple"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c",
+ "precise": "c:@E@Test2@simple"
+ },
+ "kind": {
+ "displayName": "Enumeration Case",
+ "identifier": "c.enum.case"
+ },
+ "location": {
+ "position": {
+ "character": 2,
+ "line": 4
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "simple"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "simple"
+ }
+ ],
+ "title": "simple"
+ },
+ "pathComponents": [
+ "Test2",
+ "simple"
+ ]
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "typedef"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "keyword",
+ "spelling": "struct"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Test"
+ },
+ {
+ "kind": "text",
+ "spelling": " { ... } "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Test"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c",
+ "precise": "c:@S@Test"
+ },
+ "kind": {
+ "displayName": "Structure",
+ "identifier": "c.struct"
+ },
+ "location": {
+ "position": {
+ "character": 15,
+ "line": 0
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Test"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Test"
+ }
+ ],
+ "title": "Test"
+ },
+ "pathComponents": [
+ "Test"
+ ]
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "struct"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c",
+ "precise": "c:@S@Foo"
+ },
+ "kind": {
+ "displayName": "Structure",
+ "identifier": "c.struct"
+ },
+ "location": {
+ "position": {
+ "character": 7,
+ "line": 9
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "Foo"
+ }
+ ],
+ "title": "Foo"
+ },
+ "pathComponents": [
+ "Foo"
+ ]
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:I",
+ "spelling": "int"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "bar"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c",
+ "precise": "c:@S@Foo@FI@bar"
+ },
+ "kind": {
+ "displayName": "Instance Property",
+ "identifier": "c.property"
+ },
+ "location": {
+ "position": {
+ "character": 8,
+ "line": 10
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "bar"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "bar"
+ }
+ ],
+ "title": "bar"
+ },
+ "pathComponents": [
+ "Foo",
+ "bar"
+ ]
+ },
+ {
+ "accessLevel": "public",
+ "declarationFragments": [
+ {
+ "kind": "keyword",
+ "spelling": "typedef"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "keyword",
+ "spelling": "struct"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "typeIdentifier",
+ "preciseIdentifier": "c:@S@Foo",
+ "spelling": "Foo"
+ },
+ {
+ "kind": "text",
+ "spelling": " "
+ },
+ {
+ "kind": "identifier",
+ "spelling": "TypedefedFoo"
+ },
+ {
+ "kind": "text",
+ "spelling": ";"
+ }
+ ],
+ "identifier": {
+ "interfaceLanguage": "c",
+ "precise": "c:input.h@T@TypedefedFoo"
+ },
+ "kind": {
+ "displayName": "Type Alias",
+ "identifier": "c.typealias"
+ },
+ "location": {
+ "position": {
+ "character": 19,
+ "line": 8
+ },
+ "uri": "file://INPUT_DIR/input.h"
+ },
+ "names": {
+ "navigator": [
+ {
+ "kind": "identifier",
+ "spelling": "TypedefedFoo"
+ }
+ ],
+ "subHeading": [
+ {
+ "kind": "identifier",
+ "spelling": "TypedefedFoo"
+ }
+ ],
+ "title": "TypedefedFoo"
+ },
+ "pathComponents": [
+ "TypedefedFoo"
+ ],
+ "type": "c:@S@Foo"
+ }
+ ]
+}