1 | // RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- \ |
2 | // RUN: -config="{CheckOptions: {modernize-make-unique.IgnoreMacros: false}}" \ |
3 | // RUN: -- -I %S/Inputs/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> |
12 | void 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 | } |
24 | void macro() { |
25 | std::unique_ptr<Foo> *t; |
26 | g2<Bar>(t); |
27 | } |
28 | #undef DEFINE |
29 | |