This revision was automatically updated to reflect the committed changes. Closed by commit rL353421: [clangd] Fix an assertion failure in Selection. (authored by hokein, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57879/new/ https://reviews.llvm.org/D57879 Files: clang-tools-extra/trunk/clangd/Selection.cpp clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp 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 <typename T> void foo() { [[^T]] t; }", "TypeLoc"}, + + // No crash + { + R"cpp( + template <class T> struct Foo {}; + template <[[template<class> class /*cursor here*/^U]]> + struct Foo<U<int>*> {}; + )cpp", + "TemplateTemplateParmDecl" + }, }; for (const Case &C : Cases) { Annotations Test(C.Code); 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<TranslationUnitDecl>(X)) + if (X && isa<TranslationUnitDecl>(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 <typename T> void foo() { [[^T]] t; }", "TypeLoc"}, + + // No crash + { + R"cpp( + template <class T> struct Foo {}; + template <[[template<class> class /*cursor here*/^U]]> + struct Foo<U<int>*> {}; + )cpp", + "TemplateTemplateParmDecl" + }, }; for (const Case &C : Cases) { Annotations Test(C.Code); 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<TranslationUnitDecl>(X)) + if (X && isa<TranslationUnitDecl>(X)) return Base::TraverseDecl(X); // Already pushed by constructor. return traverseNode(X, [&] { return Base::TraverseDecl(X); }); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits