aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngine.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-11-08 03:45:42 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-11-08 03:45:42 +0000
commit60156f0596a7ab9a39ddec74942b60a3da847174 (patch)
tree1d6eed45fd4d4bf5abf67bc83ec08a54ff7804e5 /lib/Analysis/GRExprEngine.cpp
parent99163252709b0c8334d8a49388344aaa2f0f3361 (diff)
Add a boilerplate for out-of-bound array checking. This has no real function currently.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58886 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r--lib/Analysis/GRExprEngine.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index e2c23b4942..8f8a143863 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1067,6 +1067,28 @@ const GRState* GRExprEngine::EvalLocation(Expr* Ex, NodeTy* Pred,
else ExplicitNullDeref.insert(NullNode);
}
}
+
+ // Check for out-of-bound array access.
+ if (isFeasibleNotNull && isa<loc::MemRegionVal>(LV)) {
+ const MemRegion* R = cast<loc::MemRegionVal>(LV).getRegion();
+ if (const ElementRegion* ER = dyn_cast<ElementRegion>(R)) {
+ // Get the index of the accessed element.
+ SVal Idx = ER->getIndex();
+ // Get the extent of the array.
+ SVal NumElements = StateMgr.getStoreManager().getSizeInElements(StNotNull,
+ ER->getSuperRegion());
+
+ bool isFeasibleInBound = false;
+ const GRState* StInBound = AssumeInBound(StNotNull, Idx, NumElements,
+ true, isFeasibleInBound);
+
+ bool isFeasibleOutBound = false;
+ const GRState* StOutBound = AssumeInBound(StNotNull, Idx, NumElements,
+ false, isFeasibleOutBound);
+
+ // Report warnings ...
+ }
+ }
return isFeasibleNotNull ? StNotNull : NULL;
}