[llvm] r292687 - [APFloat] Add asserts and descriptions. NFC.

Tim Shen via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 16:37:53 PST 2017


Author: timshen
Date: Fri Jan 20 18:37:53 2017
New Revision: 292687

URL: http://llvm.org/viewvc/llvm-project?rev=292687&view=rev
Log:
[APFloat] Add asserts and descriptions. NFC.

Modified:
    llvm/trunk/include/llvm/ADT/APFloat.h

Modified: llvm/trunk/include/llvm/ADT/APFloat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APFloat.h?rev=292687&r1=292686&r2=292687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APFloat.h (original)
+++ llvm/trunk/include/llvm/ADT/APFloat.h Fri Jan 20 18:37:53 2017
@@ -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()))




More information about the llvm-commits mailing list