Skip to content

Commit 4289771

Browse files
committed
[ExtractAPI] Include tilde in destructor name (llvm#146001)
The subheading for a destructor contained only the identifier. The tilde must also be included as it is necessary to differentiate the destructor from any constructors present. rdar://129587608
1 parent d032fcf commit 4289771

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

clang/lib/ExtractAPI/DeclarationFragments.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,10 +1625,13 @@ DeclarationFragmentsBuilder::getFunctionSignature(const ObjCMethodDecl *);
16251625
DeclarationFragments
16261626
DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) {
16271627
DeclarationFragments Fragments;
1628-
if (isa<CXXConstructorDecl>(Decl) || isa<CXXDestructorDecl>(Decl))
1628+
if (isa<CXXConstructorDecl>(Decl)) {
16291629
Fragments.append(cast<CXXRecordDecl>(Decl->getDeclContext())->getName(),
16301630
DeclarationFragments::FragmentKind::Identifier);
1631-
else if (isa<CXXConversionDecl>(Decl)) {
1631+
} else if (isa<CXXDestructorDecl>(Decl)) {
1632+
Fragments.append(cast<CXXDestructorDecl>(Decl)->getNameAsString(),
1633+
DeclarationFragments::FragmentKind::Identifier);
1634+
} else if (isa<CXXConversionDecl>(Decl)) {
16321635
Fragments.append(
16331636
cast<CXXConversionDecl>(Decl)->getConversionType().getAsString(),
16341637
DeclarationFragments::FragmentKind::Identifier);
@@ -1642,9 +1645,11 @@ DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) {
16421645
} else if (Decl->getIdentifier()) {
16431646
Fragments.append(Decl->getName(),
16441647
DeclarationFragments::FragmentKind::Identifier);
1645-
} else
1648+
} else {
16461649
Fragments.append(Decl->getDeclName().getAsString(),
16471650
DeclarationFragments::FragmentKind::Identifier);
1651+
}
1652+
16481653
return Fragments;
16491654
}
16501655

clang/test/ExtractAPI/constructor_destructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class Foo {
213213
"subHeading": [
214214
{
215215
"kind": "identifier",
216-
"spelling": "Foo"
216+
"spelling": "~Foo"
217217
}
218218
],
219219
"title": "~Foo"

0 commit comments

Comments
 (0)