// RUN: %check_clang_tidy -std=c++11-or-later %s performance-no-automatic-move %t struct Obj { Obj(); Obj(const Obj &); Obj(Obj &&); virtual ~Obj(); }; template struct StatusOr { StatusOr(const T &); StatusOr(T &&); }; struct NonTemplate { NonTemplate(const Obj &); NonTemplate(Obj &&); }; template T Make(); StatusOr PositiveStatusOrConstValue() { const Obj obj = Make(); return obj; // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: constness of 'obj' prevents automatic move [performance-no-automatic-move] } NonTemplate PositiveNonTemplateConstValue() { const Obj obj = Make(); return obj; // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: constness of 'obj' prevents automatic move [performance-no-automatic-move] } Obj PositiveSelfConstValue() { const Obj obj = Make(); return obj; // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: constness of 'obj' prevents automatic move [performance-no-automatic-move] } // FIXME: Ideally we would warn here too. NonTemplate PositiveNonTemplateLifetimeExtension() { const Obj &obj = Make(); return obj; } // FIXME: Ideally we would warn here too. StatusOr PositiveStatusOrLifetimeExtension() { const Obj &obj = Make(); return obj; } // Negatives. StatusOr Temporary() { return Make(); } StatusOr ConstTemporary() { return Make(); } StatusOr Nrvo() { Obj obj = Make(); return obj; } StatusOr Ref() { Obj &obj = Make(); return obj; } StatusOr ConstRef() { const Obj &obj = Make(); return obj; } const Obj global; StatusOr Global() { return global; } struct FromConstRefOnly { FromConstRefOnly(const Obj &); }; FromConstRefOnly FromConstRefOnly() { const Obj obj = Make(); return obj; }