diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py --- 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 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 --- /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 --- 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 @@ 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 @@ 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 --- 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 @@ 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 @@ 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 --- 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 {