From: Zhongxing Xu Date: Thu, 8 Jan 2009 13:17:14 +0000 (+0000) Subject: Add isSubRegionOf() method to SubRegion. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e5d6ed47dcedce35043de59ee00464b681bc786;p=clang Add isSubRegionOf() method to SubRegion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61924 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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(r)) + r = sr->getSuperRegion(); + else + break; + } + return false; +} + void MemSpaceRegion::Profile(llvm::FoldingSetNodeID& ID) const { ID.AddInteger((unsigned)getKind()); }