https://github.com/zeyi2 updated 
https://github.com/llvm/llvm-project/pull/185210

>From 4b593c898ca9b1104e4e7ed7eb72cf6725b0de7f Mon Sep 17 00:00:00 2001
From: mtx <[email protected]>
Date: Sun, 8 Mar 2026 01:23:54 +0800
Subject: [PATCH 1/2] [clang-tidy][NFC] Add missing Option tests in
 cppcoreguidelines and performance [3/N]

---
 .../checkers/Inputs/Headers/utility           | 18 +++++++++
 .../init-variables-mathheader.cpp             | 13 ++++++
 ...unds-constant-array-index-includestyle.cpp | 28 +++++++++++++
 ...nefficient-string-concatenation-strict.cpp | 27 +++++++++++++
 .../no-automatic-move-allowed-types.cpp       | 40 +++++++++++++++++++
 ...type-promotion-in-math-fn-includestyle.cpp | 13 ++++++
 .../unnecessary-value-param-includestyle.cpp  | 22 ++++++++++
 .../performance/unnecessary-value-param.cpp   | 27 +------------
 8 files changed, 163 insertions(+), 25 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/utility
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables-mathheader.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index-includestyle.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/performance/no-automatic-move-allowed-types.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/performance/type-promotion-in-math-fn-includestyle.cpp
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-includestyle.cpp

diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/utility 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/utility
new file mode 100644
index 0000000000000..30e170b5decc1
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/utility
@@ -0,0 +1,18 @@
+#ifndef _UTILITY_
+#define _UTILITY_
+
+namespace std {
+template <typename T>
+struct remove_reference { typedef T type; };
+template <typename T>
+struct remove_reference<T &> { typedef T type; };
+template <typename T>
+struct remove_reference<T &&> { typedef T type; };
+
+template <typename _Tp>
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+  return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
+}
+} // namespace std
+
+#endif // _UTILITY_
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables-mathheader.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables-mathheader.cpp
new file mode 100644
index 0000000000000..f5e236b895202
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables-mathheader.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- \
+// RUN:   -config="{CheckOptions: { \
+// RUN:     cppcoreguidelines-init-variables.IncludeStyle: 'google', \
+// RUN:     cppcoreguidelines-init-variables.MathHeader: '<cmath>' \
+// RUN:   }}" -- -fexceptions
+
+// CHECK-FIXES: #include <cmath>
+
+void init_unit_tests() {
+  float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'f' is not initialized 
[cppcoreguidelines-init-variables]
+  // CHECK-FIXES: float f = NAN;
+}
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index-includestyle.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index-includestyle.cpp
new file mode 100644
index 0000000000000..8f277f74befb7
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index-includestyle.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index 
%t -- \
+// RUN:   -config="{CheckOptions: { \
+// RUN:     cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: 
'dir1/gslheader.h', \
+// RUN:     cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: 
'google' \
+// RUN:   }}"
+
+// CHECK-FIXES: #include "dir1/gslheader.h"
+
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+  template<typename T, size_t N>
+  struct array {
+    T& operator[](size_t n);
+    T& at(size_t n);
+  };
+}
+
+namespace gsl {
+  template<class T, size_t N>
+  T& at( std::array<T, N> &a, size_t index );
+}
+
+void f(std::array<int, 10> a, int pos) {
+  a [ pos / 2 ] = 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use array subscript when 
the index is not an integer constant expression 
[cppcoreguidelines-pro-bounds-constant-array-index]
+  // CHECK-FIXES: gsl::at(a,  pos / 2 ) = 1;
+}
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
new file mode 100644
index 0000000000000..f4d042255aec2
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t 
-- \
+// RUN:   -config="{CheckOptions: 
{performance-inefficient-string-concatenation.StrictMode: true}}"
+
+namespace std {
+template <typename T>
+class basic_string {
+public:
+  basic_string() {}
+  ~basic_string() {}
+  basic_string<T> *operator+=(const basic_string<T> &);
+  friend basic_string<T> operator+(const basic_string<T> &, const 
basic_string<T> &);
+};
+typedef basic_string<char> string;
+}
+
+void f(std::string) {}
+
+int main() {
+  std::string mystr1, mystr2;
+  mystr1 = mystr1 + mystr2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string concatenation results in 
allocation of unnecessary temporary strings; consider using 'operator+=' or 
'string::append()' instead [performance-inefficient-string-concatenation]
+
+  f(mystr1 + mystr2 + mystr1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: string concatenation results in 
allocation of unnecessary temporary strings; consider using 'operator+=' or 
'string::append()' instead
+
+  return 0;
+}
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/no-automatic-move-allowed-types.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/no-automatic-move-allowed-types.cpp
new file mode 100644
index 0000000000000..f0a3e5f319d95
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/no-automatic-move-allowed-types.cpp
@@ -0,0 +1,40 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s performance-no-automatic-move 
%t -- \
+// RUN:   -config="{CheckOptions: {performance-no-automatic-move.AllowedTypes: 
'::Obj'}}"
+
+struct Obj {
+  Obj();
+  Obj(const Obj &);
+  Obj(Obj &&);
+  virtual ~Obj();
+};
+
+struct NonTemplate {
+  NonTemplate(const Obj &);
+  NonTemplate(Obj &&);
+};
+
+template <typename T>
+T Make();
+
+NonTemplate PositiveNonTemplate() {
+  const Obj obj = Make<Obj>();
+  return obj; // No warning because Obj is allowed.
+}
+
+struct Other {
+  Other();
+  Other(const Other &);
+  Other(Other &&);
+  virtual ~Other();
+};
+
+struct OtherNonTemplate {
+  OtherNonTemplate(const Other &);
+  OtherNonTemplate(Other &&);
+};
+
+OtherNonTemplate PositiveOtherNonTemplate() {
+  const Other obj = Make<Other>();
+  return obj;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: constness of 'obj' prevents 
automatic move [performance-no-automatic-move]
+}
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/type-promotion-in-math-fn-includestyle.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/type-promotion-in-math-fn-includestyle.cpp
new file mode 100644
index 0000000000000..747aa8200368d
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/type-promotion-in-math-fn-includestyle.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t -- \
+// RUN:   -config="{CheckOptions: 
{performance-type-promotion-in-math-fn.IncludeStyle: 'google'}}"
+
+// CHECK-FIXES: #include <cmath>
+
+double acos(double);
+
+void check() {
+  float a;
+  acos(a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to 
double [performance-type-promotion-in-math-fn]
+  // CHECK-FIXES: std::acos(a);
+}
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-includestyle.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-includestyle.cpp
new file mode 100644
index 0000000000000..d5d99a9b6f018
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-includestyle.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- \
+// RUN:   -config="{CheckOptions: 
{performance-unnecessary-value-param.IncludeStyle: 'google' \
+// RUN: }}" -- -isystem %clang_tidy_headers -fno-delayed-template-parsing
+
+// CHECK-FIXES: #include <utility>
+
+#include <utility>
+
+struct ExpensiveMovableType {
+  ExpensiveMovableType();
+  ExpensiveMovableType(ExpensiveMovableType &&);
+  ExpensiveMovableType(const ExpensiveMovableType &) = default;
+  ExpensiveMovableType &operator=(const ExpensiveMovableType &) = default;
+  ExpensiveMovableType &operator=(ExpensiveMovableType &&);
+  ~ExpensiveMovableType();
+};
+
+void PositiveMoveOnCopyConstruction(ExpensiveMovableType E) {
+  auto F = E;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'E' of type 
'ExpensiveMovableType' is passed by value and only copied once; consider moving 
it to avoid unnecessary copies [performance-unnecessary-value-param]
+  // CHECK-FIXES: auto F = std::move(E);
+}
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
index 8dc13d3ed7f85..327b676228a7f 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
@@ -1,31 +1,8 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- 
-isystem %clang_tidy_headers -fno-delayed-template-parsing
 
 // CHECK-FIXES: #include <utility>
 
-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);
-}
-} // namespace std
+#include <utility>
 
 struct ExpensiveToCopyType {
   const ExpensiveToCopyType & constReference() const {

>From b9df0075cccfe4595183b32ef7ae7adabb5bbb67 Mon Sep 17 00:00:00 2001
From: mtx <[email protected]>
Date: Mon, 9 Mar 2026 16:19:21 +0800
Subject: [PATCH 2/2] better?

---
 .../clang-tidy/checkers/Inputs/Headers/string     |  4 ++++
 .../inefficient-string-concatenation-strict.cpp   | 15 +++------------
 .../inefficient-string-concatenation.cpp          | 15 ++-------------
 3 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
index 7de709d07f2df..5744224d8d053 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
+++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
@@ -158,6 +158,10 @@ std::string operator+(const std::string&, const 
std::string&);
 std::string operator+(const std::string&, const char*);
 std::string operator+(const char*, const std::string&);
 
+std::wstring operator+(const std::wstring&, const std::wstring&);
+std::wstring operator+(const std::wstring&, const wchar_t*);
+std::wstring operator+(const wchar_t*, const std::wstring&);
+
 bool operator==(const std::string&, const std::string&);
 bool operator==(const std::string&, const char*);
 bool operator==(const char*, const std::string&);
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
index f4d042255aec2..9b3dc11c585bf 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation-strict.cpp
@@ -1,17 +1,8 @@
 // RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t 
-- \
-// RUN:   -config="{CheckOptions: 
{performance-inefficient-string-concatenation.StrictMode: true}}"
+// RUN:   -config="{CheckOptions: 
{performance-inefficient-string-concatenation.StrictMode: true}}" -- \
+// RUN:   -isystem %clang_tidy_headers
 
-namespace std {
-template <typename T>
-class basic_string {
-public:
-  basic_string() {}
-  ~basic_string() {}
-  basic_string<T> *operator+=(const basic_string<T> &);
-  friend basic_string<T> operator+(const basic_string<T> &, const 
basic_string<T> &);
-};
-typedef basic_string<char> string;
-}
+#include <string>
 
 void f(std::string) {}
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation.cpp
index a1edf5fae2f9e..b76474525cd3e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/inefficient-string-concatenation.cpp
@@ -1,17 +1,6 @@
-// RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t
+// RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t 
-- -- -isystem %clang_tidy_headers
 
-namespace std {
-template <typename T>
-class basic_string {
-public:
-  basic_string() {}
-  ~basic_string() {}
-  basic_string<T> *operator+=(const basic_string<T> &);
-  friend basic_string<T> operator+(const basic_string<T> &, const 
basic_string<T> &);
-};
-typedef basic_string<char> string;
-typedef basic_string<wchar_t> wstring;
-}
+#include <string>
 
 void f(std::string) {}
 std::string g(std::string);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to