mgehre added a comment.

Thank you for the review comments!


================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp:38
@@ +37,3 @@
+  Finder->addMatcher(
+      arraySubscriptExpr(hasBase(implicitCastExpr(hasSourceExpression(
+                             hasType(pointerType()))))).bind("expr"),
----------------
sbenza wrote:
> What is that implicitCastExpr() matching?
> Did you mean to use ignoringImpCasts() instead?
The AST for

```
int* p = 0;
int i;
i = p[1];

```
is

```
-BinaryOperator 0x22dd770 <line:52:3, col:10> 'int' lvalue '='
   |-DeclRefExpr 0x22dd6a8 <col:3> 'int' lvalue Var 0x227fca0 'i' 'int'
   `-ImplicitCastExpr 0x22dd758 <col:7, col:10> 'int' <LValueToRValue>
     `-ArraySubscriptExpr 0x22dd730 <col:7, col:10> 'int' lvalue
       |-ImplicitCastExpr 0x22dd718 <col:7> 'int *' <LValueToRValue>
       | `-DeclRefExpr 0x22dd6d0 <col:7> 'int *' lvalue Var 0x227fdf0 'p' 'int 
*'
       `-IntegerLiteral 0x22dd6f8 <col:9> 'int' 1

```
I guess you are right about ignoringImpCasts(), though.


http://reviews.llvm.org/D13311



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to