summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-24 02:23:11 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-24 02:23:11 +0000
commitcce27f55023428423dbb8ef2ffa64d8140d0bcca (patch)
tree223d51dfef700d45248bef9158ece6c568de7fab /clang/lib
parent3204dac65275ac11e1a1548883b99b0e4068a2a0 (diff)
downloadbcm5719-llvm-cce27f55023428423dbb8ef2ffa64d8140d0bcca.tar.gz
bcm5719-llvm-cce27f55023428423dbb8ef2ffa64d8140d0bcca.zip
Fix <rdar://problem/6611677>: Add basic transfer function support in the static
analyzer for array subscript expressions involving bases that are vectors. This solution is probably a hack: it gets the lvalue of the vector instead of an rvalue like all other types. This should be reviewed (big FIXME in GRExprEngine). llvm-svn: 65366
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp11
-rw-r--r--clang/lib/Analysis/RegionStore.cpp10
2 files changed, 18 insertions, 3 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index 60bef6eb718..d34e8a3ed3a 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -850,7 +850,16 @@ void GRExprEngine::VisitArraySubscriptExpr(ArraySubscriptExpr* A, NodeTy* Pred,
Expr* Base = A->getBase()->IgnoreParens();
Expr* Idx = A->getIdx()->IgnoreParens();
NodeSet Tmp;
- Visit(Base, Pred, Tmp); // Get Base's rvalue, which should be an LocVal.
+
+ if (Base->getType()->isVectorType()) {
+ // For vector types get its lvalue.
+ // FIXME: This may not be correct. Is the rvalue of a vector its location?
+ // In fact, I think this is just a hack. We need to get the right
+ // semantics.
+ VisitLValue(Base, Pred, Tmp);
+ }
+ else
+ Visit(Base, Pred, Tmp); // Get Base's rvalue, which should be an LocVal.
for (NodeSet::iterator I1=Tmp.begin(), E1=Tmp.end(); I1!=E1; ++I1) {
NodeSet Tmp2;
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp
index e2a1d361822..c61094c20cd 100644
--- a/clang/lib/Analysis/RegionStore.cpp
+++ b/clang/lib/Analysis/RegionStore.cpp
@@ -591,9 +591,14 @@ SVal RegionStoreManager::Retrieve(const GRState* St, Loc L, QualType T) {
//
// Such funny addressing will occur due to layering of regions.
- if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
- if (TR->getRValueType(getContext())->isStructureType())
+ if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
+ QualType T =TR->getRValueType(getContext());
+ if (T->isStructureType())
return RetrieveStruct(St, TR);
+ // FIXME: handle Vector types.
+ if (T->isVectorType())
+ return UnknownVal();
+ }
RegionBindingsTy B = GetRegionBindings(St->getStore());
RegionBindingsTy::data_type* V = B.lookup(R);
@@ -636,6 +641,7 @@ SVal RegionStoreManager::Retrieve(const GRState* St, Loc L, QualType T) {
return loc::MemRegionVal(getSelfRegion(0));
}
+
if (MRMgr.onStack(R) || MRMgr.onHeap(R)) {
// All stack variables are considered to have undefined values
// upon creation. All heap allocated blocks are considered to
OpenPOWER on IntegriCloud