[PATCH] D62736: [clang-tidy] Fix make-unique check to work in C++17 mode.
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 31 07:35:16 PDT 2019
gribozavr added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp:302
+ if (const auto *CEArg = dyn_cast<CXXConstructExpr>(Arg)) {
+ // Strip the ediable move constructor, it is presented in C++11/14 mode.
+ // e.g. Foo(Bar{1, 2}), the Bar init-list constructor is wrapped around
----------------
s/ediable/elidable/
s/presented/present in the AST/
================
Comment at: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp:304
+ // e.g. Foo(Bar{1, 2}), the Bar init-list constructor is wrapped around
+ // an elidable move constructor.
+ if (CEArg->isElidable()) {
----------------
Isn't it the other way round -- the move constructor is around the init-list constructor?
================
Comment at: clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp:1
-// RUN: %check_clang_tidy -std=c++14 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy -std=c++14,c++17 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
----------------
"-std=c++14-or-later" (will also cover c++2a etc.)
================
Comment at: clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp:457
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<J> PJ2 = std::make_unique<J>(E{1, 2}, 1);
+ // CHECK-FIXES: std::unique_ptr<J> PJ2 = std::unique_ptr<J>(new J(E{1, 2}, 1));
PJ2.reset(new J(E{1, 2}, 1));
----------------
Why do we print the warning if the fixit is not fixing anything?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62736/new/
https://reviews.llvm.org/D62736
More information about the cfe-commits
mailing list