Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6
authorDavid Chisnall <github@theravensnest.org>
Sun, 24 Jul 2022 10:56:12 +0000 (11:56 +0100)
committerDavid Chisnall <David.Chisnall@cl.cam.ac.uk>
Sun, 24 Jul 2022 12:59:45 +0000 (13:59 +0100)
commit94c3b169785c0a0ae650c724dcf2c22ff65f5e24
treebbc5294a53930fb063c55f82f267ca139ee66528
parent0708771cce056c3bf9b89793ebb5aa5305b194b5
Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

5ab6ee75994d645725264e757d67bbb1c96fb2b6 assumed that if `RValue::isScalar()` returns true then `RValue::getScalarVal` will return a valid value.  This is not the case when the return value is `void` and so void message returns would crash if they hit this path.  This is triggered only for cases where the nil-handling path needs to do something non-trivial (destroy arguments that should be consumed by the callee).

Reviewed By: triplef

Differential Revision: https://reviews.llvm.org/D123898
clang/lib/CodeGen/CGObjCGNU.cpp
clang/test/CodeGenObjC/gnustep2-nontrivial-destructor-argument.mm [new file with mode: 0644]