Fix APFloat assertion failure in IdempotentOperationChecker resulting in having
an APFloat with different "float semantics" than the compared float literal.
llvm-svn: 108590
diff --git a/clang/lib/Checker/IdempotentOperationChecker.cpp b/clang/lib/Checker/IdempotentOperationChecker.cpp
index 744fe2b..48b5a59 100644
--- a/clang/lib/Checker/IdempotentOperationChecker.cpp
+++ b/clang/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)