From 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 20 Feb 2011 13:06:31 +0000 Subject: Vendor import of clang trunk r126079: http://llvm.org/svn/llvm-project/cfe/trunk@126079 --- lib/AST/ParentMap.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/AST/ParentMap.cpp') diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp index 5fe873a..eca351a 100644 --- a/lib/AST/ParentMap.cpp +++ b/lib/AST/ParentMap.cpp @@ -21,7 +21,7 @@ using namespace clang; typedef llvm::DenseMap MapTy; static void BuildParentMap(MapTy& M, Stmt* S) { - for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I!=E; ++I) + for (Stmt::child_range I = S->children(); I; ++I) if (*I) { M[*I] = S; BuildParentMap(M, *I); @@ -40,6 +40,12 @@ ParentMap::~ParentMap() { delete (MapTy*) Impl; } +void ParentMap::addStmt(Stmt* S) { + if (S) { + BuildParentMap(*(MapTy*) Impl, S); + } +} + Stmt* ParentMap::getParent(Stmt* S) const { MapTy* M = (MapTy*) Impl; MapTy::iterator I = M->find(S); @@ -51,6 +57,15 @@ Stmt *ParentMap::getParentIgnoreParens(Stmt *S) const { return S; } +Stmt *ParentMap::getParentIgnoreParenCasts(Stmt *S) const { + do { + S = getParent(S); + } + while (S && (isa(S) || isa(S))); + + return S; +} + bool ParentMap::isConsumedExpr(Expr* E) const { Stmt *P = getParent(E); Stmt *DirectChild = E; -- cgit v1.1