This is an archive of the discontinued LLVM Phabricator instance.

TypeBuilder: Use parameter pack to permit any number of function parameters
Needs ReviewPublic

Authored by TwoFx on Mar 29 2016, 4:01 AM.

Details

Summary

This patch removes the partial specializations for TypeBuilder for a specific number of function parameters and replaces them with specializations that use variadic templates to accept any number of parameters rather than a maximum of five.

Instead of using an array, these new specializations use the constructor of ArrayRef which takes an std::initializer_list. The advantage of this approach is that no special case for zero (non-ellipsis) parameters is needed.

I added a few tests for functions with up to eight parameters, as the previous limit of five parameters no longer applies.

Diff Detail

Event Timeline

TwoFx updated this revision to Diff 51890.Mar 29 2016, 4:01 AM
TwoFx retitled this revision from to TypeBuilder: Use parameter pack to permit any number of function parameters.
TwoFx updated this object.
TwoFx added reviewers: lhames, foad.
TwoFx added a subscriber: llvm-commits.

Phabricator gets confused with the diff, I recommend having a look at the raw diff.

TwoFx edited reviewers, added: resistor; removed: foad.Mar 31 2016, 2:33 AM
TwoFx added a comment.Apr 6 2016, 6:30 AM

Any feedback and commentary would be appreciated :)

A couple of comments inline. Otherwise this looks good to me, but I don't own TypeBuilder. I *think* that would be Chandler. Chandler any thoughts?

include/llvm/IR/TypeBuilder.h
255–271 ↗(On Diff #51890)

I would name the variadic parameter 'As' (plural) rather than 'A'.

lhames added a comment.Oct 8 2016, 9:45 PM

Oops - missed an inline comment in my previous submit.

unittests/IR/TypeBuilderTest.cpp
138–175 ↗(On Diff #51890)

I don't think you need the additional test cases - the existing ones should provide enough coverage.

TwoFx updated this revision to Diff 74059.Oct 9 2016, 2:11 AM
TwoFx edited edge metadata.

Removed the additional test cases, renamed A to As