Skip to content

Commit cf1ad28

Browse files
[clang][ExtractAPI] Handle AttributedType fragments transparently (#107262)
rdar://131958623
1 parent f1ac334 commit cf1ad28

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

clang/lib/ExtractAPI/DeclarationFragments.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForType(
276276

277277
DeclarationFragments Fragments;
278278

279+
if (const MacroQualifiedType *MQT = dyn_cast<MacroQualifiedType>(T)) {
280+
Fragments.append(
281+
getFragmentsForType(MQT->getUnderlyingType(), Context, After));
282+
return Fragments;
283+
}
284+
285+
if (const AttributedType *AT = dyn_cast<AttributedType>(T)) {
286+
// FIXME: Serialize Attributes correctly
287+
Fragments.append(
288+
getFragmentsForType(AT->getModifiedType(), Context, After));
289+
return Fragments;
290+
}
291+
279292
// An ElaboratedType is a sugar for types that are referred to using an
280293
// elaborated keyword, e.g., `struct S`, `enum E`, or (in C++) via a
281294
// qualified name, e.g., `N::M::type`, or both.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: rm -rf %t
2+
// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing \
3+
// RUN: -triple arm64-apple-macosx -x objective-c-header %s -o %t/output.symbols.json
4+
5+
_Pragma("clang assume_nonnull begin")
6+
7+
struct Foo { int a; };
8+
typedef struct Foo *Bar;
9+
// RUN: FileCheck %s -input-file %t/output.symbols.json --check-prefix FUNC
10+
void func(Bar b);
11+
// FUNC-LABEL: "!testLabel": "c:@F@func",
12+
// CHECK-NOT: Foo
13+
// CHECK: "pathComponents"
14+
15+
// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix THING
16+
#define SWIFT_NAME(_name) __attribute__((swift_name(#_name)))
17+
extern Bar const thing SWIFT_NAME(swiftThing);
18+
// THING-LABEL: "!testLabel": "c:@thing"
19+
// THING-NOT: Foo
20+
// THING: "pathComponents"
21+
22+
_Pragma("clang assume_nonnull end")
23+
24+
// expected-no-diagnostics

0 commit comments

Comments
 (0)