This is an archive of the discontinued LLVM Phabricator instance.

[Matrix] Skip matrix casts checks for class or struct types in C++.
ClosedPublic

Authored by fhahn on May 26 2021, 6:16 AM.

Details

Summary

At the moment, the matrix support in CheckCXXCStyleCast (added in
D101696) breaks function-style constructor calls that take a
single matrix value, because it is treated as matrix cast.

Instead, skip the matrix cast checks if the destination is a struct or
class type. In that case, leave the checks for later code, that matches
against the available constructors.

Diff Detail

Event Timeline

fhahn created this revision.May 26 2021, 6:16 AM
fhahn requested review of this revision.May 26 2021, 6:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2021, 6:16 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks, this looks good to me! The existing tests are failing but seems like they are not difficult to fix. Once those are fixed, I will mark this as accepted.

fhahn updated this revision to Diff 348106.May 26 2021, 3:07 PM

Fix IR checks, which broke after adding fields to the struct/class used in the tests.

SaurabhJha accepted this revision.May 27 2021, 5:02 AM
This revision is now accepted and ready to land.May 27 2021, 5:02 AM
fhahn updated this revision to Diff 348360.May 27 2021, 12:44 PM

I discussed the problem offline with John and he suggested to handle matrix casts in TryStaticCast. This allows us the handle both static_cast and C-style casts with the same code. As a consequence, the default error messages for casting a matrix type to a non-matrix type and vice versa are used.

SaurabhJha accepted this revision.May 27 2021, 12:53 PM

I discussed the problem offline with John and he suggested to handle matrix casts in TryStaticCast. This allows us the handle both static_cast and C-style casts with the same code. As a consequence, the default error messages for casting a matrix type to a non-matrix type and vice versa are used.

Makes sense Florian. I am sorry I missed it in my static cast patch.

This revision was landed with ongoing or failed builds.May 28 2021, 5:01 AM
This revision was automatically updated to reflect the committed changes.