Skip to content

Commit

Permalink
[APFloat] Add asserts and descriptions. NFC.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292687 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
timshen91 committed Jan 21, 2017
1 parent e0c77c8 commit f0a2f63
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/llvm/ADT/APFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ class APFloat : public APFloatBase {
: U(std::move(F), S) {}

cmpResult compareAbsoluteValue(const APFloat &RHS) const {
assert(&getSemantics() == &RHS.getSemantics());
assert(&getSemantics() == &RHS.getSemantics() &&
"Should only compare APFloats with the same semantics");
if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.compareAbsoluteValue(RHS.U.IEEE);
if (usesLayout<DoubleAPFloat>(getSemantics()))
Expand Down Expand Up @@ -923,13 +924,17 @@ class APFloat : public APFloatBase {
void Profile(FoldingSetNodeID &NID) const { getIEEE().Profile(NID); }

opStatus add(const APFloat &RHS, roundingMode RM) {
assert(&getSemantics() == &RHS.getSemantics() &&
"Should only call on two APFloats with the same semantics");
if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.add(RHS.U.IEEE, RM);
if (usesLayout<DoubleAPFloat>(getSemantics()))
return U.Double.add(RHS.U.Double, RM);
llvm_unreachable("Unexpected semantics");
}
opStatus subtract(const APFloat &RHS, roundingMode RM) {
assert(&getSemantics() == &RHS.getSemantics() &&
"Should only call on two APFloats with the same semantics");
if (usesLayout<IEEEFloat>(getSemantics()))
return U.IEEE.subtract(RHS.U.IEEE, RM);
if (usesLayout<DoubleAPFloat>(getSemantics()))
Expand Down

0 comments on commit f0a2f63

Please sign in to comment.