diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2019-10-11 12:05:42 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2019-10-11 12:05:42 +0000 |
commit | 885c559369fe3d6323898c17787bd0454065fc34 (patch) | |
tree | ba43b987e078f4c2a033acc71ad3d7f1ee385a11 /clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp | |
parent | 9f6a873268e1ad9855873d9d8007086c0d01cf4f (diff) | |
download | bcm5719-llvm-885c559369fe3d6323898c17787bd0454065fc34.tar.gz bcm5719-llvm-885c559369fe3d6323898c17787bd0454065fc34.zip |
[ClangTidy] Separate tests for infrastructure and checkers
Summary:
This change moves tests for checkers and infrastructure into separate
directories, making it easier to find infrastructure tests. Tests for
checkers are already easy to find because they are named after the
checker. Tests for infrastructure were difficult to find because they
were outnumbered by tests for checkers. Now they are in a separate
directory.
Reviewers: jfb, jdoerfert, lebedev.ri
Subscribers: srhines, nemanjai, aheejin, kbarton, christof, mgrang, arphaman, jfb, lebedev.ri, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68807
llvm-svn: 374540
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp b/clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp deleted file mode 100644 index 2bf1de46de8..00000000000 --- a/clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// RUN: %check_clang_tidy %s performance-move-const-arg %t \ -// RUN: -config='{CheckOptions: \ -// RUN: [{key: performance-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}' - -namespace std { - -template <typename> struct remove_reference; -template <typename _Tp> struct remove_reference { typedef _Tp type; }; -template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; }; -template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; }; - -template <typename _Tp> -constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) { - return static_cast<typename std::remove_reference<_Tp>::type &&>(__t); -} - -template <typename _Tp> -constexpr _Tp && -forward(typename remove_reference<_Tp>::type &__t) noexcept { - return static_cast<_Tp &&>(__t); -} - -} // namespace std - -class NoMoveSemantics { - public: - NoMoveSemantics(); - NoMoveSemantics(const NoMoveSemantics &); - - NoMoveSemantics &operator=(const NoMoveSemantics &); -}; - -void callByConstRef(const NoMoveSemantics &); -void callByConstRef(int i, const NoMoveSemantics &); - -void moveToConstReferencePositives() { - NoMoveSemantics obj; - - // Basic case. It is here just to have a single "detected and fixed" case. - callByConstRef(std::move(obj)); - // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] - // CHECK-FIXES: callByConstRef(obj); -} - -struct TriviallyCopyable { - int i; -}; - -void f(TriviallyCopyable) {} - -void g() { - TriviallyCopyable obj; - f(std::move(obj)); -} - -class MoveSemantics { - public: - MoveSemantics(); - MoveSemantics(MoveSemantics &&); - - MoveSemantics &operator=(MoveSemantics &&); -}; - -void fmovable(MoveSemantics); - -void lambda1() { - auto f = [](MoveSemantics m) { - fmovable(std::move(m)); - }; - f(MoveSemantics()); -} - -template<class T> struct function {}; - -template<typename Result, typename... Args> -class function<Result(Args...)> { -public: - function() = default; - void operator()(Args... args) const { - fmovable(std::forward<Args>(args)...); - } -}; - -void functionInvocation() { - function<void(MoveSemantics)> callback; - MoveSemantics m; - callback(std::move(m)); -} - -void lambda2() { - function<void(MoveSemantics)> callback; - - auto f = [callback = std::move(callback)](MoveSemantics m) mutable { - callback(std::move(m)); - }; - f(MoveSemantics()); -} |