[PATCH] D54745: [clang-tidy] Don't generate incorrect fixes for class with deleted copy/move constructor in smart_ptr check.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 23 07:14:10 PST 2018


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Generally LGTM with a few small nits.



================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:379
+      //
+      // The fix (std::make_unique) requires to see copy/move constructor of
+      // Pair. If we found any invisible or deleted copy/move constructor, we
----------------
requires to see -> needs to see


================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:383
+      // certain about the correct fixes.
+      if (const auto *RD = New->getType()->getPointeeCXXRecordDecl()) {
+        for (const auto *Ctor : RD->ctors()) {
----------------
Don't use `auto` here.


================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:384
+      if (const auto *RD = New->getType()->getPointeeCXXRecordDecl()) {
+        for (const auto *Ctor : RD->ctors()) {
+          if (Ctor->isCopyOrMoveConstructor() &&
----------------
How about:
```
if (llvm::find_if(RD->ctors(), [](const CXXConstructorDecl *CD) {
      return Ctor->isCopyOrMoveConstructor() &&
             (Ctor->isDeleted() || Ctor->getAccess() == AS_private);
    }))
  return false;
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54745





More information about the cfe-commits mailing list