llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangd Author: Nathan Ridge (HighCommander4) <details> <summary>Changes</summary> Fixes https://github.com/llvm/llvm-project/issues/220359 --- Full diff: https://github.com/llvm/llvm-project/pull/220488.diff 2 Files Affected: - (modified) clang-tools-extra/clangd/AST.cpp (+8) - (modified) clang-tools-extra/clangd/unittests/InlayHintTests.cpp (+15) ``````````diff 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; `````````` </details> https://github.com/llvm/llvm-project/pull/220488 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
