https://github.com/Sandeep2265 updated 
https://github.com/llvm/llvm-project/pull/167319

>From dafd837aca7d19b8827619be6907d55beee3a701 Mon Sep 17 00:00:00 2001
From: Sandeep Krapa <[email protected]>
Date: Mon, 10 Nov 2025 19:42:44 +0530
Subject: [PATCH] Added a helper function OriginalNameTypedef(),it may help fix
 the issue with typedefs for structs.

---
 clang/lib/ExtractAPI/DeclarationFragments.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index e5eda46df8056..16a524702e963 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -63,6 +63,17 @@ void findTypeLocForBlockDecl(const clang::TypeSourceInfo 
*TSInfo,
 
 } // namespace
 
+static std::string OriginalNameTypedef(const clang::QualType &qt,
+                                       const clang::PrintingPolicy &policy) {
+  if (const auto *tt = 
llvm::dyn_cast<clang::TypedefType>(qt.getTypePtrOrNull())) {
+    const auto *td = tt->getDecl();
+    if (!td->getName().empty())
+      return td->getName().str();
+  }
+  return qt.getAsString(policy);
+}
+
+
 DeclarationFragments &
 DeclarationFragments::appendUnduplicatedTextCharacter(char Character) {
   if (!Fragments.empty()) {
@@ -452,7 +463,8 @@ DeclarationFragments 
DeclarationFragmentsBuilder::getFragmentsForType(
   // Default fragment builder for other kinds of types (BuiltinType etc.)
   SmallString<128> USR;
   clang::index::generateUSRForType(Base, Context, USR);
-  Fragments.append(Base.getAsString(),
+  std::string typestr = OriginalNameTypedef(Base, Context.getPrintingPolicy());
+  Fragments.append(typestr,
                    DeclarationFragments::FragmentKind::TypeIdentifier, USR);
 
   return Fragments;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to