2008-10-04 13:50:14 +08:00
|
|
|
//== MemRegion.cpp - Abstract memory regions for static analysis --*- C++ -*--//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines MemRegion and its subclasses. MemRegion defines a
|
|
|
|
// partially-typed abstraction of memory useful for path-sensitive dataflow
|
|
|
|
// analyses.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
#include "clang/Analysis/PathSensitive/MemRegion.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
2009-06-23 07:13:13 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Basic methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-10-04 13:50:14 +08:00
|
|
|
|
|
|
|
MemRegion::~MemRegion() {}
|
|
|
|
|
2009-01-08 21:17:14 +08:00
|
|
|
bool SubRegion::isSubRegionOf(const MemRegion* R) const {
|
|
|
|
const MemRegion* r = getSuperRegion();
|
|
|
|
while (r != 0) {
|
|
|
|
if (r == R)
|
|
|
|
return true;
|
|
|
|
if (const SubRegion* sr = dyn_cast<SubRegion>(r))
|
|
|
|
r = sr->getSuperRegion();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-23 08:46:41 +08:00
|
|
|
|
|
|
|
MemRegionManager* SubRegion::getMemRegionManager() const {
|
|
|
|
const SubRegion* r = this;
|
|
|
|
do {
|
|
|
|
const MemRegion *superRegion = r->getSuperRegion();
|
|
|
|
if (const SubRegion *sr = dyn_cast<SubRegion>(superRegion)) {
|
|
|
|
r = sr;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return superRegion->getMemRegionManager();
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
|
|
|
ID.AddInteger((unsigned)getKind());
|
|
|
|
}
|
|
|
|
|
2008-10-25 22:13:41 +08:00
|
|
|
void StringRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
|
|
|
const StringLiteral* Str,
|
|
|
|
const MemRegion* superRegion) {
|
|
|
|
ID.AddInteger((unsigned) StringRegionKind);
|
|
|
|
ID.AddPointer(Str);
|
|
|
|
ID.AddPointer(superRegion);
|
|
|
|
}
|
|
|
|
|
2008-11-02 08:34:33 +08:00
|
|
|
void AllocaRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
2009-06-23 08:15:41 +08:00
|
|
|
const Expr* Ex, unsigned cnt,
|
|
|
|
const MemRegion *) {
|
2008-11-02 08:34:33 +08:00
|
|
|
ID.AddInteger((unsigned) AllocaRegionKind);
|
|
|
|
ID.AddPointer(Ex);
|
|
|
|
ID.AddInteger(cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AllocaRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
2009-06-23 08:15:41 +08:00
|
|
|
ProfileRegion(ID, Ex, Cnt, superRegion);
|
2008-11-02 08:34:33 +08:00
|
|
|
}
|
|
|
|
|
2009-03-01 13:44:08 +08:00
|
|
|
void TypedViewRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T,
|
2008-11-16 12:07:26 +08:00
|
|
|
const MemRegion* superRegion) {
|
2009-03-01 13:44:08 +08:00
|
|
|
ID.AddInteger((unsigned) TypedViewRegionKind);
|
2008-11-16 12:07:26 +08:00
|
|
|
ID.Add(T);
|
|
|
|
ID.AddPointer(superRegion);
|
|
|
|
}
|
|
|
|
|
2008-10-28 04:57:58 +08:00
|
|
|
void CompoundLiteralRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
|
|
|
CompoundLiteralRegion::ProfileRegion(ID, CL, superRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompoundLiteralRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
|
|
|
const CompoundLiteralExpr* CL,
|
|
|
|
const MemRegion* superRegion) {
|
|
|
|
ID.AddInteger((unsigned) CompoundLiteralRegionKind);
|
|
|
|
ID.AddPointer(CL);
|
|
|
|
ID.AddPointer(superRegion);
|
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
void DeclRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const Decl* D,
|
|
|
|
const MemRegion* superRegion, Kind k) {
|
|
|
|
ID.AddInteger((unsigned) k);
|
|
|
|
ID.AddPointer(D);
|
|
|
|
ID.AddPointer(superRegion);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeclRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
|
|
|
DeclRegion::ProfileRegion(ID, D, superRegion, getKind());
|
|
|
|
}
|
|
|
|
|
2009-06-23 07:13:13 +08:00
|
|
|
void SymbolicRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, SymbolRef sym,
|
|
|
|
const MemRegion *sreg) {
|
2008-10-18 04:28:54 +08:00
|
|
|
ID.AddInteger((unsigned) MemRegion::SymbolicRegionKind);
|
2008-12-05 10:39:38 +08:00
|
|
|
ID.Add(sym);
|
2009-06-23 07:13:13 +08:00
|
|
|
ID.AddPointer(sreg);
|
2008-10-18 04:28:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SymbolicRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
2009-06-23 07:13:13 +08:00
|
|
|
SymbolicRegion::ProfileRegion(ID, sym, getSuperRegion());
|
2008-10-18 04:28:54 +08:00
|
|
|
}
|
|
|
|
|
2009-05-04 14:18:28 +08:00
|
|
|
void ElementRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
|
|
|
QualType ElementType, SVal Idx,
|
2008-10-21 13:27:10 +08:00
|
|
|
const MemRegion* superRegion) {
|
|
|
|
ID.AddInteger(MemRegion::ElementRegionKind);
|
2009-05-04 14:18:28 +08:00
|
|
|
ID.Add(ElementType);
|
2008-10-21 13:27:10 +08:00
|
|
|
ID.AddPointer(superRegion);
|
|
|
|
Idx.Profile(ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
2009-05-04 14:18:28 +08:00
|
|
|
ElementRegion::ProfileRegion(ID, ElementType, Index, superRegion);
|
2008-10-21 13:27:10 +08:00
|
|
|
}
|
2008-10-27 21:17:02 +08:00
|
|
|
|
2009-04-10 16:45:10 +08:00
|
|
|
void CodeTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const void* data,
|
2009-06-23 11:50:30 +08:00
|
|
|
QualType t, const MemRegion*) {
|
2009-04-10 16:45:10 +08:00
|
|
|
ID.AddInteger(MemRegion::CodeTextRegionKind);
|
|
|
|
ID.AddPointer(data);
|
|
|
|
ID.Add(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeTextRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
2009-06-23 11:50:30 +08:00
|
|
|
CodeTextRegion::ProfileRegion(ID, Data, LocationType, superRegion);
|
2009-04-10 16:45:10 +08:00
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Region pretty-printing.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void MemRegion::dump() const {
|
|
|
|
dumpToStream(llvm::errs());
|
2009-07-03 01:24:10 +08:00
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
std::string MemRegion::getString() const {
|
|
|
|
std::string s;
|
|
|
|
llvm::raw_string_ostream os(s);
|
2009-07-14 07:31:04 +08:00
|
|
|
dumpToStream(os);
|
2008-10-04 13:50:14 +08:00
|
|
|
return os.str();
|
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void MemRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2008-10-04 13:50:14 +08:00
|
|
|
os << "<Unknown Region>";
|
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void AllocaRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2008-11-02 08:34:33 +08:00
|
|
|
os << "alloca{" << (void*) Ex << ',' << Cnt << '}';
|
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void CodeTextRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2009-04-22 03:56:58 +08:00
|
|
|
os << "code{";
|
|
|
|
if (isDeclared())
|
2009-04-29 23:37:24 +08:00
|
|
|
os << getDecl()->getDeclName().getAsString();
|
2009-04-22 03:56:58 +08:00
|
|
|
else
|
|
|
|
os << '$' << getSymbol();
|
|
|
|
|
|
|
|
os << '}';
|
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void CompoundLiteralRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2009-04-22 02:09:22 +08:00
|
|
|
// FIXME: More elaborate pretty-printing.
|
|
|
|
os << "{ " << (void*) CL << " }";
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void ElementRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2009-07-14 07:53:06 +08:00
|
|
|
os << superRegion << '[' << Index << ']';
|
2008-10-18 04:28:54 +08:00
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void FieldRegion::dumpToStream(llvm::raw_ostream& os) const {
|
|
|
|
os << superRegion << "->" << getDecl()->getNameAsString();
|
2008-10-18 05:05:44 +08:00
|
|
|
}
|
|
|
|
|
2009-07-20 04:36:24 +08:00
|
|
|
void ObjCIvarRegion::dumpToStream(llvm::raw_ostream& os) const {
|
|
|
|
os << "ivar{" << superRegion << ',' << getDecl()->getNameAsString() << '}';
|
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void StringRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2009-06-30 09:26:17 +08:00
|
|
|
LangOptions LO; // FIXME.
|
|
|
|
Str->printPretty(os, 0, PrintingPolicy(LO));
|
2008-10-24 14:30:07 +08:00
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void SymbolicRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2009-07-14 07:38:57 +08:00
|
|
|
os << "SymRegion{" << sym << '}';
|
2008-10-28 04:57:58 +08:00
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void TypedViewRegion::dumpToStream(llvm::raw_ostream& os) const {
|
|
|
|
os << "typed_view{" << LValueType.getAsString() << ','
|
|
|
|
<< getSuperRegion() << '}';
|
2009-04-22 02:09:22 +08:00
|
|
|
}
|
|
|
|
|
2009-07-14 07:31:04 +08:00
|
|
|
void VarRegion::dumpToStream(llvm::raw_ostream& os) const {
|
2009-04-22 02:09:22 +08:00
|
|
|
os << cast<VarDecl>(D)->getNameAsString();
|
2008-11-10 21:05:26 +08:00
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MemRegionManager methods.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-06-23 08:46:41 +08:00
|
|
|
MemSpaceRegion* MemRegionManager::LazyAllocate(MemSpaceRegion*& region) {
|
2008-10-04 13:50:14 +08:00
|
|
|
if (!region) {
|
|
|
|
region = (MemSpaceRegion*) A.Allocate<MemSpaceRegion>();
|
2009-06-23 08:46:41 +08:00
|
|
|
new (region) MemSpaceRegion(this);
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
2009-06-23 08:46:41 +08:00
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemSpaceRegion* MemRegionManager::getStackRegion() {
|
|
|
|
return LazyAllocate(stack);
|
|
|
|
}
|
|
|
|
|
2009-07-03 02:14:59 +08:00
|
|
|
MemSpaceRegion* MemRegionManager::getStackArgumentsRegion() {
|
|
|
|
return LazyAllocate(stackArguments);
|
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
MemSpaceRegion* MemRegionManager::getGlobalsRegion() {
|
|
|
|
return LazyAllocate(globals);
|
|
|
|
}
|
|
|
|
|
|
|
|
MemSpaceRegion* MemRegionManager::getHeapRegion() {
|
|
|
|
return LazyAllocate(heap);
|
|
|
|
}
|
|
|
|
|
2008-10-08 10:50:44 +08:00
|
|
|
MemSpaceRegion* MemRegionManager::getUnknownRegion() {
|
|
|
|
return LazyAllocate(unknown);
|
|
|
|
}
|
|
|
|
|
2009-04-10 16:45:10 +08:00
|
|
|
MemSpaceRegion* MemRegionManager::getCodeRegion() {
|
|
|
|
return LazyAllocate(code);
|
|
|
|
}
|
|
|
|
|
2009-06-23 07:13:13 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Constructing regions.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-10-25 22:13:41 +08:00
|
|
|
|
2009-06-23 07:13:13 +08:00
|
|
|
StringRegion* MemRegionManager::getStringRegion(const StringLiteral* Str) {
|
|
|
|
return getRegion<StringRegion>(Str);
|
2008-10-25 22:13:41 +08:00
|
|
|
}
|
|
|
|
|
2008-10-28 05:01:26 +08:00
|
|
|
VarRegion* MemRegionManager::getVarRegion(const VarDecl* d) {
|
2009-06-23 07:13:13 +08:00
|
|
|
return getRegion<VarRegion>(d);
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
|
|
|
|
2008-10-28 04:57:58 +08:00
|
|
|
CompoundLiteralRegion*
|
|
|
|
MemRegionManager::getCompoundLiteralRegion(const CompoundLiteralExpr* CL) {
|
2009-06-23 07:13:13 +08:00
|
|
|
return getRegion<CompoundLiteralRegion>(CL);
|
2008-10-28 04:57:58 +08:00
|
|
|
}
|
|
|
|
|
2008-12-14 03:24:37 +08:00
|
|
|
ElementRegion*
|
2009-05-04 14:18:28 +08:00
|
|
|
MemRegionManager::getElementRegion(QualType elementType, SVal Idx,
|
2009-07-16 09:33:37 +08:00
|
|
|
const MemRegion* superRegion,
|
|
|
|
ASTContext& Ctx){
|
2009-06-16 17:55:50 +08:00
|
|
|
|
|
|
|
QualType T = Ctx.getCanonicalType(elementType);
|
2008-12-14 03:24:37 +08:00
|
|
|
|
2008-10-21 13:27:10 +08:00
|
|
|
llvm::FoldingSetNodeID ID;
|
2009-06-16 17:55:50 +08:00
|
|
|
ElementRegion::ProfileRegion(ID, T, Idx, superRegion);
|
2008-10-21 13:27:10 +08:00
|
|
|
|
|
|
|
void* InsertPos;
|
|
|
|
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
|
|
|
|
ElementRegion* R = cast_or_null<ElementRegion>(data);
|
|
|
|
|
|
|
|
if (!R) {
|
|
|
|
R = (ElementRegion*) A.Allocate<ElementRegion>();
|
2009-06-16 17:55:50 +08:00
|
|
|
new (R) ElementRegion(T, Idx, superRegion);
|
2008-10-21 13:27:10 +08:00
|
|
|
Regions.InsertNode(R, InsertPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return R;
|
|
|
|
}
|
|
|
|
|
2009-04-10 16:45:10 +08:00
|
|
|
CodeTextRegion* MemRegionManager::getCodeTextRegion(const FunctionDecl* fd,
|
|
|
|
QualType t) {
|
2009-06-23 11:50:30 +08:00
|
|
|
return getRegion<CodeTextRegion>(fd, t);
|
2009-04-10 16:45:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CodeTextRegion* MemRegionManager::getCodeTextRegion(SymbolRef sym, QualType t) {
|
2009-06-23 11:50:30 +08:00
|
|
|
return getRegion<CodeTextRegion>(sym, t);
|
2009-04-10 16:45:10 +08:00
|
|
|
}
|
|
|
|
|
2008-10-18 04:28:54 +08:00
|
|
|
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region.
|
2009-03-26 11:35:11 +08:00
|
|
|
SymbolicRegion* MemRegionManager::getSymbolicRegion(SymbolRef sym) {
|
2009-06-23 07:13:13 +08:00
|
|
|
return getRegion<SymbolicRegion>(sym);
|
2008-10-18 04:28:54 +08:00
|
|
|
}
|
|
|
|
|
2008-10-04 13:50:14 +08:00
|
|
|
FieldRegion* MemRegionManager::getFieldRegion(const FieldDecl* d,
|
2008-10-18 04:28:54 +08:00
|
|
|
const MemRegion* superRegion) {
|
2009-07-11 00:51:45 +08:00
|
|
|
return getSubRegion<FieldRegion>(d, superRegion);
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
|
|
|
|
2008-10-18 04:28:54 +08:00
|
|
|
ObjCIvarRegion*
|
|
|
|
MemRegionManager::getObjCIvarRegion(const ObjCIvarDecl* d,
|
|
|
|
const MemRegion* superRegion) {
|
2009-07-11 00:51:45 +08:00
|
|
|
return getSubRegion<ObjCIvarRegion>(d, superRegion);
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
|
|
|
|
2008-10-25 04:30:08 +08:00
|
|
|
ObjCObjectRegion*
|
|
|
|
MemRegionManager::getObjCObjectRegion(const ObjCInterfaceDecl* d,
|
2009-06-23 08:04:09 +08:00
|
|
|
const MemRegion* superRegion) {
|
2009-07-11 00:51:45 +08:00
|
|
|
return getSubRegion<ObjCObjectRegion>(d, superRegion);
|
2008-10-25 04:30:08 +08:00
|
|
|
}
|
|
|
|
|
2009-03-01 13:44:08 +08:00
|
|
|
TypedViewRegion*
|
|
|
|
MemRegionManager::getTypedViewRegion(QualType t, const MemRegion* superRegion) {
|
2009-07-11 00:51:45 +08:00
|
|
|
return getSubRegion<TypedViewRegion>(t, superRegion);
|
2008-11-16 12:07:26 +08:00
|
|
|
}
|
2008-10-25 04:30:08 +08:00
|
|
|
|
2008-11-02 08:34:33 +08:00
|
|
|
AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
|
2009-06-23 08:15:41 +08:00
|
|
|
return getRegion<AllocaRegion>(E, cnt);
|
2008-11-02 08:34:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-24 02:17:08 +08:00
|
|
|
const MemSpaceRegion *MemRegion::getMemorySpace() const {
|
|
|
|
const MemRegion *R = this;
|
|
|
|
const SubRegion* SR = dyn_cast<SubRegion>(this);
|
2008-10-04 13:50:14 +08:00
|
|
|
|
2008-10-18 04:28:54 +08:00
|
|
|
while (SR) {
|
2009-06-24 02:17:08 +08:00
|
|
|
R = SR->getSuperRegion();
|
|
|
|
SR = dyn_cast<SubRegion>(R);
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
2009-06-24 02:17:08 +08:00
|
|
|
|
|
|
|
return dyn_cast<MemSpaceRegion>(R);
|
2008-10-04 13:50:14 +08:00
|
|
|
}
|
2009-04-11 08:11:10 +08:00
|
|
|
|
2009-06-24 02:17:08 +08:00
|
|
|
bool MemRegion::hasStackStorage() const {
|
2009-07-03 02:14:59 +08:00
|
|
|
if (const MemSpaceRegion *MS = getMemorySpace()) {
|
|
|
|
MemRegionManager *Mgr = getMemRegionManager();
|
|
|
|
return MS == Mgr->getStackRegion() || MS == Mgr->getStackArgumentsRegion();
|
|
|
|
}
|
2009-06-23 10:51:21 +08:00
|
|
|
|
2009-06-24 02:17:08 +08:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-23 10:51:21 +08:00
|
|
|
|
2009-06-24 02:17:08 +08:00
|
|
|
bool MemRegion::hasHeapStorage() const {
|
|
|
|
if (const MemSpaceRegion *MS = getMemorySpace())
|
|
|
|
return MS == getMemRegionManager()->getHeapRegion();
|
2009-06-23 10:51:21 +08:00
|
|
|
|
2009-06-24 02:17:08 +08:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-23 10:51:21 +08:00
|
|
|
|
2009-06-24 02:17:08 +08:00
|
|
|
bool MemRegion::hasHeapOrStackStorage() const {
|
|
|
|
if (const MemSpaceRegion *MS = getMemorySpace()) {
|
|
|
|
MemRegionManager *Mgr = getMemRegionManager();
|
2009-07-03 02:14:59 +08:00
|
|
|
return MS == Mgr->getHeapRegion()
|
|
|
|
|| MS == Mgr->getStackRegion()
|
|
|
|
|| MS == Mgr->getStackArgumentsRegion();
|
2009-06-23 10:51:21 +08:00
|
|
|
}
|
|
|
|
return false;
|
2009-07-03 02:25:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MemRegion::hasGlobalsStorage() const {
|
|
|
|
if (const MemSpaceRegion *MS = getMemorySpace())
|
|
|
|
return MS == getMemRegionManager()->getGlobalsRegion();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-03 06:02:15 +08:00
|
|
|
bool MemRegion::hasParametersStorage() const {
|
|
|
|
if (const MemSpaceRegion *MS = getMemorySpace())
|
|
|
|
return MS == getMemRegionManager()->getStackArgumentsRegion();
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-03 02:25:09 +08:00
|
|
|
bool MemRegion::hasGlobalsOrParametersStorage() const {
|
|
|
|
if (const MemSpaceRegion *MS = getMemorySpace()) {
|
|
|
|
MemRegionManager *Mgr = getMemRegionManager();
|
|
|
|
return MS == Mgr->getGlobalsRegion()
|
|
|
|
|| MS == Mgr->getStackArgumentsRegion();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-04-11 08:11:10 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// View handling.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
const MemRegion *TypedViewRegion::removeViews() const {
|
|
|
|
const SubRegion *SR = this;
|
|
|
|
const MemRegion *R = SR;
|
|
|
|
while (SR && isa<TypedViewRegion>(SR)) {
|
|
|
|
R = SR->getSuperRegion();
|
|
|
|
SR = dyn_cast<SubRegion>(R);
|
|
|
|
}
|
|
|
|
return R;
|
|
|
|
}
|