This is an archive of the discontinued LLVM Phabricator instance.

[Align] Remove operations on MaybeAlign that asserted that it had a defined value.
ClosedPublic

Authored by craig.topper on May 22 2020, 1:00 PM.

Details

Summary

If the caller needs to reponsible for making sure the MaybeAlign
has a value, then we should just make the caller convert it to an Align
with operator*.

I explicitly deleted the relational comparison operators that
were being inherited from Optional. It's unclear what the meaning
of two MaybeAligns were one is defined and the other isn't
should be. So make the caller reponsible for defining the behavior.

I left the ==/!= operators from Optional. But now that exposed a
weird quirk that ==/!= between Align and MaybeAlign required the
MaybeAlign to be defined. But now the Align will be implicitly
converted to MaybeAlign and we'll use the MaybeAlign/MaybeAlign

/!=. I don't think that's a big problem though.

Diff Detail

Event Timeline

craig.topper created this revision.May 22 2020, 1:00 PM
Herald added a reviewer: sstefan1. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
efriedma accepted this revision.May 22 2020, 3:55 PM

Optional has template <typename T> bool operator<(const Optional<T> &X, const T &Y); are you sure that doesn't trigger for MaybeAlign/Align?

Otherwise LGTM

This revision is now accepted and ready to land.May 22 2020, 3:55 PM
This revision was automatically updated to reflect the committed changes.

LGTM thx for the patch.