Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion clang/lib/ExtractAPI/DeclarationFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,10 @@ DeclarationFragmentsBuilder::getFragmentsForParam(const ParmVarDecl *Param) {
DeclarationFragments::FragmentKind::InternalParam);
} else {
Fragments.append(std::move(TypeFragments));
if (!T->isAnyPointerType() && !T->isBlockPointerType())
// If the type is a type alias, append the space
// even if the underlying type is a pointer type.
if (T->isTypedefNameType() ||
(!T->isAnyPointerType() && !T->isBlockPointerType()))
Fragments.appendSpace();
Fragments
.append(Param->getName(),
Expand Down
81 changes: 80 additions & 1 deletion clang/test/ExtractAPI/typedef.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing \
// RUN: %clang_cc1 -extract-api --pretty-sgf --emit-sgf-symbol-labels-for-testing -fblocks \
// RUN: -triple arm64-apple-macosx -x objective-c-header %s -o %t/output.symbols.json -verify

// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix MYINT
Expand Down Expand Up @@ -90,4 +90,83 @@ void foo(BarPtr value);
void baz(BarPtr *value);
// CHECK-NOT: struct Bar *

// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix BLOCKPTR
typedef int (^CustomType)(const unsigned int *, unsigned long);
void bar(CustomType block);

// BLOCKPTR-LABEL: "!testLabel": "c:@F@bar",
// BLOCKPTR: "declarationFragments": [
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "typeIdentifier",
// BLOCKPTR-NEXT: "preciseIdentifier": "c:v",
// BLOCKPTR-NEXT: "spelling": "void"
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "text",
// BLOCKPTR-NEXT: "spelling": " "
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "identifier",
// BLOCKPTR-NEXT: "spelling": "bar"
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "text",
// BLOCKPTR-NEXT: "spelling": "("
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "typeIdentifier",
// BLOCKPTR-NEXT: "preciseIdentifier": "c:typedef.c@T@CustomType",
// BLOCKPTR-NEXT: "spelling": "CustomType"
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "text",
// BLOCKPTR-NEXT: "spelling": " "
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "internalParam",
// BLOCKPTR-NEXT: "spelling": "block"
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "text",
// BLOCKPTR-NEXT: "spelling": ");"
// BLOCKPTR-NEXT: }
// BLOCKPTR-NEXT: ],
// BLOCKPTR-NEXT: "functionSignature": {
// BLOCKPTR-NEXT: "parameters": [
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "declarationFragments": [
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "typeIdentifier",
// BLOCKPTR-NEXT: "preciseIdentifier": "c:typedef.c@T@CustomType",
// BLOCKPTR-NEXT: "spelling": "CustomType"
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "text",
// BLOCKPTR-NEXT: "spelling": " "
// BLOCKPTR-NEXT: },
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "internalParam",
// BLOCKPTR-NEXT: "spelling": "block"
// BLOCKPTR-NEXT: }
// BLOCKPTR-NEXT: ],
// BLOCKPTR-NEXT: "name": "block"
// BLOCKPTR-NEXT: }
// BLOCKPTR-NEXT: ],
// BLOCKPTR-NEXT: "returns": [
// BLOCKPTR-NEXT: {
// BLOCKPTR-NEXT: "kind": "typeIdentifier",
// BLOCKPTR-NEXT: "preciseIdentifier": "c:v",
// BLOCKPTR-NEXT: "spelling": "void"
// BLOCKPTR-NEXT: }
// BLOCKPTR-NEXT: ]
// BLOCKPTR-NEXT: },
// BLOCKPTR: "identifier": {
// BLOCKPTR-NEXT: "interfaceLanguage": "objective-c",
// BLOCKPTR-NEXT: "precise": "c:@F@bar"
// BLOCKPTR-NEXT: },
// BLOCKPTR: "kind": {
// BLOCKPTR-NEXT: "displayName": "Function",
// BLOCKPTR-NEXT: "identifier": "objective-c.func"
// BLOCKPTR-NEXT: },

// expected-no-diagnostics