Fix APFloat assertion failure in IdempotentOperationChecker resulting in having
an APFloat with different "float semantics" than the compared float literal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108590 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp
index 744fe2b..48b5a59 100644
--- a/lib/Checker/IdempotentOperationChecker.cpp
+++ b/lib/Checker/IdempotentOperationChecker.cpp
@@ -515,10 +515,12 @@
if (IL && IL->getValue() == 1)
return true;
- const FloatingLiteral *FL = dyn_cast<FloatingLiteral>(S);
- const llvm::APFloat one(1.0);
- if (FL && FL->getValue().compare(one) == llvm::APFloat::cmpEqual)
- return true;
+ if (const FloatingLiteral *FL = dyn_cast<FloatingLiteral>(S)) {
+ const llvm::APFloat &val = FL->getValue();
+ const llvm::APFloat one(val.getSemantics(), 1);
+ if (val.compare(one) == llvm::APFloat::cmpEqual)
+ return true;
+ }
for (Stmt::const_child_iterator I = S->child_begin(); I != S->child_end();
++I)