diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-02-05 06:57:29 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-02-05 06:57:29 +0000 |
commit | 9103df1688c3fdd3b2b85bffc026c0f3a07e38b4 (patch) | |
tree | dbbf6758c4fe155e2be6f8364a9d82c9c7aa2038 /clang/lib/Analysis/MemRegion.cpp | |
parent | 7e1d2862ca99296f6bc0e09fc5e1e814ddc648a2 (diff) | |
download | bcm5719-llvm-9103df1688c3fdd3b2b85bffc026c0f3a07e38b4.tar.gz bcm5719-llvm-9103df1688c3fdd3b2b85bffc026c0f3a07e38b4.zip |
Make SymbolicRegion subclass TypedRegion, for symbols usually have types, so
do the symblic regions associated with them and we need them to be typed.
Current SymbolicRegion::getRValueType() method is very restricting. It may be
modified when we are more clear about what could be the types of symblic
regions.
BasicConstraintManager::Assume() is changed due to that now SymblicRegion is a
subclass of SubRegion.
llvm-svn: 63844
Diffstat (limited to 'clang/lib/Analysis/MemRegion.cpp')
-rw-r--r-- | clang/lib/Analysis/MemRegion.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/clang/lib/Analysis/MemRegion.cpp b/clang/lib/Analysis/MemRegion.cpp index 82f44235419..e41c5f937b6 100644 --- a/clang/lib/Analysis/MemRegion.cpp +++ b/clang/lib/Analysis/MemRegion.cpp @@ -107,6 +107,28 @@ void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const { ElementRegion::ProfileRegion(ID, Index, superRegion); } +//===----------------------------------------------------------------------===// +// getLValueType() and getRValueType() +//===----------------------------------------------------------------------===// + +QualType SymbolicRegion::getRValueType(ASTContext& C) const { + const SymbolData& data = SymMgr.getSymbolData(sym); + + // FIXME: We could use the SymbolManager::getType() directly. But that + // would hide the assumptions we made here. What is the type of a symbolic + // region is unclear for other cases. + + // For now we assume the symbol is a typed region rvalue. + const TypedRegion* R + = cast<TypedRegion>(cast<SymbolRegionRValue>(data).getRegion()); + + // Assume the region rvalue has a pointer type, only then we could have a + // symbolic region associated with it. + PointerType* PTy = cast<PointerType>(R->getRValueType(C).getTypePtr()); + + return PTy->getPointeeType(); +} + QualType ElementRegion::getRValueType(ASTContext& C) const { // Strip off typedefs from the ArrayRegion's RvalueType. QualType T = getArrayRegion()->getRValueType(C)->getDesugaredType(); @@ -119,10 +141,6 @@ QualType ElementRegion::getRValueType(ASTContext& C) const { return T; } -//===----------------------------------------------------------------------===// -// getLValueType() and getRValueType() -//===----------------------------------------------------------------------===// - QualType StringRegion::getRValueType(ASTContext& C) const { return Str->getType(); } @@ -308,7 +326,8 @@ MemRegionManager::getElementRegion(SVal Idx, const TypedRegion* superRegion){ } /// getSymbolicRegion - Retrieve or create a "symbolic" memory region. -SymbolicRegion* MemRegionManager::getSymbolicRegion(const SymbolRef sym) { +SymbolicRegion* MemRegionManager::getSymbolicRegion(const SymbolRef sym, + const SymbolManager& mgr) { llvm::FoldingSetNodeID ID; SymbolicRegion::ProfileRegion(ID, sym); @@ -319,7 +338,8 @@ SymbolicRegion* MemRegionManager::getSymbolicRegion(const SymbolRef sym) { if (!R) { R = (SymbolicRegion*) A.Allocate<SymbolicRegion>(); - new (R) SymbolicRegion(sym); + // SymbolicRegion's storage class is usually unknown. + new (R) SymbolicRegion(sym, mgr, getUnknownRegion()); Regions.InsertNode(R, InsertPos); } |