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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D65695: I... Mark de Wever via Phabricator via cfe-commits
    • [PATCH] D656... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D656... Mark de Wever via Phabricator via cfe-commits
    • [PATCH] D656... Mark de Wever via Phabricator via cfe-commits
    • [PATCH] D656... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D656... Mark de Wever via Phabricator via cfe-commits

Reply via email to