This is an archive of the discontinued LLVM Phabricator instance.

Fix assertion when generating debug information for deduced template specialization types.
ClosedPublic

Authored by EricWF on Feb 16 2017, 10:36 PM.

Details

Summary

Currently the following code hits an llvm_unreachable in CGDebugInfo::CreateTypeNode because DeducedTemplateSpecialization isn't handled.

// clang++ -std=c++1z -g test.cpp
template <class T> struct S { S(T) {} };
S s(42);

This patch attempts to fix the handling of DeducedTemplateSpecialization as to correctly emit debug information. I've also attempted to write a test checking the emission of the debug information, but IDK if it's testing for the right output.

Diff Detail

Repository
rL LLVM

Event Timeline

EricWF created this revision.Feb 16 2017, 10:36 PM
EricWF updated this revision to Diff 88859.Feb 16 2017, 10:37 PM

Remove unintentional changes.

majnemer added inline comments.Feb 16 2017, 10:56 PM
lib/CodeGen/CGDebugInfo.cpp
2479 ↗(On Diff #88859)

You are unconditionally dereferencing a dyn_cast, this seems bad. Is T sometimes not a DeducedType or should the dyn_cast be a cast?

EricWF marked an inline comment as done.Feb 16 2017, 10:59 PM
EricWF added inline comments.
lib/CodeGen/CGDebugInfo.cpp
2479 ↗(On Diff #88859)

Woops that should have been a cast instead of a dyn_cast. T should always be DeducedType (See AstContext.cpp:1879 for an example use of cast<DeducedType>(...) ).

EricWF updated this revision to Diff 88861.Feb 16 2017, 11:00 PM
EricWF marked an inline comment as done.

Address @majnemer's comments.

EricWF added inline comments.Feb 17 2017, 4:43 AM
lib/CodeGen/CGDebugInfo.cpp
2478 ↗(On Diff #88861)

I'll put this in alphabetical order before committing.

rsmith added inline comments.Feb 17 2017, 10:07 AM
lib/CodeGen/CGDebugInfo.cpp
2478 ↗(On Diff #88861)

Reuse the Type::Auto case here rather than duplicating it. (You'll need to change its AutoType to the DeducedType common base class.)

EricWF updated this revision to Diff 88943.Feb 17 2017, 12:53 PM
EricWF marked 2 inline comments as done.

Address @rsmith's review comments.

rsmith accepted this revision.Feb 17 2017, 6:55 PM

LGTM, thanks!

This revision is now accepted and ready to land.Feb 17 2017, 6:55 PM
This revision was automatically updated to reflect the committed changes.