Skip to content

Commit a2fd6a3

Browse files
[clang][ExtractAPI] Allow serialization for ObjC++ headers (llvm#74733)
rdar://79874441
1 parent b7f1fc5 commit a2fd6a3

File tree

2 files changed

+101
-3
lines changed

2 files changed

+101
-3
lines changed

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,10 @@ StringRef getLanguageName(Language Lang) {
199199
return "objective-c";
200200
case Language::CXX:
201201
return "c++";
202+
case Language::ObjCXX:
203+
return "objective-c++";
202204

203205
// Unsupported language currently
204-
case Language::ObjCXX:
205206
case Language::OpenCL:
206207
case Language::OpenCLCXX:
207208
case Language::CUDA:

clang/test/ExtractAPI/language.c

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,42 @@
44
// RUN: %t/c.reference.output.json.in >> %t/c.reference.output.json
55
// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
66
// RUN: %t/objc.reference.output.json.in >> %t/objc.reference.output.json
7+
// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
8+
// RUN: %t/objcpp.reference.output.json.in >> %t/objcpp.reference.output.json
79

8-
// RUN: %clang -extract-api -x c-header -target arm64-apple-macosx \
10+
// RUN: %clang_cc1 -extract-api -x c-header -triple arm64-apple-macosx \
911
// RUN: %t/c.h -o %t/c.output.json | FileCheck -allow-empty %s
10-
// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
12+
// RUN: %clang_cc1 -extract-api -x objective-c-header -triple arm64-apple-macosx \
1113
// RUN: %t/objc.h -o %t/objc.output.json | FileCheck -allow-empty %s
14+
// RUN: %clang_cc1 -extract-api -x objective-c++-header -triple arm64-apple-macosx \
15+
// RUN: %t/objcpp.h -o %t/objcpp.output.json | FileCheck -allow-empty %s
1216

1317
// Generator version is not consistent across test runs, normalize it.
1418
// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
1519
// RUN: %t/c.output.json >> %t/c.output-normalized.json
1620
// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
1721
// RUN: %t/objc.output.json >> %t/objc.output-normalized.json
22+
// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
23+
// RUN: %t/objcpp.output.json >> %t/objcpp.output-normalized.json
1824

1925
// RUN: diff %t/c.reference.output.json %t/c.output-normalized.json
2026
// RUN: diff %t/objc.reference.output.json %t/objc.output-normalized.json
27+
// RUN: diff %t/objcpp.reference.output.json %t/objcpp.output-normalized.json
2128

2229
// CHECK-NOT: error:
2330
// CHECK-NOT: warning:
2431

2532
//--- c.h
2633
char c;
34+
///expected-no-diagnostics
2735

2836
//--- objc.h
2937
char objc;
38+
///expected-no-diagnostics
39+
40+
//--- objcpp.h
41+
char objcpp;
42+
///expected-no-diagnostics
3043

3144
//--- c.reference.output.json.in
3245
{
@@ -196,3 +209,87 @@ char objc;
196209
}
197210
]
198211
}
212+
//--- objcpp.reference.output.json.in
213+
{
214+
"metadata": {
215+
"formatVersion": {
216+
"major": 0,
217+
"minor": 5,
218+
"patch": 3
219+
},
220+
"generator": "?"
221+
},
222+
"module": {
223+
"name": "",
224+
"platform": {
225+
"architecture": "arm64",
226+
"operatingSystem": {
227+
"minimumVersion": {
228+
"major": 11,
229+
"minor": 0,
230+
"patch": 0
231+
},
232+
"name": "macosx"
233+
},
234+
"vendor": "apple"
235+
}
236+
},
237+
"relationships": [],
238+
"symbols": [
239+
{
240+
"accessLevel": "public",
241+
"declarationFragments": [
242+
{
243+
"kind": "typeIdentifier",
244+
"preciseIdentifier": "c:C",
245+
"spelling": "char"
246+
},
247+
{
248+
"kind": "text",
249+
"spelling": " "
250+
},
251+
{
252+
"kind": "identifier",
253+
"spelling": "objcpp"
254+
},
255+
{
256+
"kind": "text",
257+
"spelling": ";"
258+
}
259+
],
260+
"identifier": {
261+
"interfaceLanguage": "objective-c++",
262+
"precise": "c:@objcpp"
263+
},
264+
"kind": {
265+
"displayName": "Global Variable",
266+
"identifier": "objective-c++.var"
267+
},
268+
"location": {
269+
"position": {
270+
"character": 5,
271+
"line": 0
272+
},
273+
"uri": "file://INPUT_DIR/objcpp.h"
274+
},
275+
"names": {
276+
"navigator": [
277+
{
278+
"kind": "identifier",
279+
"spelling": "objcpp"
280+
}
281+
],
282+
"subHeading": [
283+
{
284+
"kind": "identifier",
285+
"spelling": "objcpp"
286+
}
287+
],
288+
"title": "objcpp"
289+
},
290+
"pathComponents": [
291+
"objcpp"
292+
]
293+
}
294+
]
295+
}

0 commit comments

Comments
 (0)