2018-08-01 03:39:37 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker core,cplusplus -verify %s
|
|
|
|
|
|
|
|
// expected-no-diagnostics
|
|
|
|
|
2018-08-15 08:33:55 +08:00
|
|
|
#define nil ((id)0)
|
|
|
|
|
2018-08-01 03:39:37 +08:00
|
|
|
// Stripped down unique_ptr<int>
|
|
|
|
struct IntPtr {
|
|
|
|
IntPtr(): i(new int) {}
|
|
|
|
IntPtr(IntPtr &&o): i(o.i) { o.i = nullptr; }
|
|
|
|
~IntPtr() { delete i; }
|
|
|
|
|
|
|
|
int *i;
|
|
|
|
};
|
|
|
|
|
|
|
|
@interface Foo {}
|
|
|
|
-(void) foo: (IntPtr)arg;
|
|
|
|
@end
|
|
|
|
|
2018-08-15 08:33:55 +08:00
|
|
|
void testArgumentRegionInvalidation(Foo *f) {
|
2018-08-01 03:39:37 +08:00
|
|
|
IntPtr ptr;
|
|
|
|
int *i = ptr.i;
|
|
|
|
[f foo: static_cast<IntPtr &&>(ptr)];
|
|
|
|
*i = 99; // no-warning
|
|
|
|
}
|
2018-08-15 08:33:55 +08:00
|
|
|
|
|
|
|
void testNilReceiverCleanup() {
|
|
|
|
[nil foo: IntPtr()];
|
|
|
|
}
|