[clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit...
authorHaojian Wu <hokein@google.com>
Fri, 4 Mar 2016 08:55:54 +0000 (08:55 +0000)
committerHaojian Wu <hokein@google.com>
Fri, 4 Mar 2016 08:55:54 +0000 (08:55 +0000)
commit678f65a9b4d808fe2f476c43d5acc884927c0377
treec5d1accfdcec9198c3e7742bfb7c6519092bc221
parent22bd871ea66538c1c21929828e2eca2185161c3e
[clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit cast expressions.

Summary:
For some test cases like:

```
 int func(int, void*, void*);
(double)func(0, 0, 0);
```

The AST contains several `ImplicitCastExpr`s, so we should not only check on the first sub expression.

```
 `-CStyleCastExpr 0x7fe43a088938 <line:6:3, col:24> 'double' <NoOp>
      `-ImplicitCastExpr 0x7fe43a088920 <col:11, col:24> 'double' <IntegralToFloating>
        `-CallExpr 0x7fe43a0888a0 <col:11, col:24> 'int'
          |-ImplicitCastExpr 0x7fe43a088888 <col:11> 'int (*)(int, void *, void *)' <FunctionToPointerDecay>
          | `-DeclRefExpr 0x7fe43a0887d8 <col:11> 'int (int, void *, void *)' lvalue Function 0x7fe43a0886f0 'func1' 'int (int, void *, void *)'
          |-IntegerLiteral 0x7fe43a088800 <col:17> 'int' 0
          |-ImplicitCastExpr 0x7fe43a0888e0 <col:20> 'void *' <NullToPointer>
          | `-IntegerLiteral 0x7fe43a088820 <col:20> 'int' 0
          `-ImplicitCastExpr 0x7fe43a0888f8 <col:23> 'void *' <NullToPointer>
            `-IntegerLiteral 0x7fe43a088840 <col:23> 'int' 0
```

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D17849

llvm-svn: 262698
clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/test/clang-tidy/modernize-use-nullptr-basic.cpp