This is an archive of the discontinued LLVM Phabricator instance.

Add deduction guides for IRBuilder
ClosedPublic

Authored by kparzysz on Nov 1 2022, 9:44 AM.

Details

Summary

This will help in using CTAD with IRBuilder.

Diff Detail

Event Timeline

kparzysz created this revision.Nov 1 2022, 9:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 9:44 AM
kparzysz requested review of this revision.Nov 1 2022, 9:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2022, 9:44 AM

I'm not sure if we want/need all of these. Feedback welcome.

nikic added a subscriber: nikic.Nov 7 2022, 6:57 AM

For the uninitiated, could you provide an example of what practical impact this would have?

We have a policy that classes that are meant to be used in CTAD should have at least one deduction guide. There is a warning (-Wctad-maybe-unsupported) that was added to LLVM build options to warn about using CTAD with classes that may not have been intended to be auto-deduced. The practical impact of this change would be that we could "officially" use IRBuilder without explicitly specifying template argument (in compliance with the CTAD policy).

Maybe cover it with a unit test (or if it can be tested with a static_assert, that'd be great - but not sure it can)? Or not, not sure the guides are sufficiently interesting.

Do you have particular use cases in mind?

The use case for me was not having to write IRBuilder<InstSimplifyFolder>. Since we need at least one guide for CTAD, I added them for each constructor.

kparzysz updated this revision to Diff 474264.Nov 9 2022, 7:19 AM

Added static_assert tests to the unit tests.

dblaikie accepted this revision.Nov 9 2022, 8:41 AM

The use case for me was not having to write IRBuilder<InstSimplifyFolder>. Since we need at least one guide for CTAD, I added them for each constructor.

Fair enough, sounds good.

This revision is now accepted and ready to land.Nov 9 2022, 8:41 AM
This revision was landed with ongoing or failed builds.Nov 10 2022, 9:50 AM
This revision was automatically updated to reflect the committed changes.