[ObjC] avoid crashing when emitting synthesized getter/setter and ptrdiff_t is smalle...
authorMatt Jacobson <mhjacobson@me.com>
Sat, 6 Aug 2022 05:01:35 +0000 (01:01 -0400)
committerMatt Jacobson <mhjacobson@me.com>
Thu, 10 Nov 2022 07:10:30 +0000 (02:10 -0500)
commitdd9f7963e434a53e8d70f607392ee9abf76f1d99
tree227aa315ef6427466185d5b5ac37eb7acc67fd74
parent18df04c944593e53705f64fd2befa804408ab521
[ObjC] avoid crashing when emitting synthesized getter/setter and ptrdiff_t is smaller than long

On targets where ptrdiff_t is smaller than long, clang crashes when emitting
synthesized getters/setters that call objc_[gs]etProperty.  Explicitly emit a
zext/trunc of the ivar offset value (which is defined to long) to ptrdiff_t,
which objc_[gs]etProperty takes.

Add a test using the AVR target, where ptrdiff_t is smaller than long. Test
failed previously and passes now.

Differential Revision: https://reviews.llvm.org/D112049
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/avr/objc-property.m [new file with mode: 0644]