diff options
author | John McCall <rjmccall@apple.com> | 2010-05-05 22:59:52 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-05-05 22:59:52 +0000 |
commit | eebc832f4390150b9b695467ad767b5c5950b178 (patch) | |
tree | 7eac535e02f1ff19df1cb4857a11b6a71c2ef31b | |
parent | 3baada6fd7f10407cabb6e005a33cb8409d68ac7 (diff) | |
download | bcm5719-llvm-eebc832f4390150b9b695467ad767b5c5950b178.tar.gz bcm5719-llvm-eebc832f4390150b9b695467ad767b5c5950b178.zip |
Add IgnoreParenImpCasts() to Expr, which is basically like IgnoreParenCasts
except it only skips implicit casts.
Also fix ObjCImplicitGetterSetterRefExpr's child_begin to skip the base expression
if it's actually a type reference (which you get with static property references).
llvm-svn: 103132
-rw-r--r-- | clang/include/clang/AST/Expr.h | 4 | ||||
-rw-r--r-- | clang/lib/AST/Expr.cpp | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index cf88faf1a0b..43e087abc19 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -321,6 +321,10 @@ public: /// or CastExprs, returning their operand. Expr *IgnoreParenCasts(); + /// IgnoreParenImpCasts - Ignore parentheses and implicit casts. Strip off any + /// ParenExpr or ImplicitCastExprs, returning their operand. + Expr *IgnoreParenImpCasts(); + /// IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the /// value (including ptr->int casts of the same size). Strip off any /// ParenExpr or CastExprs, returning their operand. diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 057d542b6d7..417bc964c82 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1557,6 +1557,18 @@ Expr *Expr::IgnoreParenCasts() { } } +Expr *Expr::IgnoreParenImpCasts() { + Expr *E = this; + while (true) { + if (ParenExpr *P = dyn_cast<ParenExpr>(E)) + E = P->getSubExpr(); + else if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E)) + E = P->getSubExpr(); + else + return E; + } +} + /// IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the /// value (including ptr->int casts of the same size). Strip off any /// ParenExpr or CastExprs, returning their operand. @@ -2712,7 +2724,9 @@ Stmt::child_iterator ObjCPropertyRefExpr::child_end() { return &Base+1; } // ObjCImplicitSetterGetterRefExpr Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_begin() { - return &Base; + // If this is accessing a class member, skip that entry. + if (Base) return &Base; + return &Base+1; } Stmt::child_iterator ObjCImplicitSetterGetterRefExpr::child_end() { return &Base+1; |