aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-11 19:49:27 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-11 19:49:27 +0000
commitb1b9f680f5fc65230de877baccae50820a969a94 (patch)
tree50a3bbff6d519f0b6c8ac9782692bca75f6633c6
parentd0f8a8d17082266c1e774ca07d58bcd4811b2681 (diff)
Add ParentMap:getParentIgnoreParens().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71469 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ParentMap.h9
-rw-r--r--lib/AST/ParentMap.cpp5
2 files changed, 12 insertions, 2 deletions
diff --git a/include/clang/AST/ParentMap.h b/include/clang/AST/ParentMap.h
index 199a360ca0..c669991ccc 100644
--- a/include/clang/AST/ParentMap.h
+++ b/include/clang/AST/ParentMap.h
@@ -24,11 +24,16 @@ public:
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;
diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp
index 939e6f9be5..9d87daa0bf 100644
--- a/lib/AST/ParentMap.cpp
+++ b/lib/AST/ParentMap.cpp
@@ -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;