[clang] cf1ad28 - [clang][ExtractAPI] Handle AttributedType fragments transparently (#107262)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 01:15:12 PDT 2024
Author: Daniel Grumberg
Date: 2024-09-05T09:15:09+01:00
New Revision: cf1ad28169be5d026ec95f351b56b0c090b3e682
URL: https://github.com/llvm/llvm-project/commit/cf1ad28169be5d026ec95f351b56b0c090b3e682
DIFF: https://github.com/llvm/llvm-project/commit/cf1ad28169be5d026ec95f351b56b0c090b3e682.diff
LOG: [clang][ExtractAPI] Handle AttributedType fragments transparently (#107262)
rdar://131958623
Added:
clang/test/ExtractAPI/attributed-typedef.m
Modified:
clang/lib/ExtractAPI/DeclarationFragments.cpp
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index d77bb1d424f7cf..06ce5ed6a64756 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -276,6 +276,19 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForType(
DeclarationFragments Fragments;
+ if (const MacroQualifiedType *MQT = dyn_cast<MacroQualifiedType>(T)) {
+ Fragments.append(
+ getFragmentsForType(MQT->getUnderlyingType(), Context, After));
+ return Fragments;
+ }
+
+ if (const AttributedType *AT = dyn_cast<AttributedType>(T)) {
+ // FIXME: Serialize Attributes correctly
+ Fragments.append(
+ getFragmentsForType(AT->getModifiedType(), Context, After));
+ return Fragments;
+ }
+
// An ElaboratedType is a sugar for types that are referred to using an
// elaborated keyword, e.g., `struct S`, `enum E`, or (in C++) via a
// qualified name, e.g., `N::M::type`, or both.
diff --git a/clang/test/ExtractAPI/attributed-typedef.m b/clang/test/ExtractAPI/attributed-typedef.m
new file mode 100644
index 00000000000000..c948c873ab759c
--- /dev/null
+++ b/clang/test/ExtractAPI/attributed-typedef.m
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing \
+// RUN: -triple arm64-apple-macosx -x objective-c-header %s -o %t/output.symbols.json
+
+_Pragma("clang assume_nonnull begin")
+
+struct Foo { int a; };
+typedef struct Foo *Bar;
+// RUN: FileCheck %s -input-file %t/output.symbols.json --check-prefix FUNC
+void func(Bar b);
+// FUNC-LABEL: "!testLabel": "c:@F at func",
+// CHECK-NOT: Foo
+// CHECK: "pathComponents"
+
+// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix THING
+#define SWIFT_NAME(_name) __attribute__((swift_name(#_name)))
+extern Bar const thing SWIFT_NAME(swiftThing);
+// THING-LABEL: "!testLabel": "c:@thing"
+// THING-NOT: Foo
+// THING: "pathComponents"
+
+_Pragma("clang assume_nonnull end")
+
+// expected-no-diagnostics
More information about the cfe-commits
mailing list