Skip to content

Commit e3cb910

Browse files
committed
[clang-tidy] Use only fast qualifiers to re-construct QualType
1 parent 6d13e32 commit e3cb910

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
967967
// Get out the qualifiers of the original type. This will always be
968968
// re-applied to the WorkType to ensure it is the same qualification as the
969969
// original From was.
970-
auto QualifiersToApply = From.split().Quals.getAsOpaqueValue();
970+
auto FastQualifiersToApply = static_cast<unsigned>(
971+
From.split().Quals.getAsOpaqueValue() & Qualifiers::FastMask);
971972

972973
// LValue->RValue is irrelevant for the check, because it is a thing to be
973974
// done at a call site, and will be performed if need be performed.
@@ -993,7 +994,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
993994
// "const double -> double".
994995
LLVM_DEBUG(llvm::dbgs()
995996
<< "--- approximateStdConv. Conversion between numerics.\n");
996-
WorkType = QualType{ToBuiltin, QualifiersToApply};
997+
WorkType = QualType{ToBuiltin, FastQualifiersToApply};
997998
}
998999

9991000
const auto *FromEnum = WorkType->getAs<EnumType>();
@@ -1002,7 +1003,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
10021003
// Unscoped enumerations (or enumerations in C) convert to numerics.
10031004
LLVM_DEBUG(llvm::dbgs()
10041005
<< "--- approximateStdConv. Unscoped enum to numeric.\n");
1005-
WorkType = QualType{ToBuiltin, QualifiersToApply};
1006+
WorkType = QualType{ToBuiltin, FastQualifiersToApply};
10061007
} else if (FromNumeric && ToEnum && ToEnum->isUnscopedEnumerationType()) {
10071008
// Numeric types convert to enumerations only in C.
10081009
if (Ctx.getLangOpts().CPlusPlus) {
@@ -1013,7 +1014,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
10131014

10141015
LLVM_DEBUG(llvm::dbgs()
10151016
<< "--- approximateStdConv. Numeric to unscoped enum.\n");
1016-
WorkType = QualType{ToEnum, QualifiersToApply};
1017+
WorkType = QualType{ToEnum, FastQualifiersToApply};
10171018
}
10181019

10191020
// Check for pointer conversions.
@@ -1022,14 +1023,14 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
10221023
if (FromPtr && ToPtr) {
10231024
if (ToPtr->isVoidPointerType()) {
10241025
LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. To void pointer.\n");
1025-
WorkType = QualType{ToPtr, QualifiersToApply};
1026+
WorkType = QualType{ToPtr, FastQualifiersToApply};
10261027
}
10271028

10281029
const auto *FromRecordPtr = FromPtr->getPointeeCXXRecordDecl();
10291030
const auto *ToRecordPtr = ToPtr->getPointeeCXXRecordDecl();
10301031
if (isDerivedToBase(FromRecordPtr, ToRecordPtr)) {
10311032
LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. Derived* to Base*\n");
1032-
WorkType = QualType{ToPtr, QualifiersToApply};
1033+
WorkType = QualType{ToPtr, FastQualifiersToApply};
10331034
}
10341035
}
10351036

@@ -1039,7 +1040,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
10391040
const auto *ToRecord = To->getAsCXXRecordDecl();
10401041
if (isDerivedToBase(FromRecord, ToRecord)) {
10411042
LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. Derived To Base.\n");
1042-
WorkType = QualType{ToRecord->getTypeForDecl(), QualifiersToApply};
1043+
WorkType = QualType{ToRecord->getTypeForDecl(), FastQualifiersToApply};
10431044
}
10441045

10451046
if (Ctx.getLangOpts().CPlusPlus17 && FromPtr && ToPtr) {
@@ -1054,7 +1055,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
10541055
!ToFunctionPtr->hasNoexceptExceptionSpec()) {
10551056
LLVM_DEBUG(llvm::dbgs() << "--- approximateStdConv. noexcept function "
10561057
"pointer to non-noexcept.\n");
1057-
WorkType = QualType{ToPtr, QualifiersToApply};
1058+
WorkType = QualType{ToPtr, FastQualifiersToApply};
10581059
}
10591060
}
10601061

0 commit comments

Comments
 (0)