From: John McCall Date: Wed, 5 May 2010 22:59:52 +0000 (+0000) Subject: Add IgnoreParenImpCasts() to Expr, which is basically like IgnoreParenCasts X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fc46bf1a9bc31d50f82de37c70ea257d3cded27;p=clang 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103132 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index cf88faf1a0..43e087abc1 100644 --- a/include/clang/AST/Expr.h +++ b/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/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 057d542b6d..417bc964c8 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1557,6 +1557,18 @@ Expr *Expr::IgnoreParenCasts() { } } +Expr *Expr::IgnoreParenImpCasts() { + Expr *E = this; + while (true) { + if (ParenExpr *P = dyn_cast(E)) + E = P->getSubExpr(); + else if (ImplicitCastExpr *P = dyn_cast(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;