summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/PointerSubChecker.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-11-10 02:37:53 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-11-10 02:37:53 +0000
commit80bbc6d13828984633d90445ca24997450abbc9e (patch)
tree451ad5db76dda608c4bb2af9355033d993973a76 /clang/lib/Analysis/PointerSubChecker.cpp
parent05671ea10af98ae128b9d7447e43b287c9e40a16 (diff)
downloadbcm5719-llvm-80bbc6d13828984633d90445ca24997450abbc9e.tar.gz
bcm5719-llvm-80bbc6d13828984633d90445ca24997450abbc9e.zip
Refine PointerSubChecker: compare the base region instead of the original
region, so that arithmetic within a memory chunk is allowed. llvm-svn: 86652
Diffstat (limited to 'clang/lib/Analysis/PointerSubChecker.cpp')
-rw-r--r--clang/lib/Analysis/PointerSubChecker.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Analysis/PointerSubChecker.cpp b/clang/lib/Analysis/PointerSubChecker.cpp
index 5cac8aa99e7..20279c67b3e 100644
--- a/clang/lib/Analysis/PointerSubChecker.cpp
+++ b/clang/lib/Analysis/PointerSubChecker.cpp
@@ -48,11 +48,17 @@ void PointerSubChecker::PreVisitBinaryOperator(CheckerContext &C,
const MemRegion *LR = LV.getAsRegion();
const MemRegion *RR = RV.getAsRegion();
- if (!(LR && RR) || (LR == RR))
+ if (!(LR && RR))
return;
- // We don't reason about SymbolicRegions for now.
- if (isa<SymbolicRegion>(LR) || isa<SymbolicRegion>(RR))
+ const MemRegion *BaseLR = LR->getBaseRegion();
+ const MemRegion *BaseRR = RR->getBaseRegion();
+
+ if (BaseLR == BaseRR)
+ return;
+
+ // Allow arithmetic on different symbolic regions.
+ if (isa<SymbolicRegion>(BaseLR) || isa<SymbolicRegion>(BaseRR))
return;
if (ExplodedNode *N = C.GenerateNode(B)) {
OpenPOWER on IntegriCloud