Revert 68028.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68068 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index 7c13f07..738e8c6 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -111,6 +111,28 @@
// getLValueType() and getRValueType()
//===----------------------------------------------------------------------===//
+QualType SymbolicRegion::getRValueType(ASTContext& C) const {
+ // Get the type of the symbol.
+ QualType T = sym->getType(C);
+
+ if (const PointerType* PTy = T->getAsPointerType())
+ return PTy->getPointeeType();
+
+ if (const BlockPointerType* PTy = T->getAsBlockPointerType())
+ return PTy->getPointeeType();
+
+ // There is no rvalue type of id<...>.
+ if (T->getAsObjCQualifiedIdType())
+ return QualType();
+
+ assert(Loc::IsLocType(T) && "Non-location type.");
+ return QualType();
+}
+
+QualType SymbolicRegion::getLValueType(ASTContext& C) const {
+ return sym->getType(C);
+}
+
QualType ElementRegion::getRValueType(ASTContext& C) const {
// Strip off typedefs from the ArrayRegion's RvalueType.
QualType T = getArrayRegion()->getRValueType(C)->getDesugaredType();
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 0b2d99b..6094806 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -362,13 +362,9 @@
BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
break;
- case loc::SymbolValKind: {
- SymbolRef Sym = cast<loc::SymbolVal>(&BaseL)->getSymbol();
- const SymbolicRegion* SR = MRMgr.getSymbolicRegion(Sym);
- // Layer the type information.
- BaseR = MRMgr.getTypedViewRegion(Sym->getType(getContext()), SR);
+ case loc::SymbolValKind:
+ BaseR = MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(&BaseL)->getSymbol());
break;
- }
case loc::GotoLabelKind:
case loc::FuncValKind:
@@ -411,14 +407,9 @@
const TypedRegion* BaseRegion = 0;
- if (isa<loc::SymbolVal>(Base)) {
- SymbolRef Sym = cast<loc::SymbolVal>(Base).getSymbol();
- SymbolicRegion* SR = MRMgr.getSymbolicRegion(Sym);
- // Layer the type information.
- BaseRegion = MRMgr.getTypedViewRegion(Sym->getType(getContext()), SR);
- }
- else
- BaseRegion = cast<TypedRegion>(cast<loc::MemRegionVal>(Base).getRegion());
+ BaseRegion = isa<loc::SymbolVal>(Base)
+ ? MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(Base).getSymbol())
+ : cast<TypedRegion>(cast<loc::MemRegionVal>(Base).getRegion());
// Pointer of any type can be cast and used as array base.
const ElementRegion *ElemR = dyn_cast<ElementRegion>(BaseRegion);