Debian Codegraph @

clang/test/ExtractAPI/emit-symbol-graph/single_file.c

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: split-file %s %t
4 // RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
5 // RUN: %t/reference.output.json.in >> %t/reference.output.json
6 // RUN: %clang_cc1 %t/main.c -emit-symbol-graph --pretty-sgf \
7 // RUN: --symbol-graph-dir=%t/SymbolGraphs --product-name=basicfile -triple=x86_64-apple-macosx12.0.0
8
9 // Generator version is not consistent across test runs, normalize it.
10 // RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
11 // RUN: %t/SymbolGraphs/main.c.symbols.json >> %t/output-normalized.json
12 // RUN: diff %t/reference.output.json %t/output-normalized.json
13
14 // CHECK-NOT: error:
15 // CHECK-NOT: warning:
16
17 //--- main.c
18 int main ()
19 {
20 return 0;
21 }
22
23
24 //--- reference.output.json.in
25 {
26 "metadata": {
27 "formatVersion": {
28 "major": 0,
29 "minor": 5,
30 "patch": 3
31 },
32 "generator": "?"
33 },
34 "module": {
35 "name": "basicfile",
36 "platform": {
37 "architecture": "x86_64",
38 "operatingSystem": {
39 "name": "macosx"
40 },
41 "vendor": "apple"
42 }
43 },
44 "relationships": [],
45 "symbols": [
46 {
47 "accessLevel": "public",
48 "declarationFragments": [
49 {
50 "kind": "typeIdentifier",
51 "preciseIdentifier": "c:I",
52 "spelling": "int"
53 },
54 {
55 "kind": "text",
56 "spelling": " "
57 },
58 {
59 "kind": "identifier",
60 "spelling": "main"
61 },
62 {
63 "kind": "text",
64 "spelling": "();"
65 }
66 ],
67 "functionSignature": {
68 "returns": [
69 {
70 "kind": "typeIdentifier",
71 "preciseIdentifier": "c:I",
72 "spelling": "int"
73 }
74 ]
75 },
76 "identifier": {
77 "interfaceLanguage": "c",
78 "precise": "c:@F@main"
79 },
80 "kind": {
81 "displayName": "Function",
82 "identifier": "c.func"
83 },
84 "location": {
85 "position": {
86 "character": 4,
87 "line": 0
88 },
89 "uri": "file://INPUT_DIR/main.c"
90 },
91 "names": {
92 "navigator": [
93 {
94 "kind": "identifier",
95 "spelling": "main"
96 }
97 ],
98 "subHeading": [
99 {
100 "kind": "identifier",
101 "spelling": "main"
102 }
103 ],
104 "title": "main"
105 },
106 "pathComponents": [
107 "main"
108 ]
109 }
110 ]
111 }