https://github.com/HighCommander4 created 
https://github.com/llvm/llvm-project/pull/220488

Fixes https://github.com/llvm/llvm-project/issues/220359

>From a6c027062dc18dedbc25d6b0de0e4501a77199e0 Mon Sep 17 00:00:00 2001
From: Nathan Ridge <[email protected]>
Date: Wed, 2 Sep 2026 01:40:48 -0400
Subject: [PATCH] [clangd] Handle varargs functions in
 resolveForwardingParameters()

Fixes https://github.com/llvm/llvm-project/issues/220359
---
 clang-tools-extra/clangd/AST.cpp                  |  8 ++++++++
 .../clangd/unittests/InlayHintTests.cpp           | 15 +++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index ee411555209a6..acaca1cdc2381 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -874,6 +874,14 @@ class ForwardingCallVisitor
     auto PackLocation = findPack(Args);
     if (!PackLocation)
       return;
+    // If the callee is a C-style variadic function, some of the arguments 
could
+    // be expanded into the variadic argument. In this case there are no names
+    // to forward. (Technically, we could handle the case where only *part* of
+    // the pack is expanded into the variadic argument, but we currently 
don't.)
+    if (Callee->parameters().size() < (*PackLocation + Parameters.size())) {
+      assert(Callee->isVariadic());
+      return;
+    }
     ArrayRef<ParmVarDecl *> MatchingParams =
         Callee->parameters().slice(*PackLocation, Parameters.size());
     // Check whether the function has a parameter pack as the last template
diff --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp 
b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
index b90f44d102018..f5813ecc4dff5 100644
--- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1251,6 +1251,21 @@ TEST(ParameterHints, IncludeAtNonGlobalScope) {
       0u);
 }
 
+TEST(ParameterHints, Issue220359_NoCrash) {
+  assertParameterHints(R"cpp(
+    struct S { 
+      S(int, ...);
+    };
+    template <typename... Args>
+    void f(Args... args) {
+      S s(1, args...);
+    }
+    void c() {
+      f(2);
+    }
+  )cpp");
+}
+
 TEST(TypeHints, Smoke) {
   assertTypeHints(R"cpp(
     auto $waldo[[waldo]] = 42;

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

Reply via email to