[clang-tools-extra] [clang-tidy][NFC] add qutation mark for C++ classes in warning message (PR #109068)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 18 06:03:29 PDT 2024


https://github.com/HerrCai0907 updated https://github.com/llvm/llvm-project/pull/109068

>From 66be189c281db7a49c5238c2fe09df64842c1e25 Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Tue, 17 Sep 2024 23:01:17 +0800
Subject: [PATCH 1/2] add quotation

---
 .../modernize/AvoidCArraysCheck.cpp           | 10 +++---
 .../checks/modernize/avoid-c-arrays.rst       | 16 +++++-----
 .../modernize/avoid-c-arrays-c++20.cpp        |  6 ++--
 .../modernize/avoid-c-arrays-ignores-main.cpp | 10 +++---
 .../avoid-c-arrays-ignores-strings.cpp        |  4 +--
 .../avoid-c-arrays-ignores-three-arg-main.cpp | 14 ++++----
 .../checkers/modernize/avoid-c-arrays.cpp     | 32 +++++++++----------
 .../test/clang-tidy/infrastructure/nolint.cpp |  4 +--
 .../infrastructure/nolintbeginend.cpp         |  4 +--
 .../infrastructure/nolintnextline.cpp         |  4 +--
 10 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
index 98778192dbd3ae..6e059ed95d0524 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
@@ -80,18 +80,18 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
   enum class RecommendType { Array, Vector, Span };
   llvm::SmallVector<const char *> RecommendTypes{};
   if (IsVLA) {
-    RecommendTypes.push_back("std::vector<>");
+    RecommendTypes.push_back("'std::vector<>'");
   } else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) {
     // in function parameter, we also don't know the size of
     // IncompleteArrayType.
     if (Result.Context->getLangOpts().CPlusPlus20)
-      RecommendTypes.push_back("std::span<>");
+      RecommendTypes.push_back("'std::span<>'");
     else {
-      RecommendTypes.push_back("std::array<>");
-      RecommendTypes.push_back("std::vector<>");
+      RecommendTypes.push_back("'std::array<>'");
+      RecommendTypes.push_back("'std::vector<>'");
     }
   } else {
-    RecommendTypes.push_back("std::array<>");
+    RecommendTypes.push_back("'std::array<>'");
   }
   diag(ArrayType->getBeginLoc(),
        "do not declare %select{C-style|C VLA}0 arrays, use %1 instead")
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
index 2d72352989ab94..f96075182a84d3 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
@@ -10,7 +10,7 @@ modernize-avoid-c-arrays
 Finds C-style array types and recommend to use ``std::array<>`` /
 ``std::vector<>``. All types of C arrays are diagnosed.
 
-For incomplete C-style array types appeared in parameters, It would be better to
+For parameters of incomplete C-style array type, it would be better to
 use ``std::span`` / ``gsl::span`` as replacement.
 
 However, fix-it are potentially dangerous in header files and are therefore not
@@ -18,24 +18,24 @@ emitted right now.
 
 .. code:: c++
 
-  int a[] = {1, 2}; // warning: do not declare C-style arrays, use std::array<> instead
+  int a[] = {1, 2}; // warning: do not declare C-style arrays, use 'std::array<>' instead
 
-  int b[1]; // warning: do not declare C-style arrays, use std::array<> instead
+  int b[1]; // warning: do not declare C-style arrays, use 'std::array<>' instead
 
   void foo() {
-    int c[b[0]]; // warning: do not declare C VLA arrays, use std::vector<> instead
+    int c[b[0]]; // warning: do not declare C VLA arrays, use 'std::vector<>' instead
   }
 
   template <typename T, int Size>
   class array {
-    T d[Size]; // warning: do not declare C-style arrays, use std::array<> instead
+    T d[Size]; // warning: do not declare C-style arrays, use 'std::array<>' instead
 
-    int e[1]; // warning: do not declare C-style arrays, use std::array<> instead
+    int e[1]; // warning: do not declare C-style arrays, use 'std::array<>' instead
   };
 
-  array<int[4], 2> d; // warning: do not declare C-style arrays, use std::array<> instead
+  array<int[4], 2> d; // warning: do not declare C-style arrays, use 'std::array<>' instead
 
-  using k = int[4]; // warning: do not declare C-style arrays, use std::array<> instead
+  using k = int[4]; // warning: do not declare C-style arrays, use 'std::array<>' instead
 
 
 However, the ``extern "C"`` code is ignored, since it is common to share
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp
index e53cfeba0e4601..910c79892520d5 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp
@@ -1,11 +1,11 @@
 // RUN: %check_clang_tidy -std=c++20 %s modernize-avoid-c-arrays %t
 
 int f1(int data[], int size) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use std::span<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use 'std::span<>' instead
   int f4[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 }
 
 int f2(int data[100]) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use 'std::array<>' instead
 }
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp
index ad12b3d6f95b91..e90634e4da9e56 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp
@@ -1,18 +1,18 @@
 // RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
 
 int not_main(int argc, char *argv[]) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
   int f4[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 }
 
 int main(int argc, char *argv[]) {
   int f5[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 
   auto not_main = [](int argc, char *argv[]) {
-    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
     int f6[] = {1, 2};
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array<>' instead
   };
 }
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp
index b607068f5b7c9c..aad5d9789922b4 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp
@@ -3,7 +3,7 @@
 
 const char name[] = "name";
 const char array[] = {'n', 'a', 'm', 'e', '\0'};
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
 
 void takeCharArray(const char name[]);
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead [modernize-avoid-c-arrays]
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp
index c04edf2b5aea08..39f98e41d8ad20 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp
@@ -1,20 +1,20 @@
 // RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
 
 int not_main(int argc, char *argv[], char *argw[]) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead
-  // CHECK-MESSAGES: :[[@LINE-2]]:38: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
+  // CHECK-MESSAGES: :[[@LINE-2]]:38: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
   int f4[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 }
 
 int main(int argc, char *argv[], char *argw[]) {
   int f5[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 
   auto not_main = [](int argc, char *argv[], char *argw[]) {
-    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead
-    // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
+    // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
     int f6[] = {1, 2};
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array<>' instead
   };
 }
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp
index b0aaa4962a8351..89b5a5e7945ea6 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp
@@ -1,14 +1,14 @@
 // RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
 
 int a[] = {1, 2};
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 int b[1];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 void foo() {
   int c[b[0]];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C VLA arrays, use std::vector<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C VLA arrays, use 'std::vector<>' instead
 
   using d = decltype(c);
   d e;
@@ -20,17 +20,17 @@ void foo() {
 template <typename T, int Size>
 class array {
   T d[Size];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 
   int e[1];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 };
 
 array<int[4], 2> d;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 using k = int[4];
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 array<k, 2> dk;
 
@@ -39,14 +39,14 @@ class unique_ptr {
   T *d;
 
   int e[1];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 };
 
 unique_ptr<int[]> d2;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 using k2 = int[];
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 unique_ptr<k2> dk2;
 
@@ -65,17 +65,17 @@ inline void bar() {
 
 extern "C++" {
 int f3[] = {1, 2};
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 int j3[1];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
 
 struct Foo {
   int f3[3] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 
   int j3[1];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
 };
 }
 
@@ -88,7 +88,7 @@ struct Bar {
 }
 
 const char name[] = "Some string";
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
 
 void takeCharArray(const char name[]);
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use std::array<> or std::vector<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead [modernize-avoid-c-arrays]
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
index bc952ee03b5ada..30a98b82993b69 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -125,10 +125,10 @@ class D5 { D5(int x); }; // NOLINT(google*,-google*)
 class D6 { D6(int x); }; // NOLINT(*,-google*)
 
 int array1[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
 
 int array2[10];  // NOLINT(cppcoreguidelines-avoid-c-arrays)
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
 
 int array3[10];  // NOLINT(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
 int array4[10];  // NOLINT(*-avoid-c-arrays)
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
index ae97bc5b514412..0b922bf493b989 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -133,11 +133,11 @@ class C16 { C16(int x); };
 // NOLINTEND(*,-google*)
 
 int array1[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
 
 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays)
 int array2[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
 // NOLINTEND(cppcoreguidelines-avoid-c-arrays)
 
 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
index 7b0a2c4374aa2e..a24f79793d3faf 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -70,11 +70,11 @@ class I5 { I5(int x); };
 class I6 { I6(int x); };
 
 int array1[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
 
 // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
 int array2[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
 
 // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
 int array3[10];

>From 3303c965480446085d9086853086f63f957e7ecb Mon Sep 17 00:00:00 2001
From: Congcong Cai <congcongcai0907 at 163.com>
Date: Wed, 18 Sep 2024 21:03:15 +0800
Subject: [PATCH 2/2] remove <>

---
 .../modernize/AvoidCArraysCheck.cpp           | 10 +++---
 .../checks/modernize/avoid-c-arrays.rst       | 14 ++++----
 .../modernize/avoid-c-arrays-c++20.cpp        |  6 ++--
 .../modernize/avoid-c-arrays-ignores-main.cpp | 10 +++---
 .../avoid-c-arrays-ignores-strings.cpp        |  4 +--
 .../avoid-c-arrays-ignores-three-arg-main.cpp | 14 ++++----
 .../checkers/modernize/avoid-c-arrays.cpp     | 32 +++++++++----------
 .../test/clang-tidy/infrastructure/nolint.cpp |  4 +--
 .../infrastructure/nolintbeginend.cpp         |  4 +--
 .../infrastructure/nolintnextline.cpp         |  4 +--
 10 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
index 6e059ed95d0524..0804aa76d953cb 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidCArraysCheck.cpp
@@ -80,18 +80,18 @@ void AvoidCArraysCheck::check(const MatchFinder::MatchResult &Result) {
   enum class RecommendType { Array, Vector, Span };
   llvm::SmallVector<const char *> RecommendTypes{};
   if (IsVLA) {
-    RecommendTypes.push_back("'std::vector<>'");
+    RecommendTypes.push_back("'std::vector'");
   } else if (ArrayType->getTypePtr()->isIncompleteArrayType() && IsInParam) {
     // in function parameter, we also don't know the size of
     // IncompleteArrayType.
     if (Result.Context->getLangOpts().CPlusPlus20)
-      RecommendTypes.push_back("'std::span<>'");
+      RecommendTypes.push_back("'std::span'");
     else {
-      RecommendTypes.push_back("'std::array<>'");
-      RecommendTypes.push_back("'std::vector<>'");
+      RecommendTypes.push_back("'std::array'");
+      RecommendTypes.push_back("'std::vector'");
     }
   } else {
-    RecommendTypes.push_back("'std::array<>'");
+    RecommendTypes.push_back("'std::array'");
   }
   diag(ArrayType->getBeginLoc(),
        "do not declare %select{C-style|C VLA}0 arrays, use %1 instead")
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
index f96075182a84d3..6a386ecd0fd4b2 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
@@ -18,24 +18,24 @@ emitted right now.
 
 .. code:: c++
 
-  int a[] = {1, 2}; // warning: do not declare C-style arrays, use 'std::array<>' instead
+  int a[] = {1, 2}; // warning: do not declare C-style arrays, use 'std::array' instead
 
-  int b[1]; // warning: do not declare C-style arrays, use 'std::array<>' instead
+  int b[1]; // warning: do not declare C-style arrays, use 'std::array' instead
 
   void foo() {
-    int c[b[0]]; // warning: do not declare C VLA arrays, use 'std::vector<>' instead
+    int c[b[0]]; // warning: do not declare C VLA arrays, use 'std::vector' instead
   }
 
   template <typename T, int Size>
   class array {
-    T d[Size]; // warning: do not declare C-style arrays, use 'std::array<>' instead
+    T d[Size]; // warning: do not declare C-style arrays, use 'std::array' instead
 
-    int e[1]; // warning: do not declare C-style arrays, use 'std::array<>' instead
+    int e[1]; // warning: do not declare C-style arrays, use 'std::array' instead
   };
 
-  array<int[4], 2> d; // warning: do not declare C-style arrays, use 'std::array<>' instead
+  array<int[4], 2> d; // warning: do not declare C-style arrays, use 'std::array' instead
 
-  using k = int[4]; // warning: do not declare C-style arrays, use 'std::array<>' instead
+  using k = int[4]; // warning: do not declare C-style arrays, use 'std::array' instead
 
 
 However, the ``extern "C"`` code is ignored, since it is common to share
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp
index 910c79892520d5..1eb8ebe3d51e3c 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-c++20.cpp
@@ -1,11 +1,11 @@
 // RUN: %check_clang_tidy -std=c++20 %s modernize-avoid-c-arrays %t
 
 int f1(int data[], int size) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use 'std::span<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use 'std::span' instead
   int f4[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 }
 
 int f2(int data[100]) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not declare C-style arrays, use 'std::array' instead
 }
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp
index e90634e4da9e56..a0c79bb55a6862 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-main.cpp
@@ -1,18 +1,18 @@
 // RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
 
 int not_main(int argc, char *argv[]) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
   int f4[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 }
 
 int main(int argc, char *argv[]) {
   int f5[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 
   auto not_main = [](int argc, char *argv[]) {
-    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
     int f6[] = {1, 2};
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array<>' instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array' instead
   };
 }
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp
index aad5d9789922b4..906663828a547e 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-strings.cpp
@@ -3,7 +3,7 @@
 
 const char name[] = "name";
 const char array[] = {'n', 'a', 'm', 'e', '\0'};
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
 
 void takeCharArray(const char name[]);
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead [modernize-avoid-c-arrays]
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp
index 39f98e41d8ad20..bd39f0fb4f1c86 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays-ignores-three-arg-main.cpp
@@ -1,20 +1,20 @@
 // RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
 
 int not_main(int argc, char *argv[], char *argw[]) {
-  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
-  // CHECK-MESSAGES: :[[@LINE-2]]:38: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
+  // CHECK-MESSAGES: :[[@LINE-2]]:38: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
   int f4[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 }
 
 int main(int argc, char *argv[], char *argw[]) {
   int f5[] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 
   auto not_main = [](int argc, char *argv[], char *argw[]) {
-    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
-    // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
+    // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead
     int f6[] = {1, 2};
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array<>' instead
+    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use 'std::array' instead
   };
 }
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp
index 89b5a5e7945ea6..14eb2852c639a4 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-c-arrays.cpp
@@ -1,14 +1,14 @@
 // RUN: %check_clang_tidy -std=c++17 %s modernize-avoid-c-arrays %t
 
 int a[] = {1, 2};
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead
 
 int b[1];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead
 
 void foo() {
   int c[b[0]];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C VLA arrays, use 'std::vector<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C VLA arrays, use 'std::vector' instead
 
   using d = decltype(c);
   d e;
@@ -20,17 +20,17 @@ void foo() {
 template <typename T, int Size>
 class array {
   T d[Size];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 
   int e[1];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 };
 
 array<int[4], 2> d;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array' instead
 
 using k = int[4];
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not declare C-style arrays, use 'std::array' instead
 
 array<k, 2> dk;
 
@@ -39,14 +39,14 @@ class unique_ptr {
   T *d;
 
   int e[1];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 };
 
 unique_ptr<int[]> d2;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use 'std::array' instead
 
 using k2 = int[];
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use 'std::array' instead
 
 unique_ptr<k2> dk2;
 
@@ -65,17 +65,17 @@ inline void bar() {
 
 extern "C++" {
 int f3[] = {1, 2};
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead
 
 int j3[1];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead
 
 struct Foo {
   int f3[3] = {1, 2};
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 
   int j3[1];
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array<>' instead
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use 'std::array' instead
 };
 }
 
@@ -88,7 +88,7 @@ struct Bar {
 }
 
 const char name[] = "Some string";
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
 
 void takeCharArray(const char name[]);
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array<>' or 'std::vector<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not declare C-style arrays, use 'std::array' or 'std::vector' instead [modernize-avoid-c-arrays]
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
index 30a98b82993b69..fd3fee6b9c56e1 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp
@@ -125,10 +125,10 @@ class D5 { D5(int x); }; // NOLINT(google*,-google*)
 class D6 { D6(int x); }; // NOLINT(*,-google*)
 
 int array1[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
 
 int array2[10];  // NOLINT(cppcoreguidelines-avoid-c-arrays)
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
 
 int array3[10];  // NOLINT(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
 int array4[10];  // NOLINT(*-avoid-c-arrays)
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
index 0b922bf493b989..15d82b751c675a 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend.cpp
@@ -133,11 +133,11 @@ class C16 { C16(int x); };
 // NOLINTEND(*,-google*)
 
 int array1[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
 
 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays)
 int array2[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
 // NOLINTEND(cppcoreguidelines-avoid-c-arrays)
 
 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
index a24f79793d3faf..71da442ad767b9 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp
@@ -70,11 +70,11 @@ class I5 { I5(int x); };
 class I6 { I6(int x); };
 
 int array1[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
 
 // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
 int array2[10];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array<>' instead [modernize-avoid-c-arrays]
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
 
 // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)
 int array3[10];



More information about the cfe-commits mailing list