forked from OSchip/llvm-project
<rdar://problem/12315386>
Test suite to catch fragile base class ivar issues. llvm-svn: 164321
This commit is contained in:
parent
363d73c518
commit
48e0c2c82d
|
@ -1,10 +1,11 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <stdint.h>
|
||||
|
||||
@interface InternalDefiner : NSObject {
|
||||
@public
|
||||
int foo;
|
||||
uintptr_t foo;
|
||||
}
|
||||
|
||||
-(int)setBarTo:(int)newBar;
|
||||
-(id)initWithFoo:(uintptr_t)f andBar:(uintptr_t)b;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,18 +1,31 @@
|
|||
#import "InternalDefiner.h"
|
||||
|
||||
@interface InternalDefiner () {
|
||||
int bar;
|
||||
uintptr_t bar;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation InternalDefiner
|
||||
|
||||
-(int)setBarTo:(int)newBar
|
||||
-(id)init
|
||||
{
|
||||
int oldBar = bar;
|
||||
bar = newBar;
|
||||
return oldBar;
|
||||
if (self = [super init])
|
||||
{
|
||||
foo = 2;
|
||||
bar = 3;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id)initWithFoo:(uintptr_t)f andBar:(uintptr_t)b
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
foo = f;
|
||||
bar = b;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
LEVEL = ../../../make
|
||||
|
||||
DYLIB_NAME := libInternalDefiner
|
||||
DYLIB_NAME := InternalDefiner
|
||||
DYLIB_OBJC_SOURCES := InternalDefiner.m
|
||||
OBJC_SOURCES := main.m
|
||||
|
||||
|
|
|
@ -70,21 +70,45 @@ class HiddenIvarsTestCase(TestBase):
|
|||
self.common_setup()
|
||||
|
||||
# This should display correctly.
|
||||
self.expect("expression (j->_definer->foo)", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 4"])
|
||||
|
||||
self.expect("expression (j->_definer->bar)", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 5"])
|
||||
|
||||
self.expect("expression *(j->_definer)", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["foo = 0", "bar = 5"])
|
||||
substrs = ["foo = 4", "bar = 5"])
|
||||
|
||||
self.expect("expression (k->foo)", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 2"])
|
||||
|
||||
self.expect("expression (k->bar)", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 3"])
|
||||
|
||||
self.expect("expression *(k)", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["foo = 2", "bar = 3"])
|
||||
|
||||
def frame_var(self):
|
||||
self.common_setup()
|
||||
|
||||
# This should display correctly.
|
||||
self.expect("frame variable j->_definer->foo", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 4"])
|
||||
|
||||
self.expect("frame variable j->_definer->bar", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 5"])
|
||||
|
||||
self.expect("frame variable *j->_definer", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["foo = 0", "bar = 5"])
|
||||
substrs = ["foo = 4", "bar = 5"])
|
||||
|
||||
self.expect("frame variable k->foo", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 2"])
|
||||
|
||||
self.expect("frame variable k->bar", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["= 3"])
|
||||
|
||||
self.expect("frame variable *k", VARIABLES_DISPLAYED_CORRECTLY,
|
||||
substrs = ["foo = 2", "bar = 3"])
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
|
|
|
@ -13,8 +13,29 @@
|
|||
|
||||
-(id)init
|
||||
{
|
||||
_definer = [InternalDefiner alloc];
|
||||
[_definer setBarTo:5];
|
||||
if (self = [super init])
|
||||
{
|
||||
_definer = [[InternalDefiner alloc] initWithFoo:4 andBar:5];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface InheritContainer : InternalDefiner
|
||||
{
|
||||
}
|
||||
|
||||
-(id)init;
|
||||
@end
|
||||
|
||||
@implementation InheritContainer
|
||||
|
||||
-(id)init
|
||||
{
|
||||
if (self = [super initWithFoo:2 andBar:3])
|
||||
{
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -25,8 +46,10 @@ int main(int argc, const char * argv[])
|
|||
|
||||
@autoreleasepool {
|
||||
Container *j = [[Container alloc] init];
|
||||
InheritContainer *k = [[InheritContainer alloc] init];
|
||||
|
||||
printf("ivar value = %d", j->_definer->foo); // Set breakpoint 0 here.
|
||||
printf("ivar value = %u\n", (unsigned)j->_definer->foo); // Set breakpoint 0 here.
|
||||
printf("ivar value = %u\n", (unsigned)k->foo); // Set breakpoint 1 here.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue