brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 3f13bf1 Raw
108 lines · plain
1// REQUIRES: objc-gnustep2// XFAIL: system-windows3//4// RUN: %build %s --compiler=clang --objc-gnustep --output=%t5 6#import "objc/runtime.h"7 8@protocol NSCoding9@end10 11#ifdef __has_attribute12#if __has_attribute(objc_root_class)13__attribute__((objc_root_class))14#endif15#endif16@interface NSObject <NSCoding> {17  id isa;18  int refcount;19}20@end21@implementation NSObject22- (id)class {23  return object_getClass(self);24}25+ (id)new {26  return class_createInstance(self, 0);27}28@end29 30@interface TestObj : NSObject {31  int _int;32  float _float;33  char _char;34  void *_ptr_void;35  NSObject *_ptr_nsobject;36  id _id_objc;37}38- (void)check_ivars_zeroed;39- (void)set_ivars;40@end41@implementation TestObj42- (void)check_ivars_zeroed {43  ;44}45- (void)set_ivars {46  _int = 1;47  _float = 2.0f;48  _char = '\3';49  _ptr_void = (void*)4;50  _ptr_nsobject = (NSObject*)5;51  _id_objc = (id)6;52}53@end54 55// RUN: %lldb -b -o "b objc-gnustep-print.m:43" -o "run" -o "p self" -o "p *self" -- %t | FileCheck %s --check-prefix=SELF56//57// SELF: (lldb) b objc-gnustep-print.m:4358// SELF: Breakpoint {{.*}} at objc-gnustep-print.m59//60// SELF: (lldb) run61// SELF: Process {{[0-9]+}} stopped62// SELF: -[TestObj check_ivars_zeroed](self=[[SELF_PTR:0x[0-9a-f]+]]{{.*}}) at objc-gnustep-print.m63//64// SELF: (lldb) p self65// SELF: (TestObj *) [[SELF_PTR]]66//67// SELF: (lldb) p *self68// SELF: (TestObj) {69// SELF:   NSObject = {70// SELF:     isa71// SELF:     refcount72// SELF:   }73// SELF:   _int = 074// SELF:   _float = 075// SELF:   _char = '\0'76// SELF:   _ptr_void = 0x{{0*}}77// SELF:   _ptr_nsobject = nil78// SELF:   _id_objc = nil79// SELF: }80 81// RUN: %lldb -b -o "b objc-gnustep-print.m:106" -o "run" -o "p t->_int" -o "p t->_float" -o "p t->_char" \82// RUN:          -o "p t->_ptr_void" -o "p t->_ptr_nsobject" -o "p t->_id_objc" -- %t | FileCheck %s --check-prefix=IVARS_SET83//84// IVARS_SET: (lldb) p t->_int85// IVARS_SET: (int) 186//87// IVARS_SET: (lldb) p t->_float88// IVARS_SET: (float) 289//90// IVARS_SET: (lldb) p t->_char91// IVARS_SET: (char) '\x03'92//93// IVARS_SET: (lldb) p t->_ptr_void94// IVARS_SET: (void *) 0x{{0*}}495//96// IVARS_SET: (lldb) p t->_ptr_nsobject97// IVARS_SET: (NSObject *) 0x{{0*}}598//99// IVARS_SET: (lldb) p t->_id_objc100// IVARS_SET: (id) 0x{{0*}}6101 102int main() {103  TestObj *t = [TestObj new];104  [t check_ivars_zeroed];105  [t set_ivars];106  return 0;107}108