Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dodicidodici committed Jan 11, 2025
1 parent d3a09b5 commit 9280db3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void ExplicitMoveConstructorCheck::check(

auto Diag = diag(
MoveCtor->getLocation(),
"copy constructor may be called instead of explicit move constructor");
"copy constructor may be called instead of move constructor");
SourceRange ExplicitTokenRange =
findExplicitToken(MoveCtor, *Result.SourceManager, getLangOpts());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// RUN: %check_clang_tidy %s performance-explicit-move-constructor %t

class NotReported1 {};

class NotReported2 {
public:
NotReported2(NotReported2&&) = default;
NotReported2(const NotReported2&) = default;
};

class NotReported3 {
public:
explicit NotReported3(NotReported3&&) = default;
};

class NotReported4 {
public:
explicit NotReported4(NotReported4&&) = default;
NotReported4(const NotReported4&) = delete;
};

class NotReported5 {
public:
explicit NotReported5(NotReported5&&) = delete;
NotReported5(const NotReported5&) = default;
};

class Reported {
public:
explicit Reported(Reported&&) = default;
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: copy constructor may be called instead of move constructor [performance-explicit-move-constructor]
// CHECK-FIXES: {{^}}Reported(Reported&&) = default;{{$}}
Reported(const Reported&) = default;
};

0 comments on commit 9280db3

Please sign in to comment.