[clang] [clang][Index] Use canonical function parameter types in USRs (PR #68222)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 08:41:03 PDT 2023


https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/68222

>From db0887d6c68dc5610a9189c96de8fcbb631385a1 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Wed, 4 Oct 2023 10:06:28 -0400
Subject: [PATCH] [clang][Index] Use canonical function parameter types in USRs

---
 clang/lib/Index/USRGeneration.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index f778a6208d5122d..b203a29d4d5ea33 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -265,10 +265,13 @@ void USRGenerator::VisitFunctionDecl(const FunctionDecl *D) {
     Out << '>';
   }
 
+  QualType CanonicalType = D->getType().getCanonicalType();
   // Mangle in type information for the arguments.
-  for (auto *PD : D->parameters()) {
-    Out << '#';
-    VisitType(PD->getType());
+  if (const auto *FPT = CanonicalType->getAs<FunctionProtoType>()) {
+    for (QualType PT : FPT->param_types()) {
+      Out << '#';
+      VisitType(PT);
+    }
   }
   if (D->isVariadic())
     Out << '.';



More information about the cfe-commits mailing list