@@ -28,6 +28,8 @@ struct ExpensiveToCopyType {
2828 template <typename A>
2929 const A &templatedAccessor () const ;
3030 operator int () const ; // Implicit conversion to int.
31+
32+ static const ExpensiveToCopyType &instance ();
3133};
3234
3335template <typename T>
@@ -100,6 +102,28 @@ void PositiveFunctionCall() {
100102 VarCopyConstructed.constMethod ();
101103}
102104
105+ void PositiveStaticMethodCall () {
106+ const auto AutoAssigned = ExpensiveToCopyType::instance ();
107+ // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
108+ // CHECK-FIXES: const auto& AutoAssigned = ExpensiveToCopyType::instance();
109+ AutoAssigned.constMethod ();
110+
111+ const auto AutoCopyConstructed (ExpensiveToCopyType::instance ());
112+ // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
113+ // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveToCopyType::instance());
114+ AutoCopyConstructed.constMethod ();
115+
116+ const ExpensiveToCopyType VarAssigned = ExpensiveToCopyType::instance ();
117+ // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
118+ // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = ExpensiveToCopyType::instance();
119+ VarAssigned.constMethod ();
120+
121+ const ExpensiveToCopyType VarCopyConstructed (ExpensiveToCopyType::instance ());
122+ // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
123+ // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveToCopyType::instance());
124+ VarCopyConstructed.constMethod ();
125+ }
126+
103127void PositiveMethodCallConstReferenceParam (const ExpensiveToCopyType &Obj) {
104128 const auto AutoAssigned = Obj.reference ();
105129 // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
0 commit comments