[llvm] r290232 - [APFloat] Remove 'else' after return. NFC
Tim Shen via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 18:39:21 PST 2016
Author: timshen
Date: Tue Dec 20 20:39:21 2016
New Revision: 290232
URL: http://llvm.org/viewvc/llvm-project?rev=290232&view=rev
Log:
[APFloat] Remove 'else' after return. NFC
Reviewers: kbarton, iteratee, hfinkel, echristo
Subscribers: mehdi_amini, llvm-commits
Differential Revision: https://reviews.llvm.org/D27934
Modified:
llvm/trunk/include/llvm/ADT/APFloat.h
llvm/trunk/lib/Support/APFloat.cpp
Modified: llvm/trunk/include/llvm/ADT/APFloat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=290232&r1=290231&r2=290232&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APFloat.h (original)
+++ llvm/trunk/include/llvm/ADT/APFloat.h Tue Dec 20 20:39:21 2016
@@ -671,41 +671,49 @@ class APFloat : public APFloatBase {
Storage(const fltSemantics &Semantics, ArgTypes &&... Args) {
if (usesLayout<IEEEFloat>(Semantics)) {
new (&IEEE) IEEEFloat(Semantics, std::forward<ArgTypes>(Args)...);
- } else if (usesLayout<DoubleAPFloat>(Semantics)) {
+ return;
+ }
+ if (usesLayout<DoubleAPFloat>(Semantics)) {
new (&Double) DoubleAPFloat(Semantics, std::forward<ArgTypes>(Args)...);
- } else {
- llvm_unreachable("Unexpected semantics");
+ return;
}
+ llvm_unreachable("Unexpected semantics");
}
~Storage() {
if (usesLayout<IEEEFloat>(*semantics)) {
IEEE.~IEEEFloat();
- } else if (usesLayout<DoubleAPFloat>(*semantics)) {
+ return;
+ }
+ if (usesLayout<DoubleAPFloat>(*semantics)) {
Double.~DoubleAPFloat();
- } else {
- llvm_unreachable("Unexpected semantics");
+ return;
}
+ llvm_unreachable("Unexpected semantics");
}
Storage(const Storage &RHS) {
if (usesLayout<IEEEFloat>(*RHS.semantics)) {
new (this) IEEEFloat(RHS.IEEE);
- } else if (usesLayout<DoubleAPFloat>(*RHS.semantics)) {
+ return;
+ }
+ if (usesLayout<DoubleAPFloat>(*RHS.semantics)) {
new (this) DoubleAPFloat(RHS.Double);
- } else {
- llvm_unreachable("Unexpected semantics");
+ return;
}
+ llvm_unreachable("Unexpected semantics");
}
Storage(Storage &&RHS) {
if (usesLayout<IEEEFloat>(*RHS.semantics)) {
new (this) IEEEFloat(std::move(RHS.IEEE));
- } else if (usesLayout<DoubleAPFloat>(*RHS.semantics)) {
+ return;
+ }
+ if (usesLayout<DoubleAPFloat>(*RHS.semantics)) {
new (this) DoubleAPFloat(std::move(RHS.Double));
- } else {
- llvm_unreachable("Unexpected semantics");
+ return;
}
+ llvm_unreachable("Unexpected semantics");
}
Storage &operator=(const Storage &RHS) {
@@ -747,35 +755,29 @@ class APFloat : public APFloatBase {
}
IEEEFloat &getIEEE() {
- if (usesLayout<IEEEFloat>(*U.semantics)) {
+ if (usesLayout<IEEEFloat>(*U.semantics))
return U.IEEE;
- } else if (usesLayout<DoubleAPFloat>(*U.semantics)) {
+ if (usesLayout<DoubleAPFloat>(*U.semantics))
return U.Double.getFirst().U.IEEE;
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
const IEEEFloat &getIEEE() const {
- if (usesLayout<IEEEFloat>(*U.semantics)) {
+ if (usesLayout<IEEEFloat>(*U.semantics))
return U.IEEE;
- } else if (usesLayout<DoubleAPFloat>(*U.semantics)) {
+ if (usesLayout<DoubleAPFloat>(*U.semantics))
return U.Double.getFirst().U.IEEE;
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
void makeZero(bool Neg) { getIEEE().makeZero(Neg); }
void makeInf(bool Neg) {
- if (usesLayout<IEEEFloat>(*U.semantics)) {
+ if (usesLayout<IEEEFloat>(*U.semantics))
return U.IEEE.makeInf(Neg);
- } else if (usesLayout<DoubleAPFloat>(*U.semantics)) {
+ if (usesLayout<DoubleAPFloat>(*U.semantics))
return U.Double.makeInf(Neg);
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
void makeNaN(bool SNaN, bool Neg, const APInt *fill) {
@@ -803,13 +805,11 @@ class APFloat : public APFloatBase {
cmpResult compareAbsoluteValue(const APFloat &RHS) const {
assert(&getSemantics() == &RHS.getSemantics());
- if (usesLayout<IEEEFloat>(getSemantics())) {
+ if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.compareAbsoluteValue(RHS.U.IEEE);
- } else if (usesLayout<DoubleAPFloat>(getSemantics())) {
+ if (usesLayout<DoubleAPFloat>(getSemantics()))
return U.Double.compareAbsoluteValue(RHS.U.Double);
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
public:
@@ -828,13 +828,11 @@ public:
~APFloat() = default;
bool needsCleanup() const {
- if (usesLayout<IEEEFloat>(getSemantics())) {
+ if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.needsCleanup();
- } else if (usesLayout<DoubleAPFloat>(getSemantics())) {
+ if (usesLayout<DoubleAPFloat>(getSemantics()))
return U.Double.needsCleanup();
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
/// Factory for Positive and Negative Zero.
@@ -925,22 +923,18 @@ public:
void Profile(FoldingSetNodeID &NID) const { getIEEE().Profile(NID); }
opStatus add(const APFloat &RHS, roundingMode RM) {
- if (usesLayout<IEEEFloat>(getSemantics())) {
+ if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.add(RHS.U.IEEE, RM);
- } else if (usesLayout<DoubleAPFloat>(getSemantics())) {
+ if (usesLayout<DoubleAPFloat>(getSemantics()))
return U.Double.add(RHS.U.Double, RM);
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
opStatus subtract(const APFloat &RHS, roundingMode RM) {
- if (usesLayout<IEEEFloat>(getSemantics())) {
+ if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.subtract(RHS.U.IEEE, RM);
- } else if (usesLayout<DoubleAPFloat>(getSemantics())) {
+ if (usesLayout<DoubleAPFloat>(getSemantics()))
return U.Double.subtract(RHS.U.Double, RM);
- } else {
- llvm_unreachable("Unexpected semantics");
- }
+ llvm_unreachable("Unexpected semantics");
}
opStatus multiply(const APFloat &RHS, roundingMode RM) {
return getIEEE().multiply(RHS.getIEEE(), RM);
Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=290232&r1=290231&r2=290232&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Tue Dec 20 20:39:21 2016
@@ -4110,13 +4110,15 @@ void DoubleAPFloat::makeNaN(bool SNaN, b
APFloat::Storage::Storage(IEEEFloat F, const fltSemantics &Semantics) {
if (usesLayout<IEEEFloat>(Semantics)) {
new (&IEEE) IEEEFloat(std::move(F));
- } else if (usesLayout<DoubleAPFloat>(Semantics)) {
+ return;
+ }
+ if (usesLayout<DoubleAPFloat>(Semantics)) {
new (&Double)
DoubleAPFloat(Semantics, APFloat(std::move(F), F.getSemantics()),
APFloat(semIEEEdouble));
- } else {
- llvm_unreachable("Unexpected semantics");
+ return;
}
+ llvm_unreachable("Unexpected semantics");
}
APFloat::opStatus APFloat::convertFromString(StringRef Str, roundingMode RM) {
@@ -4135,24 +4137,24 @@ APFloat::opStatus APFloat::convert(const
if (&getSemantics() == &ToSemantics)
return opOK;
if (usesLayout<IEEEFloat>(getSemantics()) &&
- usesLayout<IEEEFloat>(ToSemantics)) {
+ usesLayout<IEEEFloat>(ToSemantics))
return U.IEEE.convert(ToSemantics, RM, losesInfo);
- } else if (usesLayout<IEEEFloat>(getSemantics()) &&
- usesLayout<DoubleAPFloat>(ToSemantics)) {
+ if (usesLayout<IEEEFloat>(getSemantics()) &&
+ usesLayout<DoubleAPFloat>(ToSemantics)) {
assert(&ToSemantics == &semPPCDoubleDouble);
auto Ret = U.IEEE.convert(semPPCDoubleDoubleImpl, RM, losesInfo);
- *this = APFloat(
- DoubleAPFloat(semPPCDoubleDouble, std::move(*this), APFloat(semIEEEdouble)),
- ToSemantics);
+ *this = APFloat(DoubleAPFloat(semPPCDoubleDouble, std::move(*this),
+ APFloat(semIEEEdouble)),
+ ToSemantics);
return Ret;
- } else if (usesLayout<DoubleAPFloat>(getSemantics()) &&
- usesLayout<IEEEFloat>(ToSemantics)) {
+ }
+ if (usesLayout<DoubleAPFloat>(getSemantics()) &&
+ usesLayout<IEEEFloat>(ToSemantics)) {
auto Ret = getIEEE().convert(ToSemantics, RM, losesInfo);
*this = APFloat(std::move(getIEEE()), ToSemantics);
return Ret;
- } else {
- llvm_unreachable("Unexpected semantics");
}
+ llvm_unreachable("Unexpected semantics");
}
APFloat APFloat::getAllOnesValue(unsigned BitWidth, bool isIEEE) {
More information about the llvm-commits
mailing list