[PATCH] D76793: [Matrix] Implement + and - operators for MatrixType.

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 22 19:49:52 PDT 2020


rjmccall added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:11989
+  else
+    return false;
+
----------------
I would suggest checking some preconditions and then just calling `PrepareScalarCast`.

You should allow implicit conversions from class types, which somewhat surprisingly I'm not sure we have a convenient method for, but which you can find workable code for in `ConvertForConditional` in SemaExprCXX.cpp.  Test case is `struct DoubleWrapper { operator double(); };`, and you should test using that even when the element type isn't a double.

In SemaOverload, you should add builtin candidates for these operators if one operand or the other is a matrix type.  Basically:

1. Collect matrix types in `AddTypesConvertedFrom`
2. For each matrix type `M` on the LHS, add candidates for `(M, M) -> M` and `(M, E) -> M`, and then analogously on the RHS.  Although you might need to avoid adding redundant candidates if the same type shows up on both sides.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76793/new/

https://reviews.llvm.org/D76793





More information about the cfe-commits mailing list