[PATCH] D54832: [clang-tidy] No fixes for auto new expression in smart check

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


aaron.ballman added inline comments.


================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:255
                                    ASTContext *Ctx) {
+  // Skip when this is a new-expression with `auto`, e.g. "new auto(1)"."
+  if (New->getType()->getPointeeType()->getContainedAutoType())
----------------
Drop the quotation marks.


================
Comment at: test/clang-tidy/modernize-make-unique.cpp:288
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
+  // CHECK-FIXES: PE1.reset(new auto(E()));
+
----------------
It seems like we could also generate the correct replacement for the user here.
```
PE1 = std::make_unique<decltype(E())>();
```
However, I feel like this isn't worth it in general and the correct behavior is to not diagnose in this situation in the first place -- I don't think anyone will find the `make_unique<>` version to be an improvement over the `new auto()` version. What do you think?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54832





More information about the cfe-commits mailing list