This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE347551: [clang-tidy] No warning for auto new expression in
smart check (authored by hokein, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D54832?vs=175227&id=175228#toc
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54832/new/
https://reviews.llvm.org/D54832
Files:
clang-tidy/modernize/MakeSmartPtrCheck.cpp
test/clang-tidy/modernize-make-unique.cpp
Index: test/clang-tidy/modernize-make-unique.cpp
===================================================================
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -341,6 +341,9 @@
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
// CHECK-FIXES: PE1 = std::make_unique<E>();
+ // No warnings for `auto` new expression.
+ PE1.reset(new auto(E()));
+
//============================================================================
// NOTE: For initlializer-list constructors, the check only gives warnings,
// and no fixes are generated.
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===================================================================
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -120,6 +120,9 @@
if (New->getNumPlacementArgs() != 0)
return;
+ // Skip when this is a new-expression with `auto`, e.g. new auto(1)
+ if (New->getType()->getPointeeType()->getContainedAutoType())
+ return;
// Be conservative for cases where we construct an array without any
// initalization.
Index: test/clang-tidy/modernize-make-unique.cpp
===================================================================
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -341,6 +341,9 @@
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
// CHECK-FIXES: PE1 = std::make_unique<E>();
+ // No warnings for `auto` new expression.
+ PE1.reset(new auto(E()));
+
//============================================================================
// NOTE: For initlializer-list constructors, the check only gives warnings,
// and no fixes are generated.
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===================================================================
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -120,6 +120,9 @@
if (New->getNumPlacementArgs() != 0)
return;
+ // Skip when this is a new-expression with `auto`, e.g. new auto(1)
+ if (New->getType()->getPointeeType()->getContainedAutoType())
+ return;
// Be conservative for cases where we construct an array without any
// initalization.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits