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

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 13:05:48 PDT 2020


fhahn added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:11989
+  else
+    return false;
+
----------------
rjmccall wrote:
> 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.
Thank you very much John, I hope I managed to update the patch properly according to your comments!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76793





More information about the llvm-commits mailing list