Skip to content

Commit 0f48baf

Browse files
authored
[ExtractAPI] Include tilde in destructor name (#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 1121034 commit 0f48baf

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
@@ -1617,10 +1617,13 @@ DeclarationFragmentsBuilder::getFunctionSignature(const ObjCMethodDecl *);
16171617
DeclarationFragments
16181618
DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) {
16191619
DeclarationFragments Fragments;
1620-
if (isa<CXXConstructorDecl>(Decl) || isa<CXXDestructorDecl>(Decl))
1620+
if (isa<CXXConstructorDecl>(Decl)) {
16211621
Fragments.append(cast<CXXRecordDecl>(Decl->getDeclContext())->getName(),
16221622
DeclarationFragments::FragmentKind::Identifier);
1623-
else if (isa<CXXConversionDecl>(Decl)) {
1623+
} else if (isa<CXXDestructorDecl>(Decl)) {
1624+
Fragments.append(cast<CXXDestructorDecl>(Decl)->getNameAsString(),
1625+
DeclarationFragments::FragmentKind::Identifier);
1626+
} else if (isa<CXXConversionDecl>(Decl)) {
16241627
Fragments.append(
16251628
cast<CXXConversionDecl>(Decl)->getConversionType().getAsString(),
16261629
DeclarationFragments::FragmentKind::Identifier);
@@ -1634,9 +1637,11 @@ DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) {
16341637
} else if (Decl->getIdentifier()) {
16351638
Fragments.append(Decl->getName(),
16361639
DeclarationFragments::FragmentKind::Identifier);
1637-
} else
1640+
} else {
16381641
Fragments.append(Decl->getDeclName().getAsString(),
16391642
DeclarationFragments::FragmentKind::Identifier);
1643+
}
1644+
16401645
return Fragments;
16411646
}
16421647

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)