iOS clang 编译 oc 代码

时间:2023-03-10 02:30:06
iOS clang 编译 oc 代码
clang -x objective-c -rewrite-objc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk xxxxx.m

  

编译完xx.m以后,截取部分,如下:

extern "C" unsigned long OBJC_IVAR_$_ViewController$_testStr;
extern "C" unsigned long OBJC_IVAR_$_ViewController$_atestStr;
struct ViewController_IMPL {
struct UIViewController_IMPL UIViewController_IVARS;
NSString *_testStr;
NSString *_atestStr;
}; /* @end */ #ifndef _REWRITER_typedef_NotificationVO
#define _REWRITER_typedef_NotificationVO
typedef struct objc_object NotificationVO;
typedef struct {} _objc_exc_NotificationVO;
#endif struct NotificationVO_IMPL {
struct NSObject_IMPL NSObject_IVARS;
}; /* @end */ // @interface ViewController ()
// @property (nonatomic,strong) NSString * testStr;
// @property (atomic,strong) NSString * atestStr;
/* @end */ // @implementation ViewController static void _I_ViewController_viewDidLoad(ViewController * self, SEL _cmd) {
((void (*)(__rw_objc_super *, SEL))(void *)objc_msgSendSuper)((__rw_objc_super){(id)self, (id)class_getSuperclass(objc_getClass("ViewController"))}, sel_registerName("viewDidLoad"));
((void (*)(id, SEL, NSString *))(void *)objc_msgSend)((id)self, sel_registerName("setTestStr:"), (NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_0);
UITapGestureRecognizer * tap = ((UITapGestureRecognizer *(*)(id, SEL, id _Nullable, SEL _Nullable))(void *)objc_msgSend)((id)((UITapGestureRecognizer *(*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass("UITapGestureRecognizer"), sel_registerName("alloc")), sel_registerName("initWithTarget:action:"), (id _Nullable)self, sel_registerName("tapFunc"));
((void (*)(id, SEL, BOOL))(void *)objc_msgSend)((id)((UIView *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("view")), sel_registerName("setUserInteractionEnabled:"), ((bool)1));
((void (*)(id, SEL, UIGestureRecognizer *))(void *)objc_msgSend)((id)((UIView *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("view")), sel_registerName("addGestureRecognizer:"), (UIGestureRecognizer *)tap); ((void (*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("dotest1")); int a = 5;
for (int i = 0; i < 5; i++) {
a = a + i;
}
} struct __ViewController__dotest1_block_impl_0 {
struct __block_impl impl;
struct __ViewController__dotest1_block_desc_0* Desc;
__ViewController__dotest1_block_impl_0(void *fp, struct __ViewController__dotest1_block_desc_0 *desc, int flags=0) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
static void __ViewController__dotest1_block_func_0(struct __ViewController__dotest1_block_impl_0 *__cself) { NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_3);
} static struct __ViewController__dotest1_block_desc_0 {
size_t reserved;
size_t Block_size;
} __ViewController__dotest1_block_desc_0_DATA = { 0, sizeof(struct __ViewController__dotest1_block_impl_0)}; struct __ViewController__dotest1_block_impl_1 {
struct __block_impl impl;
struct __ViewController__dotest1_block_desc_1* Desc;
__ViewController__dotest1_block_impl_1(void *fp, struct __ViewController__dotest1_block_desc_1 *desc, int flags=0) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
static void __ViewController__dotest1_block_func_1(struct __ViewController__dotest1_block_impl_1 *__cself) { NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_2);
dispatch_sync(dispatch_get_main_queue(), ((void (*)())&__ViewController__dotest1_block_impl_0((void *)__ViewController__dotest1_block_func_0, &__ViewController__dotest1_block_desc_0_DATA)));
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_4);
} static struct __ViewController__dotest1_block_desc_1 {
size_t reserved;
size_t Block_size;
} __ViewController__dotest1_block_desc_1_DATA = { 0, sizeof(struct __ViewController__dotest1_block_impl_1)}; static void _I_ViewController_dotest1(ViewController * self, SEL _cmd) {
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_1);
dispatch_async(dispatch_get_global_queue(0, 0), ((void (*)())&__ViewController__dotest1_block_impl_1((void *)__ViewController__dotest1_block_func_1, &__ViewController__dotest1_block_desc_1_DATA)));
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_5);
} static void _I_ViewController_dotest2(ViewController * self, SEL _cmd) {
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_6);
} struct __ViewController__tapFunc_block_impl_0 {
struct __block_impl impl;
struct __ViewController__tapFunc_block_desc_0* Desc;
ViewController *self;
__ViewController__tapFunc_block_impl_0(void *fp, struct __ViewController__tapFunc_block_desc_0 *desc, ViewController *_self, int flags=0) : self(_self) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
static void __ViewController__tapFunc_block_func_0(struct __ViewController__tapFunc_block_impl_0 *__cself) {
ViewController *self = __cself->self; // bound by copy ((void (*)(id, SEL, NSString *))(void *)objc_msgSend)((id)self, sel_registerName("setTestStr:"), (NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_9);
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_10,((NSString *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("testStr")));
}
static void __ViewController__tapFunc_block_copy_0(struct __ViewController__tapFunc_block_impl_0*dst, struct __ViewController__tapFunc_block_impl_0*src) {_Block_object_assign((void*)&dst->self, (void*)src->self, 3/*BLOCK_FIELD_IS_OBJECT*/);} static void __ViewController__tapFunc_block_dispose_0(struct __ViewController__tapFunc_block_impl_0*src) {_Block_object_dispose((void*)src->self, 3/*BLOCK_FIELD_IS_OBJECT*/);} static struct __ViewController__tapFunc_block_desc_0 {
size_t reserved;
size_t Block_size;
void (*copy)(struct __ViewController__tapFunc_block_impl_0*, struct __ViewController__tapFunc_block_impl_0*);
void (*dispose)(struct __ViewController__tapFunc_block_impl_0*);
} __ViewController__tapFunc_block_desc_0_DATA = { 0, sizeof(struct __ViewController__tapFunc_block_impl_0), __ViewController__tapFunc_block_copy_0, __ViewController__tapFunc_block_dispose_0}; struct __ViewController__tapFunc_block_impl_1 {
struct __block_impl impl;
struct __ViewController__tapFunc_block_desc_1* Desc;
ViewController *self;
__ViewController__tapFunc_block_impl_1(void *fp, struct __ViewController__tapFunc_block_desc_1 *desc, ViewController *_self, int flags=0) : self(_self) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
static void __ViewController__tapFunc_block_func_1(struct __ViewController__tapFunc_block_impl_1 *__cself) {
ViewController *self = __cself->self; // bound by copy ((void (*)(id, SEL, NSString *))(void *)objc_msgSend)((id)self, sel_registerName("setTestStr:"), (NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_11);
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_12,((NSString *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("testStr")));
}
static void __ViewController__tapFunc_block_copy_1(struct __ViewController__tapFunc_block_impl_1*dst, struct __ViewController__tapFunc_block_impl_1*src) {_Block_object_assign((void*)&dst->self, (void*)src->self, 3/*BLOCK_FIELD_IS_OBJECT*/);} static void __ViewController__tapFunc_block_dispose_1(struct __ViewController__tapFunc_block_impl_1*src) {_Block_object_dispose((void*)src->self, 3/*BLOCK_FIELD_IS_OBJECT*/);} static struct __ViewController__tapFunc_block_desc_1 {
size_t reserved;
size_t Block_size;
void (*copy)(struct __ViewController__tapFunc_block_impl_1*, struct __ViewController__tapFunc_block_impl_1*);
void (*dispose)(struct __ViewController__tapFunc_block_impl_1*);
} __ViewController__tapFunc_block_desc_1_DATA = { 0, sizeof(struct __ViewController__tapFunc_block_impl_1), __ViewController__tapFunc_block_copy_1, __ViewController__tapFunc_block_dispose_1}; struct __ViewController__tapFunc_block_impl_2 {
struct __block_impl impl;
struct __ViewController__tapFunc_block_desc_2* Desc;
ViewController *self;
__ViewController__tapFunc_block_impl_2(void *fp, struct __ViewController__tapFunc_block_desc_2 *desc, ViewController *_self, int flags=0) : self(_self) {
impl.isa = &_NSConcreteStackBlock;
impl.Flags = flags;
impl.FuncPtr = fp;
Desc = desc;
}
};
static void __ViewController__tapFunc_block_func_2(struct __ViewController__tapFunc_block_impl_2 *__cself) {
ViewController *self = __cself->self; // bound by copy NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_13,((NSString *(*)(id, SEL))(void *)objc_msgSend)((id)self, sel_registerName("testStr")));
}
static void __ViewController__tapFunc_block_copy_2(struct __ViewController__tapFunc_block_impl_2*dst, struct __ViewController__tapFunc_block_impl_2*src) {_Block_object_assign((void*)&dst->self, (void*)src->self, 3/*BLOCK_FIELD_IS_OBJECT*/);} static void __ViewController__tapFunc_block_dispose_2(struct __ViewController__tapFunc_block_impl_2*src) {_Block_object_dispose((void*)src->self, 3/*BLOCK_FIELD_IS_OBJECT*/);} static struct __ViewController__tapFunc_block_desc_2 {
size_t reserved;
size_t Block_size;
void (*copy)(struct __ViewController__tapFunc_block_impl_2*, struct __ViewController__tapFunc_block_impl_2*);
void (*dispose)(struct __ViewController__tapFunc_block_impl_2*);
} __ViewController__tapFunc_block_desc_2_DATA = { 0, sizeof(struct __ViewController__tapFunc_block_impl_2), __ViewController__tapFunc_block_copy_2, __ViewController__tapFunc_block_dispose_2}; static void _I_ViewController_tapFunc(ViewController * self, SEL _cmd) {
((void (*)(id, SEL, NSNotificationName, id _Nullable))(void *)objc_msgSend)((id)((NSNotificationCenter *(*)(id, SEL))(void *)objc_msgSend)((id)objc_getClass("NSNotificationCenter"), sel_registerName("defaultCenter")), sel_registerName("postNotificationName:object:"), (NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_7, (id _Nullable)__null);;
NSLog((NSString *)&__NSConstantStringImpl__var_folders_05_lgchbchj0bs9m_wy5dlkgc580pdxk1_T_ViewController_95586e_mi_8);
dispatch_queue_t q1 = dispatch_queue_create("com.qiye.q1", (&(_dispatch_queue_attr_concurrent)));
dispatch_async(q1, ((void (*)())&__ViewController__tapFunc_block_impl_0((void *)__ViewController__tapFunc_block_func_0, &__ViewController__tapFunc_block_desc_0_DATA, self, 570425344))); dispatch_queue_t q2 = dispatch_queue_create("com.qiye.q2", (&(_dispatch_queue_attr_concurrent)));
dispatch_async(q2, ((void (*)())&__ViewController__tapFunc_block_impl_1((void *)__ViewController__tapFunc_block_func_1, &__ViewController__tapFunc_block_desc_1_DATA, self, 570425344))); dispatch_queue_t q3 = dispatch_queue_create("com.qiye.q3", (&(_dispatch_queue_attr_concurrent)));
dispatch_async(q3, ((void (*)())&__ViewController__tapFunc_block_impl_2((void *)__ViewController__tapFunc_block_func_2, &__ViewController__tapFunc_block_desc_2_DATA, self, 570425344)));
} static void _I_ViewController_didReceiveMemoryWarning(ViewController * self, SEL _cmd) {
((void (*)(__rw_objc_super *, SEL))(void *)objc_msgSendSuper)((__rw_objc_super){(id)self, (id)class_getSuperclass(objc_getClass("ViewController"))}, sel_registerName("didReceiveMemoryWarning")); } static NSString * _I_ViewController_testStr(ViewController * self, SEL _cmd) { return (*(NSString **)((char *)self + OBJC_IVAR_$_ViewController$_testStr)); }
static void _I_ViewController_setTestStr_(ViewController * self, SEL _cmd, NSString *testStr) { (*(NSString **)((char *)self + OBJC_IVAR_$_ViewController$_testStr)) = testStr; } static NSString * _I_ViewController_atestStr(ViewController * self, SEL _cmd) { return (*(NSString **)((char *)self + OBJC_IVAR_$_ViewController$_atestStr)); }
static void _I_ViewController_setAtestStr_(ViewController * self, SEL _cmd, NSString *atestStr) { (*(NSString **)((char *)self + OBJC_IVAR_$_ViewController$_atestStr)) = atestStr; }
// @end extern "C" __declspec(dllimport) struct objc_cache _objc_empty_cache;
#pragma warning(disable:4273) extern "C" unsigned long int OBJC_IVAR_$_ViewController$_testStr __attribute__ ((used, section ("__DATA,__objc_ivar"))) = __OFFSETOFIVAR__(struct ViewController, _testStr);
extern "C" unsigned long int OBJC_IVAR_$_ViewController$_atestStr __attribute__ ((used, section ("__DATA,__objc_ivar"))) = __OFFSETOFIVAR__(struct ViewController, _atestStr); static struct /*_ivar_list_t*/ {
unsigned int entsize; // sizeof(struct _prop_t)
unsigned int count;
struct _ivar_t ivar_list[2];
} _OBJC_$_INSTANCE_VARIABLES_ViewController __attribute__ ((used, section ("__DATA,__objc_const"))) = {
sizeof(_ivar_t),
2,
{{(unsigned long int *)&OBJC_IVAR_$_ViewController$_testStr, "_testStr", "@\"NSString\"", 3, 8},
{(unsigned long int *)&OBJC_IVAR_$_ViewController$_atestStr, "_atestStr", "@\"NSString\"", 3, 8}}
}; static struct /*_method_list_t*/ {
unsigned int entsize; // sizeof(struct _objc_method)
unsigned int method_count;
struct _objc_method method_list[9];
} _OBJC_$_INSTANCE_METHODS_ViewController __attribute__ ((used, section ("__DATA,__objc_const"))) = {
sizeof(_objc_method),
9,
{{(struct objc_selector *)"viewDidLoad", "v16@0:8", (void *)_I_ViewController_viewDidLoad},
{(struct objc_selector *)"dotest1", "v16@0:8", (void *)_I_ViewController_dotest1},
{(struct objc_selector *)"dotest2", "v16@0:8", (void *)_I_ViewController_dotest2},
{(struct objc_selector *)"tapFunc", "v16@0:8", (void *)_I_ViewController_tapFunc},
{(struct objc_selector *)"didReceiveMemoryWarning", "v16@0:8", (void *)_I_ViewController_didReceiveMemoryWarning},
{(struct objc_selector *)"testStr", "@16@0:8", (void *)_I_ViewController_testStr},
{(struct objc_selector *)"setTestStr:", "v24@0:8@16", (void *)_I_ViewController_setTestStr_},
{(struct objc_selector *)"atestStr", "@16@0:8", (void *)_I_ViewController_atestStr},
{(struct objc_selector *)"setAtestStr:", "v24@0:8@16", (void *)_I_ViewController_setAtestStr_}}
}; static struct _class_ro_t _OBJC_METACLASS_RO_$_ViewController __attribute__ ((used, section ("__DATA,__objc_const"))) = {
1, sizeof(struct _class_t), sizeof(struct _class_t),
(unsigned int)0,
0,
"ViewController",
0,
0,
0,
0,
0,
}; static struct _class_ro_t _OBJC_CLASS_RO_$_ViewController __attribute__ ((used, section ("__DATA,__objc_const"))) = {
0, __OFFSETOFIVAR__(struct ViewController, _testStr), sizeof(struct ViewController_IMPL),
(unsigned int)0,
0,
"ViewController",
(const struct _method_list_t *)&_OBJC_$_INSTANCE_METHODS_ViewController,
0,
(const struct _ivar_list_t *)&_OBJC_$_INSTANCE_VARIABLES_ViewController,
0,
0,
}; extern "C" __declspec(dllimport) struct _class_t OBJC_METACLASS_$_UIViewController;
extern "C" __declspec(dllimport) struct _class_t OBJC_METACLASS_$_NSObject; extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_ViewController __attribute__ ((used, section ("__DATA,__objc_data"))) = {
0, // &OBJC_METACLASS_$_NSObject,
0, // &OBJC_METACLASS_$_UIViewController,
0, // (void *)&_objc_empty_cache,
0, // unused, was (void *)&_objc_empty_vtable,
&_OBJC_METACLASS_RO_$_ViewController,
}; extern "C" __declspec(dllimport) struct _class_t OBJC_CLASS_$_UIViewController; extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_ViewController __attribute__ ((used, section ("__DATA,__objc_data"))) = {
0, // &OBJC_METACLASS_$_ViewController,
0, // &OBJC_CLASS_$_UIViewController,
0, // (void *)&_objc_empty_cache,
0, // unused, was (void *)&_objc_empty_vtable,
&_OBJC_CLASS_RO_$_ViewController,
};
static void OBJC_CLASS_SETUP_$_ViewController(void ) {
OBJC_METACLASS_$_ViewController.isa = &OBJC_METACLASS_$_NSObject;
OBJC_METACLASS_$_ViewController.superclass = &OBJC_METACLASS_$_UIViewController;
OBJC_METACLASS_$_ViewController.cache = &_objc_empty_cache;
OBJC_CLASS_$_ViewController.isa = &OBJC_METACLASS_$_ViewController;
OBJC_CLASS_$_ViewController.superclass = &OBJC_CLASS_$_UIViewController;
OBJC_CLASS_$_ViewController.cache = &_objc_empty_cache;
}
#pragma section(".objc_inithooks$B", long, read, write)
__declspec(allocate(".objc_inithooks$B")) static void *OBJC_CLASS_SETUP[] = {
(void *)&OBJC_CLASS_SETUP_$_ViewController,
};
static struct _class_t *L_OBJC_LABEL_CLASS_$ [1] __attribute__((used, section ("__DATA, __objc_classlist,regular,no_dead_strip")))= {
&OBJC_CLASS_$_ViewController,
};
static struct IMAGE_INFO { unsigned version; unsigned flag; } _OBJC_IMAGE_INFO = { 0, 2 };