[PATCH] D65695: Implements CWG 1601 in [over.ics.rank/4.2]
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 29 13:25:00 PDT 2019
rsmith added inline comments.
================
Comment at: clang/lib/Sema/SemaOverload.cpp:3776
+ QualType UnderlyingType = Enum->getIntegerType();
+ if (SCS.getToType(1) == UnderlyingType)
+ return FixedEnumPromotion::ToUnderlyingType;
----------------
`==` on `QualType` compares the precise expression of the type, rather than checking whether types are semantically the same. Use `S.Context.hasSameType` instead to make this more robust (though I think the difference is not observable because the `ToType` in the case of a fixed enum promotion always happens to come exactly from calling `getIntegerType()`).
================
Comment at: clang/lib/Sema/SemaOverload.cpp:3831-3838
+ if (FEP1 != FixedEnumPromotion::None && FEP2 != FixedEnumPromotion::None) {
+ if (FEP1 == FixedEnumPromotion::ToUnderlyingType &&
+ FEP2 == FixedEnumPromotion::ToPromotedUnderlyingType)
+ return ImplicitConversionSequence::Better;
+ else if (FEP1 == FixedEnumPromotion::ToPromotedUnderlyingType &&
+ FEP2 == FixedEnumPromotion::ToUnderlyingType)
+ return ImplicitConversionSequence::Worse;
----------------
This logic can be simplified:
```
if (FEP1 != FixedEnumPromotion::None && FEP2 != FixedEnumPromotion::None && FEP1 != FEP2)
return FEP1 == FixedEnumPromotion::ToUnderlyingType ? ImplicitConversionSequence::Better
: ImplicitConversionSequence::Worse;
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65695/new/
https://reviews.llvm.org/D65695
More information about the cfe-commits
mailing list