diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index 348e7588690a2..62b69436c0f97 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -1610,10 +1610,13 @@ DeclarationFragmentsBuilder::getFunctionSignature(const ObjCMethodDecl *); DeclarationFragments DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) { DeclarationFragments Fragments; - if (isa(Decl) || isa(Decl)) + if (isa(Decl)) { Fragments.append(cast(Decl->getDeclContext())->getName(), DeclarationFragments::FragmentKind::Identifier); - else if (isa(Decl)) { + } else if (isa(Decl)) { + Fragments.append(cast(Decl)->getNameAsString(), + DeclarationFragments::FragmentKind::Identifier); + } else if (isa(Decl)) { Fragments.append( cast(Decl)->getConversionType().getAsString(), DeclarationFragments::FragmentKind::Identifier); @@ -1627,9 +1630,11 @@ DeclarationFragmentsBuilder::getSubHeading(const NamedDecl *Decl) { } else if (Decl->getIdentifier()) { Fragments.append(Decl->getName(), DeclarationFragments::FragmentKind::Identifier); - } else + } else { Fragments.append(Decl->getDeclName().getAsString(), DeclarationFragments::FragmentKind::Identifier); + } + return Fragments; } diff --git a/clang/test/ExtractAPI/constructor_destructor.cpp b/clang/test/ExtractAPI/constructor_destructor.cpp index 27112c95ac45c..2f2150a6d0da0 100644 --- a/clang/test/ExtractAPI/constructor_destructor.cpp +++ b/clang/test/ExtractAPI/constructor_destructor.cpp @@ -213,7 +213,7 @@ class Foo { "subHeading": [ { "kind": "identifier", - "spelling": "Foo" + "spelling": "~Foo" } ], "title": "~Foo"