This is an archive of the discontinued LLVM Phabricator instance.

Fix ArrayRef initializer_list Ctor Test
ClosedPublic

Authored by erichkeane on Aug 25 2016, 12:29 PM.

Details

Summary

The InitializerList test had undefined behavior by creating a dangling pointer to the temporary initializer list. This patch removes the undefined behavior in the test by creating the initializer list directly.

Diff Detail

Repository
rL LLVM

Event Timeline

erichkeane retitled this revision from to Fix ArrayRef initializer_list Ctor Test.
erichkeane updated this object.
erichkeane set the repository for this revision to rL LLVM.
mehdi_amini accepted this revision.Aug 25 2016, 12:40 PM
mehdi_amini edited edge metadata.

LGTM.

unittests/ADT/ArrayRefTest.cpp
150 ↗(On Diff #69282)

Why not turn it into a lambda so it stays local to the particular test that is using it?

This revision is now accepted and ready to land.Aug 25 2016, 12:40 PM
erichkeane added inline comments.Aug 25 2016, 1:11 PM
unittests/ADT/ArrayRefTest.cpp
150 ↗(On Diff #69282)

Good idea, New patch incoming.

erichkeane updated this revision to Diff 69288.Aug 25 2016, 1:16 PM
erichkeane edited edge metadata.

Switched test to a lambda. BTW, I don't have commit rights, so if this gets approved and someone would commit for me, I'd be very appreciative.

Thanks!

dblaikie edited edge metadata.Aug 25 2016, 2:33 PM

I'd probably just keep one of these two tests - they don't seem to add a lot separately. Probably just keep the "more realistic" version, I would think (but put it in the existing test).

But no big deal either way - just my 2c :)

erichkeane marked an inline comment as done.Aug 25 2016, 2:46 PM

I'd probably just keep one of these two tests - they don't seem to add a lot separately. Probably just keep the "more realistic" version, I would think (but put it in the existing test).

But no big deal either way - just my 2c :)

I actually just realized that the ArgTest12 tests exactly the 'realistic' test anyway. I've removed the realistic test, and left this as simply the fix for the UB.

erichkeane updated this revision to Diff 69295.Aug 25 2016, 2:46 PM
erichkeane updated this object.
erichkeane edited edge metadata.

Redundant test removed

This revision was automatically updated to reflect the committed changes.