diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py index a78996a0fce3b..53ffca0bad8d0 100755 --- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py @@ -265,15 +265,17 @@ def run(self): def expand_std(std): if std == "c++98-or-later": - return ["c++98", "c++11", "c++14", "c++17", "c++20"] + return ["c++98", "c++11", "c++14", "c++17", "c++20", "c++23", "c++2c"] if std == "c++11-or-later": - return ["c++11", "c++14", "c++17", "c++20"] + return ["c++11", "c++14", "c++17", "c++20", "c++23", "c++2c"] if std == "c++14-or-later": - return ["c++14", "c++17", "c++20"] + return ["c++14", "c++17", "c++20", "c++23", "c++2c"] if std == "c++17-or-later": - return ["c++17", "c++20"] + return ["c++17", "c++20", "c++23", "c++2c"] if std == "c++20-or-later": - return ["c++20"] + return ["c++20", "c++23", "c++2c"] + if std == "c++23-or-later": + return ["c++23", "c++2c"] return [std] diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp new file mode 100644 index 0000000000000..3547ec080911e --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values-before-cxx23.cpp @@ -0,0 +1,20 @@ +// RUN: %check_clang_tidy -std=c++11,c++14,c++17,c++20 %s misc-const-correctness %t -- \ +// RUN: -config="{CheckOptions: {\ +// RUN: misc-const-correctness.TransformValues: true, \ +// RUN: misc-const-correctness.WarnPointersAsValues: false, \ +// RUN: misc-const-correctness.TransformPointersAsValues: false \ +// RUN: }}" -- -fno-delayed-template-parsing + + +double &non_const_ref_return() { + double p_local0 = 0.0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const' + // CHECK-FIXES: double const p_local0 + double np_local0 = 42.42; + return np_local0; +} + +double *&return_non_const_pointer_ref() { + double *np_local0 = nullptr; + return np_local0; +} diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp index 88f40462003e8..186e3cf5a179b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp @@ -1,9 +1,9 @@ // RUN: %check_clang_tidy %s misc-const-correctness %t -- \ // RUN: -config="{CheckOptions: {\ -// RUN: misc-const-correctness.TransformValues: true, \ -// RUN: misc-const-correctness.WarnPointersAsValues: false, \ -// RUN: misc-const-correctness.TransformPointersAsValues: false} \ -// RUN: }" -- -fno-delayed-template-parsing +// RUN: misc-const-correctness.TransformValues: true, \ +// RUN: misc-const-correctness.WarnPointersAsValues: false, \ +// RUN: misc-const-correctness.TransformPointersAsValues: false \ +// RUN: }}" -- -fno-delayed-template-parsing // ------- Provide test samples for primitive builtins --------- // - every 'p_*' variable is a 'potential_const_*' variable @@ -181,14 +181,7 @@ const double *const_pointer_return() { return &p_local1; } -double &non_const_ref_return() { - double p_local0 = 0.0; - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const' - // CHECK-FIXES: double const p_local0 - double np_local0 = 42.42; - return np_local0; -} - +// Also see const-correctness-values.cpp-before-cxx23.cpp for `non_const_ref_return` and `return_non_const_pointer_ref` const double &const_ref_return() { double p_local0 = 0.0; // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared 'const' @@ -199,11 +192,6 @@ const double &const_ref_return() { return p_local1; } -double *&return_non_const_pointer_ref() { - double *np_local0 = nullptr; - return np_local0; -} - void overloaded_arguments(const int &in); void overloaded_arguments(int &inout); void overloaded_arguments(const int *in); diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp index 566773ff3f5c4..74a22a7c083f4 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/unconventional-assign-operator.cpp @@ -45,7 +45,7 @@ struct BadArgument { BadArgument& operator=(BadArgument&); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument' BadArgument& operator=(const BadArgument&&); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadAr + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument' }; struct BadModifier { @@ -76,7 +76,7 @@ class BadReturnStatement { public: BadReturnStatement& operator=(BadReturnStatement&& rhs) { n = std::move(rhs.n); - return rhs; + return *&rhs; // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this' } diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp index c4ea1e27e63e6..05a4ebc9c8a17 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy -std=c++20 %s readability-container-contains %t +// RUN: %check_clang_tidy -std=c++20-or-later %s readability-container-contains %t // Some *very* simplified versions of `map` etc. namespace std {