From 8f470db6729f127ee9c3a6f46e9298690e9e6c32 Mon Sep 17 00:00:00 2001 From: Tim Shen Date: Sat, 21 Jan 2017 00:37:53 +0000 Subject: [PATCH] [APFloat] Add asserts and descriptions. NFC. llvm-svn: 292687 --- llvm/include/llvm/ADT/APFloat.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h index 0030423..4188a54 100644 --- a/llvm/include/llvm/ADT/APFloat.h +++ b/llvm/include/llvm/ADT/APFloat.h @@ -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(getSemantics())) return U.IEEE.compareAbsoluteValue(RHS.U.IEEE); if (usesLayout(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(getSemantics())) return U.IEEE.add(RHS.U.IEEE, RM); if (usesLayout(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(getSemantics())) return U.IEEE.subtract(RHS.U.IEEE, RM); if (usesLayout(getSemantics())) -- 2.7.4