[clang-tools-extra] [clang-tidy][NFC] Use universal memory mock for smart ptrs (PR #186649)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 01:41:50 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Baranov Victor (vbvictor)
<details>
<summary>Changes</summary>
---
Patch is 27.09 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/186649.diff
26 Files Affected:
- (modified) clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/std/memory (+167)
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp (+1-11)
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/unhandled-self-assignment.cpp (+1-18)
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp (+1-22)
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/unused-return-value.cpp (+1-13)
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp (+2-28)
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp (+1-6)
- (modified) clang-tools-extra/test/clang-tidy/checkers/misc/uniqueptr-reset-release.cpp (+1-15)
- (removed) clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/replace-auto-ptr/memory.h (-45)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/shared_ptr.h (+1-33)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/Inputs/smart-ptr/unique_ptr.h (+1-28)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-shared-header.cpp (+2-3)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-cxx11.cpp (+3-3)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-default-init.cpp (+2-4)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-header.cpp (+2-3)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique-macros.cpp (+1-1)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/replace-auto-ptr.cpp (+1-1)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-emplace.cpp (+1-6)
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp (+1-1)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call-custom-pointers.cpp (+2-3)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/ambiguous-smartptr-reset-call.cpp (+2-3)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp (+1-6)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp (-8)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get-macros.cpp (+1-11)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/redundant-smartptr-get.cpp (+1-34)
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/uniqueptr-delete-release.cpp (+3-19)
``````````diff
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 2ec18dbec18f4..234f168fd1c40 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,175 @@
#ifndef _MEMORY_
#define _MEMORY_
+#include "stddef.h"
+
namespace std {
+template <typename T>
+struct default_delete {};
+
+template <typename T>
+struct default_delete<T[]> {};
+
+template <typename T, typename Deleter = default_delete<T>>
+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 <typename U, typename E>
+ unique_ptr(unique_ptr<U, E> &&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 &&) noexcept { return *this; }
+ template <typename U, typename E>
+ unique_ptr &operator=(unique_ptr<U, E> &&) 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 <typename T, typename Deleter>
+class unique_ptr<T[], Deleter> {
+public:
+ unique_ptr() noexcept {}
+ template <typename U>
+ explicit unique_ptr(U p) noexcept {}
+ template <typename U>
+ 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 <typename T, typename... Args>
+unique_ptr<T> make_unique(Args &&...args) {
+ return unique_ptr<T>(new T(static_cast<Args &&>(args)...));
+}
+
+template <typename T>
+class shared_ptr {
+public:
+ shared_ptr() {}
+ explicit shared_ptr(T *p) {}
+ template <typename Y>
+ explicit shared_ptr(Y *p) {}
+ template <typename Y, typename D>
+ 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 <typename U>
+ shared_ptr &operator=(shared_ptr<U> &&) { return *this; }
+
+private:
+ T *ptr = nullptr;
+};
+
+template <typename T>
+class shared_ptr<T[]> {
+public:
+ shared_ptr() {}
+ explicit shared_ptr(T *p) {}
+ template <typename Y>
+ explicit shared_ptr(Y *p) {}
+ template <typename Y, typename D>
+ 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 <typename T, typename... Args>
+shared_ptr<T> make_shared(Args &&...args) {
+ return shared_ptr<T>(new T(static_cast<Args &&>(args)...));
+}
+
+template <typename T>
+class weak_ptr {
+public:
+ weak_ptr() {}
+ bool expired() const { return true; }
+};
+
+template <typename Y>
+struct auto_ptr_ref {
+ Y *ptr;
+};
+
+template <typename X>
+class auto_ptr {
+public:
+ typedef X element_type;
+ explicit auto_ptr(X *p = 0) throw() {}
+ auto_ptr(auto_ptr &a) throw() {}
+ template <typename Y>
+ auto_ptr(auto_ptr<Y> &a) throw() {}
+ auto_ptr &operator=(auto_ptr &a) throw() { return *this; }
+ template <typename Y>
+ auto_ptr &operator=(auto_ptr<Y> &a) throw() { return *this; }
+ auto_ptr &operator=(auto_ptr_ref<X> r) throw() { return *this; }
+ ~auto_ptr() throw() {}
+ auto_ptr(auto_ptr_ref<X> r) throw() {}
+ template <typename Y>
+ operator auto_ptr_ref<Y>() throw() {
+ auto_ptr_ref<Y> r;
+ r.ptr = ptr;
+ return r;
+ }
+ template <typename Y>
+ operator auto_ptr<Y>() throw() { return auto_ptr<Y>(ptr); }
+
+private:
+ X *ptr = nullptr;
+};
+
+template <>
+class auto_ptr<void> {
+public:
+ typedef void element_type;
+};
+
template <typename T>
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 70449e6bfc24c..dab7ef0d071f5 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 <typename T>
-struct shared_ptr {
- template <class Y>
- explicit shared_ptr(Y *) {}
- template <class Y, class Deleter>
- shared_ptr(Y *, Deleter) {}
-};
-
-} // namespace std
+#include <memory>
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 0386c9bfda359..c0a65f3cb9bef 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 <utility>
+#include <memory>
namespace std {
-template <typename T> class default_delete {};
-
-template <class T, typename Deleter = std::default_delete<T>>
-class unique_ptr {
-};
-
-template <class T>
-class shared_ptr {
-};
-
-template <class T>
-class weak_ptr {
-};
-
-template <class T>
-class auto_ptr {
-};
-
namespace pmr {
template <typename TYPE = void>
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 494e83dce3720..7076461497fc3 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<class T> struct default_delete {};
-template<class T> struct default_delete<T[]> {};
-
-template<class T, class Deleter = std::default_delete<T>>
-class unique_ptr {
-public:
- explicit unique_ptr(T* p) noexcept;
- unique_ptr(T* p, Deleter d1 ) noexcept;
-};
-
-template <class T, class Deleter>
-class unique_ptr<T[], Deleter> {
-public:
- template<class U>
- explicit unique_ptr(U p) noexcept;
- template<class U>
- unique_ptr(U p, Deleter d1) noexcept;
-};
-
-} // namespace std
+#include <memory>
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 7ecacabef1a0b..3fa87b94dc6b4 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 <vector>
+#include <memory>
namespace std {
@@ -26,19 +27,6 @@ ForwardIt remove_if(ForwardIt, ForwardIt, UnaryPredicate);
template <typename ForwardIt>
ForwardIt unique(ForwardIt, ForwardIt);
-template <typename T>
-struct default_delete;
-
-template <typename T, typename Deleter = std::default_delete<T>>
-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 <typename T>
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 983a7ec578c8d..5d95c44fc318f 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 <utility>
+#include <memory>
typedef decltype(nullptr) nullptr_t;
namespace std {
-template <typename T>
-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 <typename T>
-struct shared_ptr {
- shared_ptr();
- T *get() const;
- explicit operator bool() const;
- void reset(T *ptr);
- T &operator*() const;
- T *operator->() const;
-};
-
-template <typename T>
-struct weak_ptr {
- weak_ptr();
- bool expired() const;
-};
-
template <typename T>
struct optional {
optional();
@@ -224,7 +198,7 @@ void standardSmartPtr() {
// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
}
{
- std::unique_ptr<A> ptr;
+ std::unique_ptr<A[]> 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 19da88300aec4..bd6e1ce301fd5 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 <typename T>
-struct unique_ptr {};
-template <typename T>
-struct shared_ptr {};
-} // namespace std
+#include <memory>
namespace gsl {
template <typename T>
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 629f55a96f3b8..f14598d2eb4b9 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 <utility>
-namespace std {
-
-template <typename T>
-struct default_delete {};
-
-template <typename T, class Deleter = std::default_delete<T>>
-struct unique_ptr {
- unique_ptr();
- explicit unique_ptr(T *);
- template <typename U, typename E>
- unique_ptr(unique_ptr<U, E> &&);
- void reset(T *);
- T *release();
-};
-} // namespace std
+#include <memory>
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 bc476ced927a5..0000000000000
--- 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 <class Y> struct auto_ptr_ref {
- Y *y_;
-};
-
-template <class X> class auto_ptr {
-public:
- typedef X element_type;
- explicit auto_ptr(X *p = 0) throw() {}
- auto_ptr(auto_ptr &) throw() {}
- template <class Y> auto_ptr(auto_ptr<Y> &) throw() {}
- auto_ptr &operator=(auto_ptr &) throw() { return *this; }
- template <class Y> auto_ptr &operator=(auto_ptr<Y> &) throw() {
- return *this;
- }
- auto_ptr &operator=(auto_ptr_ref<X> r) throw() { return *this; }
- ~auto_ptr() throw() {}
- auto_ptr(auto_ptr_ref<X> r) throw() : x_(r.y_) {}
- template <class Y> operator auto_ptr_ref<Y>() throw() {
- auto_ptr_ref<Y> r;
- r.y_ = x_;
- return r;
- }
- template <class Y> operator auto_ptr<Y>() throw() { return auto_ptr<Y>(x_); }
-
-private:
- X *x_;
-};
-
-template <> class auto_ptr<void> {
-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 337cb28228b09..ef00360c87d72 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 <typename type>
-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 <typename type>
-class shared_ptr : public __shared_ptr<type> {
-public:
- shared_ptr();
- shared_ptr(type *ptr);
- shared_ptr(const shared_ptr<type> &t);
- shared_ptr(shared_ptr<type> &&t);
- ~shared_ptr();
- shared_ptr &operator=(shared_ptr &&);
- template <typename T>
- shared_ptr &operator=(shared_ptr<T> &&);
-};
-
-} // namespace std
+#include <memory>
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 5dc9e02b637a2..ef00360c87d72 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 <typename T>
-class default_delete {};
-
-template <typename type, typename Deleter = std::default_delete<type>>
-class unique_ptr {
-public:
- unique_ptr() {}
- unique_ptr(type *ptr) {}
- unique_ptr(const unique_ptr<type> &t) = delete;
- unique_ptr(unique_ptr<type> &&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 <typename T>
- unique_ptr &operator=(unique_ptr<T> &&) { return *this; }
-
-private:
- type *ptr;
-};
-
-} // namespace std
+#include <memory>
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 0e95d070ae55e..65bf830fd3142 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 <memory>
// 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 e2944b8080c53..539943e7ba749 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 <memory>
+// CHECK-FIXES: #include <memory>
void f() {
auto my_ptr = std::unique_ptr<int>(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 50e7beda68a43..aec7189fb2b51 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 <memory>
#include <vector>
-// CHECK-FIXES: #include <memory>
void basic() {
std::unique_ptr<int> P1 = std::unique_ptr<int>(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 5ffd9483a146a..d58f52c06194e 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 <memory>
// 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 78beb911f5a0a..e75daf9938c73 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 <memory>
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 371f3ddf6d650..d1d70b788a789 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
@@ -2,7 +2,7 @@
// CHECK-FIXES: #include <utility>
-#include "memory.h"
+#include <memory>
// 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 7d88c1be24747..bed5c88ed47d8 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 <utility>
+#include <memory>
namespace std {
template <typename E>
@@ -313,12 +314,6 @@ tuple<typename remove_reference<Ts>::type...> make_tuple(Ts &&...) {
return {};
}
-template <typename T>
-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 21e6c32720163..80b054b74b49a 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/m...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/186649
More information about the cfe-commits
mailing list