diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/std/memory b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/std/memory index 2ec18dbec18f..201ebd59555f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/std/memory +++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/std/memory @@ -1,8 +1,178 @@ #ifndef _MEMORY_ #define _MEMORY_ +#include "stddef.h" + namespace std { +template +struct default_delete {}; + +template +struct default_delete {}; + +template > +class unique_ptr { +public: + unique_ptr() noexcept {} + explicit unique_ptr(T *p) noexcept {} + unique_ptr(T *p, Deleter d) noexcept {} + unique_ptr(const unique_ptr &) = delete; + unique_ptr(unique_ptr &&t) noexcept {} + template + unique_ptr(unique_ptr &&t) noexcept {} + ~unique_ptr() {} + + T &operator*() const { return *ptr; } + T *operator->() const { return ptr; } + explicit operator bool() const noexcept { return ptr != nullptr; } + + T *get() const { return ptr; } + T *release() { return ptr; } + void reset() {} + void reset(T *p) {} + + unique_ptr &operator=(unique_ptr &) = delete; + template + unique_ptr &operator=(unique_ptr &) = delete; + unique_ptr &operator=(unique_ptr &&) noexcept { return *this; } + template + unique_ptr &operator=(unique_ptr &&) noexcept { return *this; } + + bool operator==(const unique_ptr &) const noexcept { return false; } + bool operator!=(const unique_ptr &) const noexcept { return true; } + +private: + T *ptr = nullptr; +}; + +template +class unique_ptr { +public: + unique_ptr() noexcept {} + template + explicit unique_ptr(U p) noexcept {} + template + unique_ptr(U p, Deleter d) noexcept {} + ~unique_ptr() {} + + T &operator[](size_t i) const { return ptr[i]; } + T *get() const { return ptr; } + explicit operator bool() const noexcept { return ptr != nullptr; } + + void reset() {} + void reset(T *p) {} + +private: + T *ptr = nullptr; +}; + +template +unique_ptr make_unique(Args &&...args) { + return unique_ptr(new T(static_cast(args)...)); +} + +template +class shared_ptr { +public: + shared_ptr() {} + explicit shared_ptr(T *p) {} + template + explicit shared_ptr(Y *p) {} + template + shared_ptr(Y *p, D d) {} + shared_ptr(const shared_ptr &) {} + shared_ptr(shared_ptr &&) {} + ~shared_ptr() {} + + T &operator*() const { return *this->get(); } + T *operator->() const { return this->get(); } + T *get() const { return ptr; } + void reset() {} + void reset(T *p) {} + explicit operator bool() const noexcept { return this->get() != nullptr; } + + shared_ptr &operator=(shared_ptr &&) { return *this; } + template + shared_ptr &operator=(shared_ptr &&) { return *this; } + +private: + T *ptr = nullptr; +}; + +template +class shared_ptr { +public: + shared_ptr() {} + explicit shared_ptr(T *p) {} + template + explicit shared_ptr(Y *p) {} + template + shared_ptr(Y *p, D d) {} + shared_ptr(const shared_ptr &) {} + shared_ptr(shared_ptr &&) {} + ~shared_ptr() {} + + T &operator[](size_t i) const { return ptr[i]; } + T *get() const { return ptr; } + void reset() {} + void reset(T *p) {} + explicit operator bool() const noexcept { return ptr != nullptr; } + +private: + T *ptr = nullptr; +}; + +template +shared_ptr make_shared(Args &&...args) { + return shared_ptr(new T(static_cast(args)...)); +} + +template +class weak_ptr { +public: + weak_ptr() {} + bool expired() const { return true; } +}; + +template +struct auto_ptr_ref { + Y *ptr; +}; + +template +class auto_ptr { +public: + typedef X element_type; + explicit auto_ptr(X *p = 0) throw() {} + auto_ptr(auto_ptr &a) throw() {} + template + auto_ptr(auto_ptr &a) throw() {} + auto_ptr &operator=(auto_ptr &a) throw() { return *this; } + template + auto_ptr &operator=(auto_ptr &a) throw() { return *this; } + auto_ptr &operator=(auto_ptr_ref r) throw() { return *this; } + ~auto_ptr() throw() {} + auto_ptr(auto_ptr_ref r) throw() {} + template + operator auto_ptr_ref() throw() { + auto_ptr_ref r; + r.ptr = ptr; + return r; + } + template + operator auto_ptr() throw() { return auto_ptr(ptr); } + +private: + X *ptr = nullptr; +}; + +template <> +class auto_ptr { +public: + typedef void element_type; +}; + template class allocator {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp index 70449e6bfc24..dab7ef0d071f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp @@ -1,16 +1,6 @@ // RUN: %check_clang_tidy %s bugprone-shared-ptr-array-mismatch %t -namespace std { - -template -struct shared_ptr { - template - explicit shared_ptr(Y *) {} - template - shared_ptr(Y *, Deleter) {} -}; - -} // namespace std +#include struct A {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp index 0386c9bfda35..c0a65f3cb9be 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp @@ -1,27 +1,10 @@ // RUN: %check_clang_tidy %s bugprone-unhandled-self-assignment %t -- -- -fno-delayed-template-parsing #include +#include namespace std { -template class default_delete {}; - -template > -class unique_ptr { -}; - -template -class shared_ptr { -}; - -template -class weak_ptr { -}; - -template -class auto_ptr { -}; - namespace pmr { template class allocator {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp index 494e83dce372..7076461497fc 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp @@ -1,27 +1,6 @@ // RUN: %check_clang_tidy %s bugprone-unique-ptr-array-mismatch %t -namespace std { - -template struct default_delete {}; -template struct default_delete {}; - -template> -class unique_ptr { -public: - explicit unique_ptr(T* p) noexcept; - unique_ptr(T* p, Deleter d1 ) noexcept; -}; - -template -class unique_ptr { -public: - template - explicit unique_ptr(U p) noexcept; - template - unique_ptr(U p, Deleter d1) noexcept; -}; - -} // namespace std +#include struct A {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp index 7ecacabef1a0..3fa87b94dc6b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp @@ -1,6 +1,7 @@ // RUN: %check_clang_tidy %s bugprone-unused-return-value %t -- \ // RUN: --config="{CheckOptions: {bugprone-unused-return-value.AllowCastToVoid: true}}" -- -fexceptions #include +#include namespace std { @@ -26,19 +27,6 @@ ForwardIt remove_if(ForwardIt, ForwardIt, UnaryPredicate); template ForwardIt unique(ForwardIt, ForwardIt); -template -struct default_delete; - -template > -struct unique_ptr { - unique_ptr(); - unique_ptr(unique_ptr const&); - unique_ptr(unique_ptr &&); - unique_ptr& operator=(unique_ptr const&); - unique_ptr& operator=(unique_ptr &&); - T *release() noexcept; -}; - template struct char_traits; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp index 983a7ec578c8..5d95c44fc318 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp @@ -12,38 +12,12 @@ // RUN: -fno-delayed-template-parsing #include +#include typedef decltype(nullptr) nullptr_t; namespace std { -template -struct unique_ptr { - unique_ptr(); - T *get() const; - explicit operator bool() const; - void reset(T *ptr); - T &operator*() const; - T *operator->() const; - T& operator[](size_t i) const; -}; - -template -struct shared_ptr { - shared_ptr(); - T *get() const; - explicit operator bool() const; - void reset(T *ptr); - T &operator*() const; - T *operator->() const; -}; - -template -struct weak_ptr { - weak_ptr(); - bool expired() const; -}; - template struct optional { optional(); @@ -224,7 +198,7 @@ void standardSmartPtr() { // CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here } { - std::unique_ptr ptr; + std::unique_ptr ptr; std::move(ptr); ptr[0]; // CHECK-NOTES: [[@LINE-1]]:5: warning: 'ptr' used after it was moved diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp index 19da88300aec..bd6e1ce301fd 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp @@ -1,11 +1,6 @@ // RUN: %check_clang_tidy %s cppcoreguidelines-avoid-const-or-ref-data-members %t -namespace std { -template -struct unique_ptr {}; -template -struct shared_ptr {}; -} // namespace std +#include namespace gsl { template diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/uniqueptr-reset-release.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/uniqueptr-reset-release.cpp index 629f55a96f3b..f14598d2eb4b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/uniqueptr-reset-release.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/uniqueptr-reset-release.cpp @@ -2,21 +2,7 @@ // CHECK-FIXES: #include -namespace std { - -template -struct default_delete {}; - -template > -struct unique_ptr { - unique_ptr(); - explicit unique_ptr(T *); - template - unique_ptr(unique_ptr &&); - void reset(T *); - T *release(); -}; -} // namespace std +#include struct Foo {}; struct Bar : Foo {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/replace-auto-ptr/memory.h b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/replace-auto-ptr/memory.h deleted file mode 100644 index bc476ced927a..000000000000 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/replace-auto-ptr/memory.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef INPUTS_MEMORY_H -#define INPUTS_MEMORY_H - -namespace std { - -inline namespace _1 { - -template struct auto_ptr_ref { - Y *y_; -}; - -template class auto_ptr { -public: - typedef X element_type; - explicit auto_ptr(X *p = 0) throw() {} - auto_ptr(auto_ptr &) throw() {} - template auto_ptr(auto_ptr &) throw() {} - auto_ptr &operator=(auto_ptr &) throw() { return *this; } - template auto_ptr &operator=(auto_ptr &) throw() { - return *this; - } - auto_ptr &operator=(auto_ptr_ref r) throw() { return *this; } - ~auto_ptr() throw() {} - auto_ptr(auto_ptr_ref r) throw() : x_(r.y_) {} - template operator auto_ptr_ref() throw() { - auto_ptr_ref r; - r.y_ = x_; - return r; - } - template operator auto_ptr() throw() { return auto_ptr(x_); } - -private: - X *x_; -}; - -template <> class auto_ptr { -public: - typedef void element_type; -}; - -} // namespace _1 - -} // end namespace std - -#endif // INPUTS_MEMORY_H diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h index 337cb28228b0..ef00360c87d7 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h @@ -1,33 +1 @@ -namespace std { - -template -class __shared_ptr { -protected: - __shared_ptr(); - __shared_ptr(type *ptr); - ~__shared_ptr(); -public: - type &operator*() { return *ptr; } - type *operator->() { return ptr; } - type *release(); - void reset(); - void reset(type *pt); - -private: - type *ptr; -}; - -template -class shared_ptr : public __shared_ptr { -public: - shared_ptr(); - shared_ptr(type *ptr); - shared_ptr(const shared_ptr &t); - shared_ptr(shared_ptr &&t); - ~shared_ptr(); - shared_ptr &operator=(shared_ptr &&); - template - shared_ptr &operator=(shared_ptr &&); -}; - -} // namespace std +#include diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/unique_ptr.h b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/unique_ptr.h index 5dc9e02b637a..ef00360c87d7 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/unique_ptr.h +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/unique_ptr.h @@ -1,28 +1 @@ -namespace std { - -template -class default_delete {}; - -template > -class unique_ptr { -public: - unique_ptr() {} - unique_ptr(type *ptr) {} - unique_ptr(const unique_ptr &t) = delete; - unique_ptr(unique_ptr &&t) {} - ~unique_ptr() {} - type &operator*() { return *ptr; } - type *operator->() { return ptr; } - type *release() { return ptr; } - void reset() {} - void reset(type *pt) {} - void reset(type pt) {} - unique_ptr &operator=(unique_ptr &&) { return *this; } - template - unique_ptr &operator=(unique_ptr &&) { return *this; } - -private: - type *ptr; -}; - -} // namespace std +#include diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-shared-header.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-shared-header.cpp index 0e95d070ae55..65bf830fd314 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-shared-header.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-shared-header.cpp @@ -2,10 +2,9 @@ // RUN: -config="{CheckOptions: \ // RUN: {modernize-make-shared.MakeSmartPtrFunction: 'my::MakeShared', \ // RUN: modernize-make-shared.MakeSmartPtrFunctionHeader: 'make_shared_util.h' \ -// RUN: }}" \ -// RUN: -- -I %S/Inputs/smart-ptr +// RUN: }}" -#include "shared_ptr.h" +#include // CHECK-FIXES: #include "make_shared_util.h" void f() { diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-cxx11.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-cxx11.cpp index e2944b8080c5..539943e7ba74 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-cxx11.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-cxx11.cpp @@ -1,7 +1,7 @@ -// RUN: %check_clang_tidy -std=c++11 %s modernize-make-unique %t -- -- -I %S/Inputs/smart-ptr +// RUN: %check_clang_tidy -std=c++11 %s modernize-make-unique %t -#include "unique_ptr.h" -// CHECK-FIXES: #include "unique_ptr.h" +#include +// CHECK-FIXES: #include void f() { auto my_ptr = std::unique_ptr(new int(1)); diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-default-init.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-default-init.cpp index 50e7beda68a4..aec7189fb2b5 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-default-init.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-default-init.cpp @@ -2,12 +2,10 @@ // RUN: -config="{CheckOptions: \ // RUN: {modernize-make-unique.IgnoreDefaultInitialization: \ // RUN: 'false'}} \ -// RUN: }" \ -// RUN: -- -I %S/Inputs/smart-ptr +// RUN: }" -#include "unique_ptr.h" +#include #include -// CHECK-FIXES: #include void basic() { std::unique_ptr P1 = std::unique_ptr(new int()); diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-header.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-header.cpp index 5ffd9483a146..d58f52c06194 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-header.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-header.cpp @@ -2,10 +2,9 @@ // RUN: -config="{CheckOptions: \ // RUN: {modernize-make-unique.MakeSmartPtrFunction: 'my::MakeUnique', \ // RUN: modernize-make-unique.MakeSmartPtrFunctionHeader: 'make_unique_util.h' \ -// RUN: }}" \ -// RUN: -- -I %S/Inputs/smart-ptr +// RUN: }}" -#include "unique_ptr.h" +#include // CHECK-FIXES: #include "make_unique_util.h" void f() { diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-macros.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-macros.cpp index 78beb911f5a0..e75daf9938c7 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-macros.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-macros.cpp @@ -2,7 +2,7 @@ // RUN: -config="{CheckOptions: {modernize-make-unique.IgnoreMacros: false}}" \ // RUN: -- -I %S/Inputs/smart-ptr -#include "unique_ptr.h" +#include class Foo {}; class Bar {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/replace-auto-ptr.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/replace-auto-ptr.cpp index 371f3ddf6d65..68c961d92d2d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/replace-auto-ptr.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/replace-auto-ptr.cpp @@ -1,8 +1,8 @@ -// RUN: %check_clang_tidy %s modernize-replace-auto-ptr %t -- -- -isystem %S/Inputs/replace-auto-ptr +// RUN: %check_clang_tidy %s modernize-replace-auto-ptr %t // CHECK-FIXES: #include -#include "memory.h" +#include // Instrumentation for auto_ptr_ref test. struct Base {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp index 7d88c1be2474..bed5c88ed47d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp @@ -8,6 +8,7 @@ // RUN: '::std::make_pair; ::std::make_tuple; ::test::MakeSingle'}}" #include +#include namespace std { template @@ -313,12 +314,6 @@ tuple::type...> make_tuple(Ts &&...) { return {}; } -template -class unique_ptr { -public: - explicit unique_ptr(T *) {} - ~unique_ptr(); -}; } // namespace std namespace llvm { diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp index 21e6c3272016..80b054b74b49 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp @@ -6,7 +6,7 @@ // CHECK-FIXES: #include #include "use-ranges/fake_std.h" -#include "smart-ptr/unique_ptr.h" +#include void Positives() { std::vector I, J; diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call-custom-pointers.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call-custom-pointers.cpp index df3f16a9cf9e..679ba48c6d43 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call-custom-pointers.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call-custom-pointers.cpp @@ -1,10 +1,9 @@ // RUN: %check_clang_tidy %s readability-ambiguous-smartptr-reset-call %t -- \ // RUN: -config='{CheckOptions: \ // RUN: {readability-ambiguous-smartptr-reset-call.SmartPointers: "::std::unique_ptr;::other_ptr"}}' \ -// RUN: --fix-notes -- -I %S/../modernize/Inputs/smart-ptr +// RUN: --fix-notes -#include "unique_ptr.h" -#include "shared_ptr.h" +#include template struct other_ptr { diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call.cpp index e6e7eb9231ec..1e7bfa0df5e3 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call.cpp @@ -1,7 +1,6 @@ -// RUN: %check_clang_tidy %s readability-ambiguous-smartptr-reset-call %t --fix-notes -- -I %S/../modernize/Inputs/smart-ptr +// RUN: %check_clang_tidy %s readability-ambiguous-smartptr-reset-call %t --fix-notes -#include "unique_ptr.h" -#include "shared_ptr.h" +#include template struct non_default_reset_ptr { diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp index 80add8191d32..4fd228a554d7 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp @@ -4,14 +4,7 @@ #include #include #include - -namespace std { -template -struct unique_ptr { - T &operator*() const; - T *operator->() const; -}; -} +#include template void f(const T *); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp index 93dc00845290..2b8b3261ac76 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp @@ -2,6 +2,7 @@ // RUN: -config="{CheckOptions: {readability-container-size-empty.ExcludedComparisonTypes: '::std::array;::IgnoredDummyType'}}" \ // RUN: -- -fno-delayed-template-parsing #include +#include namespace std { template struct vector { @@ -682,14 +683,6 @@ void instantiator() { instantiatedTemplateWithSizeCall>(); } -namespace std { -template -struct unique_ptr { - T *operator->() const; - T &operator*() const; -}; -} // namespace std - bool call_through_unique_ptr(const std::unique_ptr> &ptr) { return ptr->size() > 0; // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-macros.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-macros.cpp index 4c8bb8441435..05b52a67bfc8 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-macros.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-macros.cpp @@ -1,17 +1,7 @@ // RUN: %check_clang_tidy %s readability-redundant-smartptr-get %t -- \ // RUN: -config="{CheckOptions: {readability-redundant-smartptr-get.IgnoreMacros: false}}" -namespace std { - -template -struct shared_ptr { - T &operator*() const; - T *operator->() const; - T *get() const; - explicit operator bool() const noexcept; -}; - -} // namespace std +#include #define MACRO(p) p.get() diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp index 2d88281eb852..b74d28f4873b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp @@ -1,42 +1,9 @@ // RUN: %check_clang_tidy %s readability-redundant-smartptr-get %t #include +#include #define NULL __null -namespace std { - -template -struct unique_ptr { - T& operator*() const; - T* operator->() const; - T* get() const; - explicit operator bool() const noexcept; -}; - -template -struct unique_ptr { - T& operator[](unsigned) const; - T* get() const; - explicit operator bool() const noexcept; -}; - -template -struct shared_ptr { - T& operator*() const; - T* operator->() const; - T* get() const; - explicit operator bool() const noexcept; -}; - -template -struct shared_ptr { - T& operator[](unsigned) const; - T* get() const; - explicit operator bool() const noexcept; -}; - -} // namespace std - struct Bar { void Do(); void ConstDo() const; diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/uniqueptr-delete-release.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/uniqueptr-delete-release.cpp index b4695394f6be..0742b970e772 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/uniqueptr-delete-release.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/uniqueptr-delete-release.cpp @@ -1,24 +1,8 @@ // RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t -check-suffix=NULLPTR // RUN: %check_clang_tidy %s readability-uniqueptr-delete-release %t -check-suffix=RESET -config='{ \ // RUN: CheckOptions: {readability-uniqueptr-delete-release.PreferResetCall: true}}' -namespace std { -template -struct default_delete {}; -template > -class unique_ptr { - public: - unique_ptr(); - ~unique_ptr(); - explicit unique_ptr(T*); - template - unique_ptr(unique_ptr&&); - T* release(); - void reset(T *P = nullptr); - T &operator*() const; - T *operator->() const; -}; -} // namespace std +#include std::unique_ptr& ReturnsAUnique(); @@ -30,7 +14,7 @@ void Positives() { // CHECK-FIXES-NULLPTR: P = nullptr; // CHECK-FIXES-RESET: P.reset(); - auto P2 = P; + auto &P2 = P; delete P2.release(); // CHECK-MESSAGES-NULLPTR: :[[@LINE-1]]:3: warning: prefer '= nullptr' to reset 'unique_ptr<>' objects // CHECK-MESSAGES-RESET: :[[@LINE-2]]:3: warning: prefer 'reset()' to reset 'unique_ptr<>' objects