1*af4f2eb4SDaniel // RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t
2*af4f2eb4SDaniel 
3*af4f2eb4SDaniel namespace std {
4*af4f2eb4SDaniel 
5*af4f2eb4SDaniel template <typename T>
6*af4f2eb4SDaniel class vector {
7*af4f2eb4SDaniel public:
push_back(const T &)8*af4f2eb4SDaniel   void push_back(const T &) {}
push_back(T &&)9*af4f2eb4SDaniel   void push_back(T &&) {}
10*af4f2eb4SDaniel 
11*af4f2eb4SDaniel   template <typename... Args>
emplace_back(Args &&...args)12*af4f2eb4SDaniel   void emplace_back(Args &&... args){};
13*af4f2eb4SDaniel };
14*af4f2eb4SDaniel } // namespace std
15*af4f2eb4SDaniel 
16*af4f2eb4SDaniel class Foo {
17*af4f2eb4SDaniel public:
Foo()18*af4f2eb4SDaniel   Foo() : _num1(0)
19*af4f2eb4SDaniel   // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init]
20*af4f2eb4SDaniel   {
21*af4f2eb4SDaniel     _num1 = 10;
22*af4f2eb4SDaniel   }
23*af4f2eb4SDaniel 
use_the_members() const24*af4f2eb4SDaniel   int use_the_members() const {
25*af4f2eb4SDaniel     return _num1 + _num2;
26*af4f2eb4SDaniel   }
27*af4f2eb4SDaniel 
28*af4f2eb4SDaniel private:
29*af4f2eb4SDaniel   int _num1;
30*af4f2eb4SDaniel   int _num2;
31*af4f2eb4SDaniel   // CHECK-FIXES: _num2{};
32*af4f2eb4SDaniel };
33*af4f2eb4SDaniel 
should_use_emplace(std::vector<Foo> & v)34*af4f2eb4SDaniel int should_use_emplace(std::vector<Foo> &v) {
35*af4f2eb4SDaniel   v.push_back(Foo());
36*af4f2eb4SDaniel   // CHECK-FIXES: v.emplace_back();
37*af4f2eb4SDaniel   // CHECK-MESSAGES: warning: use emplace_back instead of push_back [hicpp-use-emplace,modernize-use-emplace]
38*af4f2eb4SDaniel }
39*af4f2eb4SDaniel 
40