diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -4002,6 +4002,19 @@ EXPECT_EQ(Second.activeParameter, 1); } +TEST(CompletionTest, NoCrashTests) { + llvm::StringLiteral Cases[] = { + R"cpp( + template struct Foo {}; + auto a = [x(3)](Foo<^>){}; + )cpp", + }; + for (auto Case : Cases) { + SCOPED_TRACE(Case); + auto Completions = completions(Case); + } +} + } // namespace } // namespace clangd } // namespace clang diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/lib/Index/USRGeneration.cpp @@ -262,6 +262,12 @@ // Mangle in type information for the arguments. for (auto *PD : D->parameters()) { + // FIXME: Make sure we don't have nullptrs in parameter lists of function + // decls. + if (!PD) { + IgnoreResults = true; + return; + } Out << '#'; VisitType(PD->getType()); }