[clang-tidy][misc-const-correctness] fix fp when using const array type. (#133018)
Fixed: #132931 const array is immutable in C/C++ language design, we don't need to check constness for it.
This commit is contained in:
parent
52975d5c9f
commit
01e505b992
@ -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(
|
||||
|
@ -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
|
||||
<clang-tidy/checks/misc/redundant-expression>` check by providing additional
|
||||
|
@ -1007,3 +1007,11 @@ template <typename T> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user