diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-semicolon-constexpr.cpp +++ b/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() { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii.cpp @@ -36,6 +36,16 @@ } }; +template +void templ() { + T(); +} + +template +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(); + templ(); + Bar(); f(); qux(); 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 --- 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 @@ -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; diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/modernize-raw-string-literal.cpp +++ b/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"); diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-nodiscard.cpp +++ b/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 diff --git a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp b/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-value-param-header.cpp +++ b/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" diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-avoid-const-params-in-decls.cpp @@ -81,6 +81,29 @@ }; FooT f(1); +template +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 f2(1); + +template +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 b(1); +template +struct BatT { + BatT(const T i) {} + + void operator()(const T i) {} +}; +BatT b2(1); // Do not match on other stuff void NF(const alias_type& i); diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp @@ -2,6 +2,41 @@ #define NULL 0 +template +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 +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 ti2; + ti2.foo(); + TemplPtr ti3; + ti3.foo(); +} + void f() { int *ps = 0; if (ps /**/) // #0 diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp +++ b/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