]> granicus.if.org Git - clang/commitdiff
Add a utility method.
authorZhongxing Xu <xuzhongxing@gmail.com>
Wed, 17 Feb 2010 08:45:06 +0000 (08:45 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Wed, 17 Feb 2010 08:45:06 +0000 (08:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96471 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/AnalysisContext.h
lib/Analysis/AnalysisContext.cpp

index ea4f5b20669c87d401966bc536dc14fc95942cff..bde441741227778d60b01cbde67db6704e8eb46b 100644 (file)
@@ -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(); }
index ccd5088f2ec757ab135b3cf8d15501aa9c8e0685..d9933e85cb9103eebdf9cda50e06e208d0066eab 100644 (file)
@@ -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.
 //===----------------------------------------------------------------------===//