Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp =================================================================== --- clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ clang-tidy/modernize/MakeSmartPtrCheck.cpp @@ -274,19 +274,17 @@ SourceRange InitRange; if (const auto *NewConstruct = New->getConstructExpr()) { if (NewConstruct->isStdInitListInitialization()) { - // Direct Initialization with the initializer-list constructor. - // struct S { S(std::initializer_list); }; + // FIXME: Add fixes for direct initialization with the initializer-list + // constructor. Unlike ordinal cases, braced list can not be deduced in + // std::make_smart_ptr, we need to specify the type explicitly in the + // fixes, see below. + // struct S { S(std::initializer_list); }; // smart_ptr(new S{1, 2, 3}); // smart_ptr(new S{}); // use initializer-list consturctor // The brace has to be kept, so this has to be replaced with: - // std::make_smart_ptr({1, 2, 3}); - // std::make_smart_ptr({}); - unsigned NumArgs = NewConstruct->getNumArgs(); - if (NumArgs == 0) { - return; - } - InitRange = SourceRange(NewConstruct->getArg(0)->getLocStart(), - NewConstruct->getArg(NumArgs - 1)->getLocEnd()); + // std::make_smart_ptr(std::initializer_list({1, 2, 3})); + // std::make_smart_ptr(std::initializer_list({})); + return; } else { // Direct initialization with ordinary constructors. // struct S { S(int x); S(); }; Index: test/clang-tidy/modernize-make-unique.cpp =================================================================== --- test/clang-tidy/modernize-make-unique.cpp +++ test/clang-tidy/modernize-make-unique.cpp @@ -250,7 +250,6 @@ // Initialization with the initializer-list constructor. std::unique_ptr PE2 = std::unique_ptr(new E{1, 2}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PE2 = std::make_unique({1, 2}); // Initialization with default constructor. std::unique_ptr PF1 = std::unique_ptr(new F()); @@ -265,33 +264,27 @@ // Initialization with the initializer-list constructor. std::unique_ptr PF3 = std::unique_ptr(new F{1}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PF3 = std::make_unique({1}); // Initialization with the initializer-list constructor. std::unique_ptr PF4 = std::unique_ptr(new F{1, 2}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PF4 = std::make_unique({1, 2}); // Initialization with the initializer-list constructor. std::unique_ptr PF5 = std::unique_ptr(new F({1, 2})); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PF5 = std::make_unique({1, 2}); // Initialization with the initializer-list constructor as the default // constructor is not present. std::unique_ptr PG1 = std::unique_ptr(new G{}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PG1 = std::make_unique({}); // Initialization with the initializer-list constructor. std::unique_ptr PG2 = std::unique_ptr(new G{1}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PG2 = std::make_unique({1}); // Initialization with the initializer-list constructor. std::unique_ptr PG3 = std::unique_ptr(new G{1, 2}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead - // CHECK-FIXES: std::unique_ptr PG3 = std::make_unique({1, 2}); std::unique_ptr FF = std::unique_ptr(new Foo()); // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: