summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-07-17 00:40:32 +0000
committerTed Kremenek <kremenek@apple.com>2010-07-17 00:40:32 +0000
commit8b9fd890e316f804e093ec1003d7fa4a7d2ec85c (patch)
treef5821366ba1794288198a495eee6e432ff196f73 /clang/lib
parent83f250f005d4bfbe5c85c0d998adc55ec16e054a (diff)
downloadbcm5719-llvm-8b9fd890e316f804e093ec1003d7fa4a7d2ec85c.tar.gz
bcm5719-llvm-8b9fd890e316f804e093ec1003d7fa4a7d2ec85c.zip
Fix APFloat assertion failure in IdempotentOperationChecker resulting in having
an APFloat with different "float semantics" than the compared float literal. llvm-svn: 108590
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Checker/IdempotentOperationChecker.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Checker/IdempotentOperationChecker.cpp b/clang/lib/Checker/IdempotentOperationChecker.cpp
index 744fe2ba992..48b5a597caf 100644
--- a/clang/lib/Checker/IdempotentOperationChecker.cpp
+++ b/clang/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)
OpenPOWER on IntegriCloud