This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Refactor enumerate unit tests
ClosedPublic

Authored by scott.linder on May 26 2021, 1:55 PM.

Details

Summary

Preparation for landing the tests for llvm::makeVisitor, including
breaking out the a "Counted" base class and explicitly testing
the prvalue case as distinct from the rvalue case.

Diff Detail

Event Timeline

scott.linder requested review of this revision.May 26 2021, 1:55 PM
scott.linder created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2021, 1:55 PM
dblaikie added inline comments.Jun 3 2021, 7:55 PM
llvm/unittests/ADT/STLExtrasTest.cpp
157

Probably doesn't need to be virtual, if no one ever destroys it polymorphically? But I guess we have warnings enabled that make that problematic?

Could we use composition instead, then? (Range contains a Counted, rather than derives from?)

scott.linder added inline comments.Jun 4 2021, 9:29 AM
llvm/unittests/ADT/STLExtrasTest.cpp
157

Good point, I think I just reflexively made it virtual. I would prefer to use inheritence as it cuts down on the boilerplate in the derived classes to just using Counted::Counted.

It doesn't seem like we have any warnings enabled that complain here, so I just made the destructor non-virtual

Make Counted::~Counted non-virtual

dblaikie accepted this revision.Jun 4 2021, 1:39 PM

Looks good, thanks!

This revision is now accepted and ready to land.Jun 4 2021, 1:39 PM
This revision was automatically updated to reflect the committed changes.