diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-07-17 00:40:32 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-07-17 00:40:32 +0000 |
commit | 453293109e670824d84e94c0c2891737e3261f1f (patch) | |
tree | 7803d4cf66a1ed553c26a4fadca864202f045819 /lib/Checker/IdempotentOperationChecker.cpp | |
parent | fbd4bf16341c1b23181c829ef2630d9a643e793c (diff) |
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
Diffstat (limited to 'lib/Checker/IdempotentOperationChecker.cpp')
-rw-r--r-- | lib/Checker/IdempotentOperationChecker.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp index 744fe2ba99..48b5a597ca 100644 --- a/lib/Checker/IdempotentOperationChecker.cpp +++ b/lib/Checker/IdempotentOperationChecker.cpp @@ -515,10 +515,12 @@ bool IdempotentOperationChecker::containsOneConstant(const Stmt *S) { 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) |