29 lines · cpp
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-ptr4 5#include "unique_ptr.h"6 7class Foo {};8class Bar {};9#define DEFINE(...) __VA_ARGS__10// CHECK-FIXES: #define DEFINE(...) __VA_ARGS__11template<typename 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 instead17 // 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 instead20 // CHECK-FIXES: t->reset(new Foo);21 );22 // CHECK-FIXES: );23}24void macro() {25 std::unique_ptr<Foo> *t;26 g2<Bar>(t);27}28#undef DEFINE29