]> granicus.if.org Git - clang/commitdiff
Add ParentMap:getParentIgnoreParens().
authorTed Kremenek <kremenek@apple.com>
Mon, 11 May 2009 19:49:27 +0000 (19:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 11 May 2009 19:49:27 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71469 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ParentMap.h
lib/AST/ParentMap.cpp

index 199a360ca0dcbaa41a472034dba35bac741ffcd1..c669991ccc088ff099b36159114de4f51366fa33 100644 (file)
@@ -24,11 +24,16 @@ public:
   ParentMap(Stmt* ASTRoot);
   ~ParentMap();
 
-  Stmt* getParent(Stmt*) const;
+  Stmt *getParent(Stmt*) const;
+  Stmt *getParentIgnoreParens(Stmt *) const;
 
-  const StmtgetParent(const Stmt* S) const {
+  const Stmt *getParent(const Stmt* S) const {
     return getParent(const_cast<Stmt*>(S));
   }
+  
+  const Stmt *getParentIgnoreParens(const Stmt *S) const {
+    return getParentIgnoreParens(const_cast<Stmt*>(S));
+  }
 
   bool hasParent(Stmt* S) const {
     return getParent(S) != 0;
index 939e6f9be529ca2e5b07b1192bee6179610eb607..9d87daa0bfd8613e149136dcd90040c5c3122d06 100644 (file)
@@ -46,6 +46,11 @@ Stmt* ParentMap::getParent(Stmt* S) const {
   return I == M->end() ? 0 : I->second;
 }
 
+Stmt *ParentMap::getParentIgnoreParens(Stmt *S) const {
+  do { S = getParent(S); } while (S && isa<ParenExpr>(S));
+  return S;
+}
+
 bool ParentMap::isConsumedExpr(Expr* E) const {
   Stmt *P = getParent(E);
   Stmt *DirectChild = E;