Index: include/clang/Analysis/PathSensitive/MemRegion.h
===================================================================
--- include/clang/Analysis/PathSensitive/MemRegion.h	（版本 57962）
+++ include/clang/Analysis/PathSensitive/MemRegion.h	（工作副本）
@@ -273,6 +273,8 @@
 
 public:
 
+  SVal getIndex() const { return Index; }
+
   void Profile(llvm::FoldingSetNodeID& ID) const;
 
   static bool classof(const MemRegion* R) {
Index: lib/Analysis/RegionStore.cpp
===================================================================
--- lib/Analysis/RegionStore.cpp	（版本 57977）
+++ lib/Analysis/RegionStore.cpp	（工作副本）
@@ -44,6 +44,8 @@
 
   SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D);
 
+  SVal getLValueElement(const GRState* St, SVal Base, SVal Offset);
+
   SVal Retrieve(Store S, Loc L, QualType T);
 
   Store Bind(Store St, Loc LV, SVal V);
@@ -119,6 +121,43 @@
   return loc::MemRegionVal(MRMgr.getFieldRegion(D, BaseR));
 }
 
+SVal RegionStoreManager::getLValueElement(const GRState* St, 
+                                          SVal Base, SVal Offset) {
+  if (Base.isUnknownOrUndef())
+    return Base;
+
+  Loc BaseL = cast<Loc>(Base);
+
+  switch (BaseL.getSubKind()) {
+  default:
+    assert("Other cases are not handled yet.");
+    return UnknownVal();
+
+  case loc::MemRegionKind: {
+    // We expect BaseR is an ElementRegion, not a base VarRegion.
+    const MemRegion* BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
+
+    const ElementRegion* ElemR = cast<ElementRegion>(BaseR);
+
+    SVal Idx = ElemR->getIndex();
+
+    nonloc::ConcreteInt *CI1, *CI2;
+
+    // Only handle integer indices for now.
+    if ((CI1 = dyn_cast<nonloc::ConcreteInt>(&Idx)) &&
+        (CI2 = dyn_cast<nonloc::ConcreteInt>(&Offset))) {
+      SVal NewIdx = CI1->EvalBinOp(StateMgr.getBasicVals(), BinaryOperator::Add,
+                                   *CI2);
+      return loc::MemRegionVal(MRMgr.getElementRegion(NewIdx, 
+                                                      ElemR->getSuperRegion()));
+    }
+    break;
+  }
+  }
+
+  return UnknownVal();
+}
+
 SVal RegionStoreManager::Retrieve(Store S, Loc L, QualType T) {
   assert(!isa<UnknownVal>(L) && "location unknown");
   assert(!isa<UndefinedVal>(L) && "location undefined");
