This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit cast expressions.
ClosedPublic

Authored by hokein on Mar 3 2016, 6:50 AM.

Details

Summary

For some test cases like:

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

The AST contains several ImplicitCastExprs, 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

Diff Detail

Repository
rL LLVM

Event Timeline

hokein updated this revision to Diff 49736.Mar 3 2016, 6:50 AM
hokein retitled this revision from to [clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit cast expressions..
hokein updated this object.
hokein updated this object.Mar 3 2016, 6:55 AM
hokein added a reviewer: alexfh.
hokein set the repository for this revision to rL LLVM.
hokein added a subscriber: cfe-commits.
alexfh accepted this revision.Mar 3 2016, 9:32 AM
alexfh edited edge metadata.

LG

This revision is now accepted and ready to land.Mar 3 2016, 9:32 AM
This revision was automatically updated to reflect the committed changes.