[cfe-commits] r71469 - in /cfe/trunk: include/clang/AST/ParentMap.h lib/AST/ParentMap.cpp

Ted Kremenek kremenek at apple.com
Mon May 11 12:49:27 PDT 2009


Author: kremenek
Date: Mon May 11 14:49:27 2009
New Revision: 71469

URL: http://llvm.org/viewvc/llvm-project?rev=71469&view=rev
Log:
Add ParentMap:getParentIgnoreParens().

Modified:
    cfe/trunk/include/clang/AST/ParentMap.h
    cfe/trunk/lib/AST/ParentMap.cpp

Modified: cfe/trunk/include/clang/AST/ParentMap.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ParentMap.h?rev=71469&r1=71468&r2=71469&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ParentMap.h (original)
+++ cfe/trunk/include/clang/AST/ParentMap.h Mon May 11 14:49:27 2009
@@ -24,11 +24,16 @@
   ParentMap(Stmt* ASTRoot);
   ~ParentMap();
 
-  Stmt* getParent(Stmt*) const;
+  Stmt *getParent(Stmt*) const;
+  Stmt *getParentIgnoreParens(Stmt *) const;
 
-  const Stmt* getParent(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;

Modified: cfe/trunk/lib/AST/ParentMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ParentMap.cpp?rev=71469&r1=71468&r2=71469&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ParentMap.cpp (original)
+++ cfe/trunk/lib/AST/ParentMap.cpp Mon May 11 14:49:27 2009
@@ -46,6 +46,11 @@
   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;





More information about the cfe-commits mailing list