diff options
| author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-02-17 08:45:06 +0000 |
|---|---|---|
| committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-02-17 08:45:06 +0000 |
| commit | 86bab2cddd665350b724004715df190b4e2be57d (patch) | |
| tree | ae531d33e4e0bc7d8e60fa1a2159ecc6fe8c23a5 /clang | |
| parent | 672bfeffe69bc2f91bc8be5ac65ebbc7b5a190f9 (diff) | |
| download | bcm5719-llvm-86bab2cddd665350b724004715df190b4e2be57d.tar.gz bcm5719-llvm-86bab2cddd665350b724004715df190b4e2be57d.zip | |
Add a utility method.
llvm-svn: 96471
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Analysis/AnalysisContext.h | 2 | ||||
| -rw-r--r-- | clang/lib/Analysis/AnalysisContext.cpp | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/include/clang/Analysis/AnalysisContext.h b/clang/include/clang/Analysis/AnalysisContext.h index ea4f5b20669..bde44174122 100644 --- a/clang/include/clang/Analysis/AnalysisContext.h +++ b/clang/include/clang/Analysis/AnalysisContext.h @@ -110,6 +110,8 @@ public: const LocationContext *getParent() const { return Parent; } + bool isParentOf(const LocationContext *LC) const; + const Decl *getDecl() const { return getAnalysisContext()->getDecl(); } CFG *getCFG() const { return getAnalysisContext()->getCFG(); } diff --git a/clang/lib/Analysis/AnalysisContext.cpp b/clang/lib/Analysis/AnalysisContext.cpp index ccd5088f2ec..d9933e85cb9 100644 --- a/clang/lib/Analysis/AnalysisContext.cpp +++ b/clang/lib/Analysis/AnalysisContext.cpp @@ -186,6 +186,18 @@ LocationContext::getStackFrameForDeclContext(const DeclContext *DC) const { return NULL; } +bool LocationContext::isParentOf(const LocationContext *LC) const { + do { + const LocationContext *Parent = LC->getParent(); + if (Parent == this) + return true; + else + LC = Parent; + } while (LC); + + return false; +} + //===----------------------------------------------------------------------===// // Lazily generated map to query the external variables referenced by a Block. //===----------------------------------------------------------------------===// |

