This is an archive of the discontinued LLVM Phabricator instance.

[clang][ExprConstant] Print template arguments when describing stack frame
ClosedPublic

Authored by hazohelet on Jul 3 2023, 10:07 AM.

Details

Summary

This patch adds additional printing of template argument list when the described function is a template specialization.
This can be useful when handling complex template functions in constexpr evaluator.

Diff Detail

Event Timeline

hazohelet created this revision.Jul 3 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 3 2023, 10:07 AM
hazohelet requested review of this revision.Jul 3 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 3 2023, 10:07 AM
cjdb added a subscriber: dblaikie.Jul 5 2023, 11:07 AM

Generally in favour of this, but I wonder if we ought to have a way of suppressing it when the specialisation is known and ends up being a gargantuan name (this is a discussion, not an action item). cc @dblaikie

Do we not already have some function name printing helper we could be reusing that might have some smarts about not printing deduced template arguments, using preferred names, whatever else?

FunctionDecll::getNameForDiagnostic yields almost the same result and I should use it here.
This function internal avoids printing template args that match the defaults, but it doesn't seem to have other techniques to reduce the size of printing.
Link: https://github.com/llvm/llvm-project/blob/03125e6894f82f9aa6f4e8d8036d0c833dd7d761/clang/lib/AST/TypePrinter.cpp#L2163-L2229

BTW, Line2171-2173 in the link seems to be dead code.

Uses FunctionDecl::getNameForDiagnostic

LGTM from my side, does anyone else still have a problem?

dblaikie accepted this revision.Jul 18 2023, 4:24 PM

Sounds good to me

This revision is now accepted and ready to land.Jul 18 2023, 4:24 PM

I think this looks fine, I just wonder if we should be adding more tests to make sure we cover the a fuller set of types and non-type template parameters. I feel like this is always what bites us when bugs come up, if we had just test more carefully we would have caught the problem earlier.

cjdb accepted this revision.Jul 19 2023, 10:33 AM

If there aren't any concerns from others, then LGTM!

@hazohelet can you commit this yourself, or do you need someone to commit it on your behalf? (& if so, what name/email address would you like to be credited)

@hazohelet can you commit this yourself, or do you need someone to commit it on your behalf? (& if so, what name/email address would you like to be credited)

Thanks for the review.
I have commit access now, so I'll land this myself.
I'll add some missing tests on method function templates before landing this.

Added missing tests for method function templates before landing this

This revision was landed with ongoing or failed builds.Jul 31 2023, 1:07 AM
This revision was automatically updated to reflect the committed changes.