]> granicus.if.org Git - llvm/commitdiff
[APFloat] Add asserts and descriptions. NFC.
authorTim Shen <timshen91@gmail.com>
Sat, 21 Jan 2017 00:37:53 +0000 (00:37 +0000)
committerTim Shen <timshen91@gmail.com>
Sat, 21 Jan 2017 00:37:53 +0000 (00:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292687 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APFloat.h

index 00304230a991aede965e58047c3343e508c6f1b9..4188a5409e3259f2df551c218f21ab8e60736d2a 100644 (file)
@@ -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()))
@@ -923,6 +924,8 @@ public:
   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()))
@@ -930,6 +933,8 @@ public:
     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()))