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

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 12 16:17:56 PDT 2018


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


================
Comment at: include/clang/AST/Expr.h:3097-3106
+  bool isRelationalOp() const {
+    return isRelationalOp(getOpcode()) ||
+           (getOpcode() == BO_Cmp && IsCmpOrdered);
+  }
 
   static bool isEqualityOp(Opcode Opc) { return Opc == BO_EQ || Opc == BO_NE; }
+  bool isEqualityOp() const {
----------------
rsmith wrote:
> These seem wrong to me. Relational operators are `<`, `<=`, `>`, and `>=`. `<=>` is not a relational operator even if it's an ordered comparison. Likewise, `<=>` is not an equality operator even if we don't have an ordered comparison.
> 
> If you undo this, you can also drop the `IsCmpOrdered` member entirely.
OK. I'll find another way to do this.

The intention was to facilitate identification of three-way comparisons which require equality/relational comparisons, which may or may not be legal in certain contexts. For example, comparing member pointers of different bases is OK, but only so long as we're evaluating them for strong/weak equality. 


https://reviews.llvm.org/D45476





More information about the cfe-commits mailing list