diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp index 50e6722badf50..697398a54332d 100644 --- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp @@ -81,10 +81,10 @@ void ConstCorrectnessCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { } void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) { - const auto ConstType = hasType( - qualType(isConstQualified(), - // pointee check will check the const pointer and const array - unless(pointerType()), unless(arrayType()))); + const auto ConstType = + hasType(qualType(isConstQualified(), + // pointee check will check the constness of pointer + unless(pointerType()))); const auto ConstReference = hasType(references(isConstQualified())); const auto RValueReference = hasType( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index aa85105918ecf..7bbf2190ee262 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -146,7 +146,8 @@ Changes in existing checks `AllowedTypes`, that excludes specified types from const-correctness checking and fixing false positives when modifying variant by ``operator[]`` with template in parameters and supporting to check pointee mutation by - `AnalyzePointers` option. + `AnalyzePointers` option and fixing false positives when using const array + type. - Improved :doc:`misc-redundant-expression ` check by providing additional 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 4cf78aeef5bd4..a80e1e1af1870 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 @@ -1007,3 +1007,11 @@ template void f() { x[T{}] = 3; } } // namespace gh127776_false_positive + +namespace gh132931_false_positive { +using T = const int; +void valid(int i) { + const int arr0[] = {1, 2, 3}; + T arr1[] = {1, 2, 3}; +} +} // namespace gh132931_false_positive