This is an archive of the discontinued LLVM Phabricator instance.

[ubsan] Make the C++ code here not cast floating point values outside the range of an integer type to that integer type.
ClosedPublic

Authored by chandlerc on Apr 30 2018, 6:07 PM.

Details

Summary

Instead, change the random value function to cast to the destination
type first and do the devision by 8 afterward. When the destination is
floating point this should be roughly equivalent, but when it is an
integer type it will end up truncating stuff down rather than ending up
outside the range.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc created this revision.Apr 30 2018, 6:07 PM
asbirlea accepted this revision.Apr 30 2018, 6:11 PM

LGTM. Thanks for the change!

This revision is now accepted and ready to land.Apr 30 2018, 6:11 PM
This revision was automatically updated to reflect the committed changes.