This is an archive of the discontinued LLVM Phabricator instance.

[AST][JSON] Fix null ptr crash dumping TemplateTemplateParmDecl
ClosedPublic

Authored by dtolnay on Apr 23 2021, 5:16 PM.

Details

Reviewers
aaron.ballman
Summary

The following program winds up with D->getDefaultArgStorage().getInheritedFrom() == nullptr
during dumping the TemplateTemplateParmDecl corresponding to the template parameter of i.

template <typename>
struct R;
template <template <typename> class = R>
void i();

Previously--

 #6 clang::TemplateTemplateParmDecl::getSourceRange() const clang/include/clang/AST/DeclTemplate.h:1745
#15 clang::JSONNodeDumper::VisitTemplateTemplateParmDecl(clang::TemplateTemplateParmDecl const*) clang/lib/AST/JSONNodeDumper.cpp:889
#16 clang::JSONNodeDumper::Visit(clang::Decl const*) clang/lib/AST/JSONNodeDumper.cpp:128
...
clang-13: error: unable to execute command: Segmentation fault (core dumped)

Diff Detail

Event Timeline

dtolnay created this revision.Apr 23 2021, 5:16 PM
dtolnay requested review of this revision.Apr 23 2021, 5:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2021, 5:16 PM
dtolnay edited the summary of this revision. (Show Details)Apr 23 2021, 5:18 PM
aaron.ballman accepted this revision.Apr 24 2021, 9:07 AM

LGTM, thank you for the fix! Do you need me to commit on your behalf? If so, what email address and name would you like me to use for attribution?

This revision is now accepted and ready to land.Apr 24 2021, 9:07 AM

Yes, could you please commit for me? This is my first contribution. Please attribute to David Tolnay <dtolnay@gmail.com>.

aaron.ballman closed this revision.Apr 24 2021, 9:29 AM

Yes, could you please commit for me? This is my first contribution. Please attribute to David Tolnay <dtolnay@gmail.com>.

I've committed on your behalf in 967ebad12521f3187014a722804c27a75d44e649. Congrats on landing your first contribution!