[PATCH] D57879: [clangd] Fix an assertion failure in Selection.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 7 07:56:12 PST 2019
hokein updated this revision to Diff 185770.
hokein added a comment.
Add reproduce testcase.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57879/new/
https://reviews.llvm.org/D57879
Files:
clangd/Selection.cpp
unittests/clangd/SelectionTests.cpp
Index: unittests/clangd/SelectionTests.cpp
===================================================================
--- unittests/clangd/SelectionTests.cpp
+++ unittests/clangd/SelectionTests.cpp
@@ -176,7 +176,18 @@
// 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"
+ },
};
+ // template <template<class> class /*cursor here*/[[^U]]> struct Foo<U<int>*>
for (const Case &C : Cases) {
Annotations Test(C.Code);
auto AST = TestTU::withCode(Test.code()).build();
Index: clangd/Selection.cpp
===================================================================
--- clangd/Selection.cpp
+++ 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); });
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57879.185770.patch
Type: text/x-patch
Size: 1364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190207/79941196/attachment.bin>
More information about the cfe-commits
mailing list