summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2014-08-20 16:51:26 +0000
committerJordan Rose <jordan_rose@apple.com>2014-08-20 16:51:26 +0000
commitf3544e913defc63a52fd5e6acfc17fe6f5408711 (patch)
tree1ac4e3c6502e2c2d77b881522b5320eeb0862f39 /clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
parentb6100301e8e0aa4a47b0ef3be8d5d34341d54d53 (diff)
downloadbcm5719-llvm-f3544e913defc63a52fd5e6acfc17fe6f5408711.tar.gz
bcm5719-llvm-f3544e913defc63a52fd5e6acfc17fe6f5408711.zip
[analyzer] IdenticalExpr: don't try to compare integer literals with different widths.
PR20659. Patch by Anders Rönnholm. llvm-svn: 216076
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
index ecb82c9031c..58d0783f397 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
@@ -445,7 +445,12 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
case Stmt::IntegerLiteralClass: {
const IntegerLiteral *IntLit1 = cast<IntegerLiteral>(Stmt1);
const IntegerLiteral *IntLit2 = cast<IntegerLiteral>(Stmt2);
- return IntLit1->getValue() == IntLit2->getValue();
+
+ llvm::APInt I1 = IntLit1->getValue();
+ llvm::APInt I2 = IntLit2->getValue();
+ if (I1.getBitWidth() != I2.getBitWidth())
+ return false;
+ return I1 == I2;
}
case Stmt::FloatingLiteralClass: {
const FloatingLiteral *FloatLit1 = cast<FloatingLiteral>(Stmt1);
OpenPOWER on IntegriCloud