This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Avoid undefined behavior in unittest by not making a named ArrayRef from a std::initializer_list
ClosedPublic

Authored by craig.topper on Apr 14 2017, 10:53 AM.

Details

Summary

One of the ValueTracking unittests creates a named ArrayRef initialized by a std::initializer_list. The underlying array for an std::initializer_list is only guaranteed to have a lifetime as long as the initializer_list object itself. So this can leave the ArrayRef pointing at an array that no long exists.

This fixes this to just create an explicit array instead of an ArrayRef.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 14 2017, 10:53 AM
sanjoy accepted this revision.Apr 14 2017, 10:59 AM

I think used the ArrayRef to make sure we range check the accesses, but that's probably redundant since we have sanitizer builds running regularly.

This revision is now accepted and ready to land.Apr 14 2017, 10:59 AM
This revision was automatically updated to reflect the committed changes.