aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/IdempotentOperationChecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Checker/IdempotentOperationChecker.cpp')
-rw-r--r--lib/Checker/IdempotentOperationChecker.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp
index 3dcbea491e..7b9ff755a7 100644
--- a/lib/Checker/IdempotentOperationChecker.cpp
+++ b/lib/Checker/IdempotentOperationChecker.cpp
@@ -629,6 +629,13 @@ bool IdempotentOperationChecker::CanVary(const Expr *Ex,
// The next cases require recursion for subexpressions
case Stmt::BinaryOperatorClass: {
const BinaryOperator *B = cast<const BinaryOperator>(Ex);
+
+ // Exclude cases involving pointer arithmetic. These are usually
+ // false positives.
+ if (B->getOpcode() == BO_Sub || B->getOpcode() == BO_Add)
+ if (B->getLHS()->getType()->getAs<PointerType>())
+ return false;
+
return CanVary(B->getRHS(), AC)
|| CanVary(B->getLHS(), AC);
}