Index: clang-tools-extra/trunk/clangd/Selection.cpp =================================================================== --- clang-tools-extra/trunk/clangd/Selection.cpp +++ clang-tools-extra/trunk/clangd/Selection.cpp @@ -51,7 +51,7 @@ // - those that can't be stored in DynTypedNode. // We're missing some interesting things like Attr due to the latter. bool TraverseDecl(Decl *X) { - if (isa(X)) + if (X && isa(X)) return Base::TraverseDecl(X); // Already pushed by constructor. return traverseNode(X, [&] { return Base::TraverseDecl(X); }); } Index: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp =================================================================== --- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp +++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp @@ -176,6 +176,16 @@ // Node types that have caused problems in the past. {"template void foo() { [[^T]] t; }", "TypeLoc"}, + + // No crash + { + R"cpp( + template struct Foo {}; + template <[[template class /*cursor here*/^U]]> + struct Foo*> {}; + )cpp", + "TemplateTemplateParmDecl" + }, }; for (const Case &C : Cases) { Annotations Test(C.Code);