1 // RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -config="{CheckOptions: [{key: performance-unnecessary-value-param.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" -- 2 3 struct SmartPointer { 4 ~SmartPointer(); 5 }; 6 7 struct smart_pointer { 8 ~smart_pointer(); 9 }; 10 11 struct SmartPtr { 12 ~SmartPtr(); 13 }; 14 15 struct smart_ptr { 16 ~smart_ptr(); 17 }; 18 19 struct SmartReference { 20 ~SmartReference(); 21 }; 22 23 struct smart_reference { 24 ~smart_reference(); 25 }; 26 27 struct SmartRef { 28 ~SmartRef(); 29 }; 30 31 struct smart_ref { 32 ~smart_ref(); 33 }; 34 35 struct OtherType { 36 ~OtherType(); 37 }; 38 39 template <typename T> struct SomeComplexTemplate { 40 ~SomeComplexTemplate(); 41 }; 42 43 typedef SomeComplexTemplate<int> NotTooComplexRef; 44 negativeSmartPointer(SmartPointer P)45void negativeSmartPointer(SmartPointer P) { 46 } 47 negative_smart_pointer(smart_pointer p)48void negative_smart_pointer(smart_pointer p) { 49 } 50 negativeSmartPtr(SmartPtr P)51void negativeSmartPtr(SmartPtr P) { 52 } 53 negative_smart_ptr(smart_ptr p)54void negative_smart_ptr(smart_ptr p) { 55 } 56 negativeSmartReference(SmartReference R)57void negativeSmartReference(SmartReference R) { 58 } 59 negative_smart_reference(smart_reference r)60void negative_smart_reference(smart_reference r) { 61 } 62 negativeSmartRef(SmartRef R)63void negativeSmartRef(SmartRef R) { 64 } 65 negative_smart_ref(smart_ref r)66void negative_smart_ref(smart_ref r) { 67 } 68 positiveOtherType(OtherType O)69void positiveOtherType(OtherType O) { 70 // CHECK-MESSAGES: [[@LINE-1]]:34: warning: the parameter 'O' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] 71 // CHECK-FIXES: void positiveOtherType(const OtherType& O) { 72 } 73 negativeNotTooComplexRef(NotTooComplexRef R)74void negativeNotTooComplexRef(NotTooComplexRef R) { 75 } 76