brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 215b09a Raw
31 lines · cpp
1// RUN: %check_clang_tidy -std=c++11-or-later %s readability-reference-to-constructed-temporary %t2 3struct WithConstructor4{5    WithConstructor(int, int);6};7 8struct WithoutConstructor9{10    int a, b;11};12 13void test()14{15// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: reference variable 'tmp1' extends the lifetime of a just-constructed temporary object 'const WithConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]16   const WithConstructor& tmp1{1,2};17 18// CHECK-MESSAGES: :[[@LINE+1]]:30: warning: reference variable 'tmp2' extends the lifetime of a just-constructed temporary object 'const WithoutConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]19   const WithoutConstructor& tmp2{1,2};20 21 22// CHECK-MESSAGES: :[[@LINE+1]]:22: warning: reference variable 'tmp3' extends the lifetime of a just-constructed temporary object 'WithConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]23   WithConstructor&& tmp3{1,2};24 25// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: reference variable 'tmp4' extends the lifetime of a just-constructed temporary object 'WithoutConstructor', consider changing reference to value [readability-reference-to-constructed-temporary]26   WithoutConstructor&& tmp4{1,2};27 28   WithConstructor tmp5{1,2};29   WithoutConstructor tmp6{1,2};30}31