This is an archive of the discontinued LLVM Phabricator instance.

[Index] Prevent canonical decl becoming nullptr
ClosedPublic

Authored by krasimir on Jul 10 2017, 10:45 AM.

Details

Summary

This patch prevents getCanonicalDecl returning nullptr in case it finds
a canonical TemplateDeclaration with no attached TemplatedDecl.
Found by running the indexer over a version of the standard library deep inside
a template metaprogramming mess.

Event Timeline

krasimir created this revision.Jul 10 2017, 10:45 AM
vsk added subscribers: arphaman, vsk.Jul 13 2017, 7:04 PM

Do you have a test case?

I've figured out a test case for this:

template <template <typename> class A> class B { typedef A<int> A_int; };

The real-world problem comes from ptr_traits.h.

@vsk: could you help me turning this into a test case?

vsk added a comment.Jul 17 2017, 10:24 AM

Take a look at the tests in clang/test/Index/Core. You should be able to write a test which uses c-index-test to dump the symbols in this source.

krasimir updated this revision to Diff 106930.Jul 17 2017, 1:16 PM
  • Add an Index test case
vsk added a comment.Jul 17 2017, 1:38 PM

LGTM, thank you! (Let me know if you need someone to commit this for you.)

vsk accepted this revision.Jul 17 2017, 1:38 PM
This revision is now accepted and ready to land.Jul 17 2017, 1:38 PM
This revision was automatically updated to reflect the committed changes.