diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-01-08 13:17:14 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-01-08 13:17:14 +0000 |
commit | 7e5d6ed47dcedce35043de59ee00464b681bc786 (patch) | |
tree | beffcfb9a868a8174eb90af526cef29e4ef96b5b | |
parent | 41761d67291ae9ac74843f31737a96157d982c0b (diff) |
Add isSubRegionOf() method to SubRegion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61924 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/PathSensitive/MemRegion.h | 2 | ||||
-rw-r--r-- | lib/Analysis/MemRegion.cpp | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h index 40c6fde51e..80efac4dbf 100644 --- a/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/include/clang/Analysis/PathSensitive/MemRegion.h @@ -100,6 +100,8 @@ public: return superRegion; } + bool isSubRegionOf(const MemRegion* R) const; + static bool classof(const MemRegion* R) { return R->getKind() > SymbolicRegionKind; } diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp index 8767781354..c1b6ed32d5 100644 --- a/lib/Analysis/MemRegion.cpp +++ b/lib/Analysis/MemRegion.cpp @@ -21,6 +21,19 @@ using namespace clang; MemRegion::~MemRegion() {} +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; +} + void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const { ID.AddInteger((unsigned)getKind()); } |