[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 4 21:59:36 PDT 2018


EricWF marked 12 inline comments as done.
EricWF added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:9825
+    LHS = S.ImpCastExprToType(LHS.get(), IntType, CK_IntegralCast);
+    RHS = S.ImpCastExprToType(RHS.get(), IntType, CK_IntegralCast);
+    LHSType = RHSType = IntType;
----------------
EricWF wrote:
> rjmccall wrote:
> > I believe this will assert if the underlying type of the enum is `bool`.
> Ack. It does indeed.
> 
> What's the correct way to promote the boolean to an integer?
I seem to have solved the problem for enums with an underlying type of bool by first performing LValueToRValue conversions, followed by a conversion to `int` instead of `bool`.

Does that sound reasonable?


================
Comment at: lib/Sema/SemaExpr.cpp:9955
+      // and direction polls
+      return buildResultTy(ComparisonCategoryType::StrongEquality);
+
----------------
rjmccall wrote:
> Should we generate a tautological warning about comparisons on `nullptr_t` that aren't the result of some kind of macro/template expansion?
Probably? But we don't currently do it for equality operators, so perhaps this could be done in a follow up patch which adds the diagnostic for both equality and three-way comparisons?


https://reviews.llvm.org/D45476





More information about the cfe-commits mailing list