[clang] 7abca75 - [Index] Skip adding call relations to deduction guides (#126151)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 7 12:02:16 PST 2025


Author: Ben Barham
Date: 2025-02-07T12:02:13-08:00
New Revision: 7abca756d1434f0e51cd0af8da647d51f38f634e

URL: https://github.com/llvm/llvm-project/commit/7abca756d1434f0e51cd0af8da647d51f38f634e
DIFF: https://github.com/llvm/llvm-project/commit/7abca756d1434f0e51cd0af8da647d51f38f634e.diff

LOG: [Index] Skip adding call relations to deduction guides (#126151)

Deduction guides have no name and we already skip adding occurrences to
them for that reason. Also skip adding any relations to them.

Added: 
    clang/test/Index/index-deduction-guide.cpp

Modified: 
    clang/lib/Index/IndexBody.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp
index c18daf7faa74979..f1dc4d5831ce746 100644
--- a/clang/lib/Index/IndexBody.cpp
+++ b/clang/lib/Index/IndexBody.cpp
@@ -130,6 +130,9 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
 
   void addCallRole(SymbolRoleSet &Roles,
                    SmallVectorImpl<SymbolRelation> &Relations) {
+    if (isa<CXXDeductionGuideDecl>(ParentDC))
+      return;
+
     Roles |= (unsigned)SymbolRole::Call;
     if (auto *FD = dyn_cast<FunctionDecl>(ParentDC))
       Relations.emplace_back((unsigned)SymbolRole::RelationCalledBy, FD);

diff  --git a/clang/test/Index/index-deduction-guide.cpp b/clang/test/Index/index-deduction-guide.cpp
new file mode 100644
index 000000000000000..a29162e8588e8a1
--- /dev/null
+++ b/clang/test/Index/index-deduction-guide.cpp
@@ -0,0 +1,10 @@
+// RUN: c-index-test core -print-source-symbols -- %s -std=gnu++17 | FileCheck %s
+
+template<typename T>
+typename T::type declval() {}
+template <typename T> struct Test;
+template <typename C, typename T = decltype(declval<C>().d())> Test(C &) -> Test<T>;
+// CHECK: [[@LINE-1]]:45 | function/C | declval
+// CHECK-NOT: RelCall
+// CHECK: [[@LINE-3]]:77 | struct(Gen)/C++ | Test
+// CHECK: [[@LINE-4]]:64 | struct(Gen)/C++ | Test


        


More information about the cfe-commits mailing list