Skip to content

Commit a1d27fd

Browse files
committed
[ExtractAPI] Include tilde in destructor name
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 9a0a976 commit a1d27fd

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
@@ -1610,10 +1610,13 @@ DeclarationFragmentsBuilder::getFunctionSignature(const ObjCMethodDecl *);
16101610
DeclarationFragments
16111611
DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) {
16121612
DeclarationFragments Fragments;
1613-
if (isa<CXXConstructorDecl>(Decl) || isa<CXXDestructorDecl>(Decl))
1613+
if (isa<CXXConstructorDecl>(Decl)) {
16141614
Fragments.append(cast<CXXRecordDecl>(Decl->getDeclContext())->getName(),
16151615
DeclarationFragments::FragmentKind::Identifier);
1616-
else if (isa<CXXConversionDecl>(Decl)) {
1616+
} else if (isa<CXXDestructorDecl>(Decl)) {
1617+
Fragments.append(cast<CXXDestructorDecl>(Decl)->getNameAsString(),
1618+
DeclarationFragments::FragmentKind::Identifier);
1619+
} else if (isa<CXXConversionDecl>(Decl)) {
16171620
Fragments.append(
16181621
cast<CXXConversionDecl>(Decl)->getConversionType().getAsString(),
16191622
DeclarationFragments::FragmentKind::Identifier);
@@ -1627,9 +1630,11 @@ DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) {
16271630
} else if (Decl->getIdentifier()) {
16281631
Fragments.append(Decl->getName(),
16291632
DeclarationFragments::FragmentKind::Identifier);
1630-
} else
1633+
} else {
16311634
Fragments.append(Decl->getDeclName().getAsString(),
16321635
DeclarationFragments::FragmentKind::Identifier);
1636+
}
1637+
16331638
return Fragments;
16341639
}
16351640

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)