This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix an assertion failure in Selection.
ClosedPublic

Authored by hokein on Feb 7 2019, 1:34 AM.

Details

Summary

The assertion is triggered when the Decl is null. I didn't have a small
reproduce testcase, but this failure happened internally.

Details for the assertion:

F0207 09:55:09.069385 47308 logging.cc:84] assert.h assertion failed at llvm/include/llvm/Support/Casting.h:105 in static bool llvm::isa_impl_cl<clang::TranslationUnitDecl, const clang:: Decl *>::doit(const From *) [To = clang::TranslationUnitDecl, From = const clang::Decl *]: Val && "isa<> used on a null pointer"
15 * Check failure stack trace: *
19 @ 0x55615c1f7e06 __assert_fail
20 @ 0x55615a6297d8 clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl()
21 @ 0x55615a62f48d clang::RecursiveASTVisitor<>::TraverseTemplateTemplateParmDecl()
22 @ 0x55615a62b264 clang::RecursiveASTVisitor<>::TraverseDecl()
23 @ 0x55615a62979c clang::clangd::(anonymous namespace)::SelectionVisitor::TraverseDecl()
24 @ 0x55615a63060c clang::RecursiveASTVisitor<>::TraverseClassTemplatePartialSpecializationDecl()
25 @ 0x55615a62ae45 clang::RecursiveASTVisitor<>::TraverseDecl()

Event Timeline

hokein created this revision.Feb 7 2019, 1:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2019, 1:34 AM

Repro:

template <class T>
struct Foo {};

template <template<class> class /*cursor here*/U>
struct Foo<U<int>*> {};

I'm not sure how easy is that, but this should probably be fixed in the RecursiveASTVisitor<>. There's really no point in calling TraverseDecl(null)

sammccall accepted this revision.Feb 7 2019, 7:23 AM

Repro:

template <class T>
struct Foo {};

template <template<class> class /*cursor here*/U>
struct Foo<U<int>*> {};

I'm not sure how easy is that, but this should probably be fixed in the RecursiveASTVisitor<>. There's really no point in calling TraverseDecl(null)

Ultimately, but the current code has null-checks everywhere except this spot, so I think we should land this first before boiling the ocean.

This revision is now accepted and ready to land.Feb 7 2019, 7:23 AM
hokein updated this revision to Diff 185770.Feb 7 2019, 7:55 AM

Add reproduce testcase.

hokein updated this revision to Diff 185771.Feb 7 2019, 7:56 AM

Remove an unexpected change.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2019, 8:00 AM