This is an archive of the discontinued LLVM Phabricator instance.

[APFloat] Remove 'else' after return. NFC
ClosedPublic

Authored by timshen on Dec 19 2016, 11:40 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

timshen updated this revision to Diff 81979.Dec 19 2016, 11:40 AM
timshen retitled this revision from to [APFloat] Remove 'else' after return. NFC.
timshen added reviewers: kbarton, iteratee, hfinkel, echristo.
timshen added a subscriber: llvm-commits.
mehdi_amini added inline comments.Dec 19 2016, 11:42 AM
llvm/include/llvm/ADT/APFloat.h
772–774 ↗(On Diff #81979)

Why aren't you doing the same transformation as before here?

timshen added a subscriber: jtony.Dec 19 2016, 2:09 PM
timshen added inline comments.
llvm/include/llvm/ADT/APFloat.h
772–774 ↗(On Diff #81979)

This will also work:

if (usesLayout<IEEEFloat>(*U.semantics))
  return U.IEEE.makeInf(Neg);
if (usesLayout<DoubleAPFloat>(*U.semantics))
  return U.Double.makeInf(Neg);
llvm_unreachable("Unexpected semantics");

But @jtony have opinions on returning an expression as void in D27872, and suggested removing the void.

I'm slightly in favor of the early return version, since it's more consistent with other places; but I didn't have many data points from others. I'm happy to change.

mehdi_amini added inline comments.Dec 19 2016, 6:30 PM
llvm/include/llvm/ADT/APFloat.h
772–774 ↗(On Diff #81979)

This seems both more compact, and consistent with the other cases, so it has my preference.
I don't object to the argument that someone may find undesirable to return a void call, but then we should call it out in the coding guidelines.

timshen updated this revision to Diff 82147.Dec 20 2016, 1:42 PM

Consistently use early return style.

mehdi_amini accepted this revision.Dec 20 2016, 1:46 PM
mehdi_amini added a reviewer: mehdi_amini.

LGTM, thanks.

This revision is now accepted and ready to land.Dec 20 2016, 1:46 PM
This revision was automatically updated to reflect the committed changes.