Skip to content

Conversation

@snprajwal
Copy link
Contributor

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

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
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jun 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 27, 2025

@llvm/pr-subscribers-clang

Author: Prajwal Nadig (snprajwal)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/146001.diff

2 Files Affected:

  • (modified) clang/lib/ExtractAPI/DeclarationFragments.cpp (+8-3)
  • (modified) clang/test/ExtractAPI/constructor_destructor.cpp (+1-1)
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<CXXConstructorDecl>(Decl) || isa<CXXDestructorDecl>(Decl))
+  if (isa<CXXConstructorDecl>(Decl)) {
     Fragments.append(cast<CXXRecordDecl>(Decl->getDeclContext())->getName(),
                      DeclarationFragments::FragmentKind::Identifier);
-  else if (isa<CXXConversionDecl>(Decl)) {
+  } else if (isa<CXXDestructorDecl>(Decl)) {
+    Fragments.append(cast<CXXDestructorDecl>(Decl)->getNameAsString(),
+                     DeclarationFragments::FragmentKind::Identifier);
+  } else if (isa<CXXConversionDecl>(Decl)) {
     Fragments.append(
         cast<CXXConversionDecl>(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"

@QuietMisdreavus QuietMisdreavus merged commit 0f48baf into llvm:main Jul 7, 2025
9 checks passed
snprajwal added a commit to snprajwal/llvm-project that referenced this pull request Jul 9, 2025
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
@snprajwal snprajwal deleted the extractapi/destructor branch August 7, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants