This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix a false positive on modernize-use-nullptr check.
ClosedPublic

Authored by hokein on Feb 27 2017, 9:07 AM.

Details

Summary

The false positive happens on two neighbour CXXDefaultArgExpr AST nodes.
like below:

CXXFunctionalCastExpr 0x85c9670 <col:7, col:23> 'struct ZZ' functional cast to struct ZZ <ConstructorConversion>
 `-CXXConstructExpr 0x85c9518 <col:7, col:23> 'struct ZZ' 'void (uint64, const uint64 *)'
   |-CallExpr 0x85a0a90 <col:10, col:22> 'uint64':'unsigned long long'
   | |-ImplicitCastExpr 0x85a0a78 <col:10> 'uint64 (*)(uint64)' <FunctionToPointerDecay>
   | | `-DeclRefExpr 0x85a09f0 <col:10> 'uint64 (uint64)' lvalue Function 0x85a06a0 'Hash' 'uint64 (uint64)'
   | `-CXXDefaultArgExpr 0x85a0ac8 <<invalid sloc>> 'uint64':'unsigned long long'
   `-CXXDefaultArgExpr 0x85c94f8 <<invalid sloc>> 'const uint64 *'

For each particular CXXDefaultArgExpr node, we need to reset
FirstSubExpr, otherwise FirstSubExpr will refer to an incorrect expr.

Event Timeline

hokein created this revision.Feb 27 2017, 9:07 AM
hokein edited the summary of this revision. (Show Details)Feb 27 2017, 9:08 AM
alexfh accepted this revision.Feb 28 2017, 3:14 AM

LG. Thanks for tracking this down!

This revision is now accepted and ready to land.Feb 28 2017, 3:14 AM
This revision was automatically updated to reflect the committed changes.