| 1 | // RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -config="{CheckOptions: {performance-unnecessary-value-param.AllowedTypes: '[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 | |
| 45 | void negativeSmartPointer(SmartPointer P) { |
| 46 | } |
| 47 | |
| 48 | void negative_smart_pointer(smart_pointer p) { |
| 49 | } |
| 50 | |
| 51 | void negativeSmartPtr(SmartPtr P) { |
| 52 | } |
| 53 | |
| 54 | void negative_smart_ptr(smart_ptr p) { |
| 55 | } |
| 56 | |
| 57 | void negativeSmartReference(SmartReference R) { |
| 58 | } |
| 59 | |
| 60 | void negative_smart_reference(smart_reference r) { |
| 61 | } |
| 62 | |
| 63 | void negativeSmartRef(SmartRef R) { |
| 64 | } |
| 65 | |
| 66 | void negative_smart_ref(smart_ref r) { |
| 67 | } |
| 68 | |
| 69 | void 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 | |
| 74 | void negativeNotTooComplexRef(NotTooComplexRef R) { |
| 75 | } |
| 76 | |