[cfe-commits] r68068 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/MemRegion.cpp lib/Analysis/RegionStore.cpp
Ted Kremenek
kremenek at apple.com
Mon Mar 30 14:56:17 PDT 2009
Author: kremenek
Date: Mon Mar 30 16:56:17 2009
New Revision: 68068
URL: http://llvm.org/viewvc/llvm-project?rev=68068&view=rev
Log:
Revert 68028.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
cfe/trunk/lib/Analysis/MemRegion.cpp
cfe/trunk/lib/Analysis/RegionStore.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=68068&r1=68067&r2=68068&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Mon Mar 30 16:56:17 2009
@@ -39,10 +39,10 @@
class MemRegion : public llvm::FoldingSetNode {
public:
enum Kind { MemSpaceRegionKind,
- SymbolicRegionKind,
AllocaRegionKind,
// Typed regions.
BEG_TYPED_REGIONS,
+ SymbolicRegionKind,
CompoundLiteralRegionKind,
StringRegionKind, ElementRegionKind,
TypedViewRegionKind,
@@ -179,18 +179,21 @@
/// either a real region, a NULL pointer, etc. It essentially is used to
/// map the concept of symbolic values into the domain of regions. Symbolic
/// regions do not need to be typed.
-class SymbolicRegion : public SubRegion {
+class SymbolicRegion : public TypedRegion {
protected:
const SymbolRef sym;
public:
SymbolicRegion(const SymbolRef s, const MemRegion* sreg)
- : SubRegion(sreg, SymbolicRegionKind), sym(s) {}
+ : TypedRegion(sreg, SymbolicRegionKind), sym(s) {}
SymbolRef getSymbol() const {
return sym;
}
+ QualType getRValueType(ASTContext& C) const;
+ QualType getLValueType(ASTContext& C) const;
+
void Profile(llvm::FoldingSetNodeID& ID) const;
static void ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym);
Modified: cfe/trunk/lib/Analysis/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/MemRegion.cpp?rev=68068&r1=68067&r2=68068&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Mon Mar 30 16:56:17 2009
@@ -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();
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=68068&r1=68067&r2=68068&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Mon Mar 30 16:56:17 2009
@@ -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);
More information about the cfe-commits
mailing list