[PATCH] D81769: [clang-tidy] Repair various issues with modernize-avoid-bind

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 23 04:12:44 PDT 2020


njames93 added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:243
+  if ((std::distance(ME->child_begin(), ME->child_end()) == 1) &&
+      isa<CXXThisExpr>(*ME->children().begin())) {
+    // reference to data member without explicit "this"
----------------
jaafar wrote:
> aaron.ballman wrote:
> > jaafar wrote:
> > > Is there a better way to express this? "a single child of type ThisExpr" was what I was going for...
> > `if (isa<CXXThisExpr>(ME->getBase()))` -- `MemberExpr::children()` only considers the base anyway, so there's only ever one child node to begin with.
> Could there be zero? I'm just worried about dereferencing `ME->children().begin()` before verifying there is at least one...
> 
The child nodes in `MemberExpr` just point to one node, its base, which should never be null. Is it not simpler to just use this?
```
if (isa<CXXThisExpr>(ME->getBase())) {
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81769/new/

https://reviews.llvm.org/D81769





More information about the cfe-commits mailing list