From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- .../performance-implicit-conversion-in-loop.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/clang-tidy/test/performance-implicit-conversion-in-loop.cpp (limited to 'tools/clang-tidy/test/performance-implicit-conversion-in-loop.cpp') diff --git a/tools/clang-tidy/test/performance-implicit-conversion-in-loop.cpp b/tools/clang-tidy/test/performance-implicit-conversion-in-loop.cpp new file mode 100644 index 0000000000..75ed510f3f --- /dev/null +++ b/tools/clang-tidy/test/performance-implicit-conversion-in-loop.cpp @@ -0,0 +1,43 @@ +// Iterator returning by value. +template +struct Iterator { + void operator++(); + T operator*(); + bool operator!=(const Iterator& other); +}; + +// The template argument is an iterator type, and a view is an object you can +// run a for loop on. +template +struct View { + T begin(); + T end(); +}; + +// With this class, the implicit conversion is a call to the (implicit) +// constructor of the class. +template +class ImplicitWrapper { + public: + // Implicit! + ImplicitWrapper(const T& t); +}; + +template +class OperatorWrapper { + public: + OperatorWrapper() = delete; +}; + +struct SimpleClass { + int foo; + operator OperatorWrapper(); +}; + +typedef View> SimpleView; + +void ImplicitSimpleClassIterator() { + for (const ImplicitWrapper& foo : SimpleView()) {} + for (const ImplicitWrapper foo : SimpleView()) {} + for (ImplicitWrapper foo : SimpleView()) {} +} -- cgit v1.2.3