diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp @@ -962,11 +962,8 @@ // LValue->RValue is irrelevant for the check, because it is a thing to be // done at a call site, and will be performed if need be performed. - // Array->Ptr decay. - if (const auto *ArrayT = dyn_cast(From)) { - LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. Array->Ptr decayed.\n"); - WorkType = ArrayT->getPointeeType(); - } + // Array->Pointer decay is handled by the main method in desugaring + // the parameter's DecayedType as "useless sugar". // Function->Pointer conversions are also irrelevant, because a // "FunctionType" cannot be the type of a parameter variable, so this diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.cpp @@ -26,6 +26,26 @@ void arrayAndElement(int I, int IA[]) {} // NO-WARN. +typedef int Point2D[2]; +typedef int Point3D[3]; + +void arrays1(Point2D P2D, Point3D P3D) {} // In reality this is (int*, int*). +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'arrays1' of similar type ('int *') are +// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in the range is 'P2D' +// CHECK-MESSAGES: :[[@LINE-3]]:35: note: the last parameter in the range is 'P3D' + +void crefToArrayTypedef1(int I, const Point2D &P) {} +// NO-WARN. + +void crefToArrayTypedef2(int *IA, const Point2D &P) {} +// NO-WARN. + +void crefToArrayTypedef3(int P1[2], const Point2D &P) {} +// NO-WARN. + +void crefToArrayTypedefBoth1(const Point2D &VecDescartes, const Point3D &VecThreeD) {} +// NO-WARN: Distinct types. + void numericConversion1(int I, double D) { numericConversion1(D, I); } // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 2 adjacent parameters of 'numericConversion1' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] // CHECK-MESSAGES: :[[@LINE-2]]:29: note: the first parameter in the range is 'I' diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp @@ -244,6 +244,26 @@ // CHECK-MESSAGES: :[[@LINE-6]]:52: note: 'int' and 'MyIntCRTy' parameters accept and bind the same kind of values // CHECK-MESSAGES: :[[@LINE-7]]:37: note: after resolving type aliases, the common type of 'ICRTy' and 'MyIntCRTy' is 'const int &' +typedef int Point2D[2]; +typedef int Point3D[3]; + +void arrays1(Point2D P2D, Point3D P3D) {} // In reality this is (int*, int*). +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 2 adjacent parameters of 'arrays1' of similar type ('int *') are +// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in the range is 'P2D' +// CHECK-MESSAGES: :[[@LINE-3]]:35: note: the last parameter in the range is 'P3D' + +void crefToArrayTypedef1(int I, const Point2D &P) {} +// NO-WARN. + +void crefToArrayTypedef2(int *IA, const Point2D &P) {} +// NO-WARN. + +void crefToArrayTypedef3(int P1[2], const Point2D &P) {} +// NO-WARN. + +void crefToArrayTypedefBoth1(const Point2D &VecDescartes, const Point3D &VecThreeD) {} +// NO-WARN: Distinct types and no conversion because of &. + short const typedef int unsigned Eldritch; typedef const unsigned short Holy;