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 | 8ddf7cead8a67342a4584a203e0bf736b7efedbe (patch) | |
tree | b200ceefd541b725a9ffbcfabe0401207f36310d | |
parent | 435c43932e1285d393da35892a80b1ba3b62a0a4 (diff) |
Add a utility method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96471 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Analysis/AnalysisContext.h | 2 | ||||
-rw-r--r-- | lib/Analysis/AnalysisContext.cpp | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h index ea4f5b2066..bde4417412 100644 --- a/include/clang/Analysis/AnalysisContext.h +++ b/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/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp index ccd5088f2e..d9933e85cb 100644 --- a/lib/Analysis/AnalysisContext.cpp +++ b/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. //===----------------------------------------------------------------------===// |