1 // RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- \ 2 // RUN: -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: false}]}" \ 3 // RUN: -- -I %S/Inputs/modernize-smart-ptr 4 5 #include "unique_ptr.h" 6 7 class Foo {}; 8 class Bar {}; 9 #define DEFINE(...) __VA_ARGS__ 10 // CHECK-FIXES: {{^}}#define DEFINE(...) __VA_ARGS__{{$}} 11 template<typename T> g2(std::unique_ptr<Foo> * t)12void g2(std::unique_ptr<Foo> *t) { 13 DEFINE( 14 // CHECK-FIXES: {{^ *}}DEFINE({{$}} 15 auto p = std::unique_ptr<Foo>(new Foo); 16 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead 17 // CHECK-FIXES: {{^ *}}auto p = std::unique_ptr<Foo>(new Foo);{{$}} 18 t->reset(new Foo); 19 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead 20 // CHECK-FIXES: {{^ *}}t->reset(new Foo);{{$}} 21 ); 22 // CHECK-FIXES: {{^ *}});{{$}} 23 } macro()24void macro() { 25 std::unique_ptr<Foo> *t; 26 g2<Bar>(t); 27 } 28 #undef DEFINE 29