This revision was automatically updated to reflect the committed changes.
Closed by commit rG53c3acb89fcc: [clang-tidy] Add extra tests (authored by 
stephenkelly).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94029/new/

https://reviews.llvm.org/D94029

Files:
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,9 +1,8 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t \
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t \
 // RUN:   -config="{CheckOptions: \
 // RUN:             [{key: readability-redundant-string-init.StringNames, \
 // RUN:               value: '::std::basic_string;::std::basic_string_view;our::TestString'}] \
 // RUN:             }"
-// FIXME: Fix the checker to work in C++17 mode.
 
 namespace std {
 template <typename T>
Index: clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
@@ -2,6 +2,41 @@
 
 #define NULL 0
 
+template <typename T>
+struct Templ {
+  void foo() {
+    // t1
+    if (mem) // t2
+      delete mem;
+    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: 'if' statement is unnecessary;
+    // CHECK-FIXES: // t1
+    // CHECK-FIXES-NEXT: {{^    }}// t2
+    // CHECK-FIXES-NEXT: delete mem;
+  }
+  T mem;
+};
+
+template <typename T>
+struct TemplPtr {
+  void foo() {
+    // t3
+    if (mem) // t4
+      delete mem;
+    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: 'if' statement is unnecessary;
+    // CHECK-FIXES: // t3
+    // CHECK-FIXES-NEXT: {{^    }}// t4
+    // CHECK-FIXES-NEXT: delete mem;
+  }
+  T *mem;
+};
+
+void instantiate() {
+  Templ<int *> ti2;
+  ti2.foo();
+  TemplPtr<int> ti3;
+  ti3.foo();
+}
+
 void f() {
   int *ps = 0;
   if (ps /**/) // #0
Index: clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp
@@ -81,6 +81,29 @@
 };
 FooT<int> f(1);
 
+template <class T>
+struct BingT {
+  BingT(const T i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i'
+  // CHECK-FIXES: BingT(T i);
+
+  void operator()(const T i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(T i);
+};
+BingT<int> f2(1);
+
+template <class T>
+struct NeverInstantiatedT {
+  NeverInstantiatedT(const T i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: parameter 'i'
+  // CHECK-FIXES: NeverInstantiatedT(T i);
+
+  void operator()(const T i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i'
+  // CHECK-FIXES: void operator()(T i);
+};
+
 // Do not match on definitions
 void NF1(const int i) {}
 void NF2(const int *const i) {}
@@ -109,6 +132,13 @@
   void operator()(const int i) {}
 };
 BarT<int> b(1);
+template <class T>
+struct BatT {
+  BatT(const T i) {}
+
+  void operator()(const T i) {}
+};
+BatT<int> b2(1);
 
 // Do not match on other stuff
 void NF(const alias_type& i);
Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp
@@ -1,9 +1,8 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: cp %S/Inputs/performance-unnecessary-value-param/header.h %t/header.h
-// RUN: %check_clang_tidy -std=c++11 %s performance-unnecessary-value-param %t/temp -- -- -I %t
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t/temp -- -- -I %t
 // RUN: diff %t/header.h %S/Inputs/performance-unnecessary-value-param/header-fixed.h
-// FIXME: Make the test work in all language modes.
 
 #include "header.h"
 
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp
@@ -1,6 +1,5 @@
-// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
-// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
-// RUN: -- -std=c++17
+// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-use-nodiscard %t -- \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}"
 
 namespace std {
 template <class>
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s modernize-raw-string-literal %t -- -config="{CheckOptions: [{key: modernize-raw-string-literal.ReplaceShorterLiterals, value: 1}]}"
-// FIXME: Fix the checker to work in C++20 mode.
+// RUN: %check_clang_tidy %s modernize-raw-string-literal %t -- -config="{CheckOptions: [{key: modernize-raw-string-literal.ReplaceShorterLiterals, value: 1}]}"
 
 char const *const BackSlash("goink\\frob");
 // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
@@ -47,8 +46,8 @@
 char const *const TrailingSpace("A line \\with space. \n");
 char const *const TrailingNewLine("A single \\line.\n");
 char const *const AlreadyRaw(R"(foobie\\bletch)");
-char const *const UTF8Literal(u8"foobie\\bletch");
-char const *const UTF8RawLiteral(u8R"(foobie\\bletch)");
+auto const *const UTF8Literal(u8"foobie\\bletch");
+auto const *const UTF8RawLiteral(u8R"(foobie\\bletch)");
 // TODO: enable these tests once all supported compilers
 // support char16_t and char32_t (VS2013 does not)
 // char16_t const *const UTF16Literal(u"foobie\\bletch");
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-use-after-move %t -- -- -std=c++17 -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-use-after-move %t -- -- -fno-delayed-template-parsing
 
 typedef decltype(nullptr) nullptr_t;
 
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp
@@ -36,6 +36,16 @@
   }
 };
 
+template <typename T>
+void templ() {
+  T();
+}
+
+template <typename T>
+void neverInstantiated() {
+  T();
+}
+
 void test() {
   Foo(42);
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: object destroyed immediately after creation; did you mean to name the object?
@@ -54,6 +64,9 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: object destroyed immediately after creation; did you mean to name the object?
 // CHECK-FIXES: FooBar give_me_a_name;
 
+  templ<FooBar>();
+  templ<Bar>();
+
   Bar();
   f();
   qux<Foo>();
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17
+// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-suspicious-semicolon %t
 
 void fail()
 {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to