17 lines · cpp
1// RUN: %check_clang_tidy %s cert-oop54-cpp %t2 3// Test whether bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option is set correctly.4class TrivialFields {5public:6 TrivialFields &operator=(const TrivialFields &object) {7 // CHECK-MESSAGES: [[@LINE-1]]:18: warning: operator=() does not handle self-assignment properly [cert-oop54-cpp]8 return *this;9 }10 11private:12 int m;13 float f;14 double d;15 bool b;16};17