Lines Matching refs:Result

375     void ObjCIvarBitfieldGroupDecl(ObjCIvarDecl *IV, std::string &Result);
377 void ObjCIvarBitfieldGroupType(ObjCIvarDecl *IV, std::string &Result);
379 void ObjCIvarBitfieldGroupOffset(ObjCIvarDecl *IV, std::string &Result);
397 std::string &Result);
399 void RewriteObjCFieldDecl(FieldDecl *fieldDecl, std::string &Result);
403 std::string &Result);
405 bool RewriteObjCFieldDeclType(QualType &Type, std::string &Result);
408 std::string &Result);
448 std::string &Result);
450 std::string &Result);
453 StringRef prefix, StringRef ClassName, std::string &Result);
455 std::string &Result);
456 void RewriteClassSetupInitHook(std::string &Result);
458 void RewriteMetaDataIntoBuffer(std::string &Result);
459 void WriteImageInfo(std::string &Result);
461 std::string &Result);
462 void RewriteCategorySetupInitHook(std::string &Result);
466 std::string &Result);
838 ObjCIvarDecl *IvarDecl, std::string &Result) {
839 Result += "OBJC_IVAR_$_";
840 Result += IDecl->getName();
841 Result += "$";
842 Result += IvarDecl->getName();
1992 std::string Result;
1993 ConvertSourceLocationToLineDirective(Catch->getLocStart(), Result);
2001 Result += "catch (_objc_exc_"; Result += IDecl->getNameAsString();
2002 Result += " *_"; Result += catchDecl->getNameAsString();
2003 Result += ")";
2004 ReplaceText(startLoc, rParenBuf-startBuf+1, Result);
2006 Result.clear();
2007 Result = "{ ";
2008 Result += IDecl->getNameAsString();
2009 Result += " *"; Result += catchDecl->getNameAsString();
2010 Result += " = ("; Result += IDecl->getNameAsString(); Result += "*)";
2011 Result += "_"; Result += catchDecl->getNameAsString();
2013 Result += "; ";
2015 ReplaceText(lBraceLoc, 1, Result);
3127 /// returnType - Result type of the method being synthesized.
3718 std::string &Result) {
3720 Result += "\t";
3726 return RewriteObjCFieldDeclType(ElemTy, Result);
3732 Result += "\n\tstruct ";
3734 Result += "\n\tunion ";
3738 Result += RD->getName();
3741 Result += " ";
3744 Result += " {\n";
3746 RewriteObjCFieldDecl(FD, Result);
3747 Result += "\t} ";
3754 Result += "\n\tenum ";
3755 Result += ED->getName();
3758 Result += " ";
3762 Result += " {\n";
3764 Result += "\t"; Result += EC->getName(); Result += " = ";
3766 Result += Val.toString(10);
3767 Result += ",\n";
3769 Result += "\t} ";
3774 Result += "\t";
3783 std::string &Result) {
3787 bool EleboratedType = RewriteObjCFieldDeclType(Type, Result);
3790 Result += Name;
3792 Result += " : "; Result += utostr(fieldDecl->getBitWidthValue(*Context));
3798 Result += "[";
3800 Result += utostr(Dim.getZExtValue());
3801 Result += "]";
3807 Result += ";\n";
3813 std::string &Result) {
3836 RewriteObjCFieldDeclType(Type, Result);
3837 Result += ";";
3927 std::string &Result) {
3929 Result += CDecl->getName();
3930 Result += "__GRBF_";
3932 Result += utostr(GroupNo);
3940 std::string &Result) {
3942 Result += CDecl->getName();
3943 Result += "__T_";
3945 Result += utostr(GroupNo);
3953 std::string &Result) {
3954 Result += "OBJC_IVAR_$_";
3955 ObjCIvarBitfieldGroupDecl(IV, Result);
3968 std::string &Result) {
3989 ReplaceText(LocStart, endBuf-startBuf, Result);
3997 RewriteLocallyDefinedNamedAggregates(IVars[i], Result);
4005 RewriteObjCFieldDeclType(QT, Result);
4006 Result += ";";
4011 Result += "\nstruct ";
4012 Result += CDecl->getNameAsString();
4013 Result += "_IMPL {\n";
4016 Result += "\tstruct "; Result += RCDecl->getNameAsString();
4017 Result += "_IMPL "; Result += RCDecl->getNameAsString();
4018 Result += "_IVARS;\n";
4024 Result += "\tstruct ";
4025 ObjCIvarBitfieldGroupType(IV, Result); Result += " ";
4026 ObjCIvarBitfieldGroupDecl(IV, Result); Result += ";\n";
4031 RewriteObjCFieldDecl(IVars[i], Result);
4034 Result += "};\n";
4036 ReplaceText(LocStart, endBuf-startBuf, Result);
4045 std::string &Result) {
4061 Result += "\n";
4063 Result += "__declspec(allocate(\".objc_ivar$B\")) ";
4064 Result += "extern \"C\" ";
4068 Result += "__declspec(dllimport) ";
4070 Result += "unsigned long ";
4072 ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
4076 WriteInternalIvarName(CDecl, IvarDecl, Result);
4077 Result += ";";
5925 std::string &Result) {
5928 Result += "static ";
5929 Result += "struct _protocol_t *";
5930 Result += "_OBJC_PROTOCOL_REFERENCE_$_";
5931 Result += PDecl->getNameAsString();
5932 Result += " = &";
5933 Result += "_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
5934 Result += ";\n";
6174 std::string &Result) {
6175 Result += "__OFFSETOFIVAR__(struct ";
6176 Result += ivar->getContainingInterface()->getNameAsString();
6178 Result += "_IMPL";
6179 Result += ", ";
6181 ObjCIvarBitfieldGroupDecl(ivar, Result);
6183 Result += ivar->getNameAsString();
6184 Result += ")";
6289 static void WriteModernMetadataDeclarations(ASTContext *Context, std::string &Result) {
6294 Result += "\nstruct _prop_t {\n";
6295 Result += "\tconst char *name;\n";
6296 Result += "\tconst char *attributes;\n";
6297 Result += "};\n";
6299 Result += "\nstruct _protocol_t;\n";
6301 Result += "\nstruct _objc_method {\n";
6302 Result += "\tstruct objc_selector * _cmd;\n";
6303 Result += "\tconst char *method_type;\n";
6304 Result += "\tvoid *_imp;\n";
6305 Result += "};\n";
6307 Result += "\nstruct _protocol_t {\n";
6308 Result += "\tvoid * isa; // NULL\n";
6309 Result += "\tconst char *protocol_name;\n";
6310 Result += "\tconst struct _protocol_list_t * protocol_list; // super protocols\n";
6311 Result += "\tconst struct method_list_t *instance_methods;\n";
6312 Result += "\tconst struct method_list_t *class_methods;\n";
6313 Result += "\tconst struct method_list_t *optionalInstanceMethods;\n";
6314 Result += "\tconst struct method_list_t *optionalClassMethods;\n";
6315 Result += "\tconst struct _prop_list_t * properties;\n";
6316 Result += "\tconst unsigned int size; // sizeof(struct _protocol_t)\n";
6317 Result += "\tconst unsigned int flags; // = 0\n";
6318 Result += "\tconst char ** extendedMethodTypes;\n";
6319 Result += "};\n";
6321 Result += "\nstruct _ivar_t {\n";
6322 Result += "\tunsigned long int *offset; // pointer to ivar offset location\n";
6323 Result += "\tconst char *name;\n";
6324 Result += "\tconst char *type;\n";
6325 Result += "\tunsigned int alignment;\n";
6326 Result += "\tunsigned int size;\n";
6327 Result += "};\n";
6329 Result += "\nstruct _class_ro_t {\n";
6330 Result += "\tunsigned int flags;\n";
6331 Result += "\tunsigned int instanceStart;\n";
6332 Result += "\tunsigned int instanceSize;\n";
6335 Result += "\tunsigned int reserved;\n";
6336 Result += "\tconst unsigned char *ivarLayout;\n";
6337 Result += "\tconst char *name;\n";
6338 Result += "\tconst struct _method_list_t *baseMethods;\n";
6339 Result += "\tconst struct _objc_protocol_list *baseProtocols;\n";
6340 Result += "\tconst struct _ivar_list_t *ivars;\n";
6341 Result += "\tconst unsigned char *weakIvarLayout;\n";
6342 Result += "\tconst struct _prop_list_t *properties;\n";
6343 Result += "};\n";
6345 Result += "\nstruct _class_t {\n";
6346 Result += "\tstruct _class_t *isa;\n";
6347 Result += "\tstruct _class_t *superclass;\n";
6348 Result += "\tvoid *cache;\n";
6349 Result += "\tvoid *vtable;\n";
6350 Result += "\tstruct _class_ro_t *ro;\n";
6351 Result += "};\n";
6353 Result += "\nstruct _category_t {\n";
6354 Result += "\tconst char *name;\n";
6355 Result += "\tstruct _class_t *cls;\n";
6356 Result += "\tconst struct _method_list_t *instance_methods;\n";
6357 Result += "\tconst struct _method_list_t *class_methods;\n";
6358 Result += "\tconst struct _protocol_list_t *protocols;\n";
6359 Result += "\tconst struct _prop_list_t *properties;\n";
6360 Result += "};\n";
6362 Result += "extern \"C\" __declspec(dllimport) struct objc_cache _objc_empty_cache;\n";
6363 Result += "#pragma warning(disable:4273)\n";
6367 static void Write_protocol_list_t_TypeDecl(std::string &Result,
6369 Result += "struct /*_protocol_list_t*/"; Result += " {\n";
6370 Result += "\tlong protocol_count; // Note, this is 32/64 bit\n";
6371 Result += "\tstruct _protocol_t *super_protocols[";
6372 Result += utostr(super_protocol_count); Result += "];\n";
6373 Result += "}";
6376 static void Write_method_list_t_TypeDecl(std::string &Result,
6378 Result += "struct /*_method_list_t*/"; Result += " {\n";
6379 Result += "\tunsigned int entsize; // sizeof(struct _objc_method)\n";
6380 Result += "\tunsigned int method_count;\n";
6381 Result += "\tstruct _objc_method method_list[";
6382 Result += utostr(method_count); Result += "];\n";
6383 Result += "}";
6386 static void Write__prop_list_t_TypeDecl(std::string &Result,
6388 Result += "struct /*_prop_list_t*/"; Result += " {\n";
6389 Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
6390 Result += "\tunsigned int count_of_properties;\n";
6391 Result += "\tstruct _prop_t prop_list[";
6392 Result += utostr(property_count); Result += "];\n";
6393 Result += "}";
6396 static void Write__ivar_list_t_TypeDecl(std::string &Result,
6398 Result += "struct /*_ivar_list_t*/"; Result += " {\n";
6399 Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
6400 Result += "\tunsigned int count;\n";
6401 Result += "\tstruct _ivar_t ivar_list[";
6402 Result += utostr(ivar_count); Result += "];\n";
6403 Result += "}";
6406 static void Write_protocol_list_initializer(ASTContext *Context, std::string &Result,
6411 Result += "\nstatic ";
6412 Write_protocol_list_t_TypeDecl(Result, SuperProtocols.size());
6413 Result += " "; Result += VarName;
6414 Result += ProtocolName;
6415 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6416 Result += "\t"; Result += utostr(SuperProtocols.size()); Result += ",\n";
6419 Result += "\t&"; Result += "_OBJC_PROTOCOL_";
6420 Result += SuperPD->getNameAsString();
6422 Result += "\n};\n";
6424 Result += ",\n";
6430 ASTContext *Context, std::string &Result,
6436 Result += "\nstatic ";
6437 Write_method_list_t_TypeDecl(Result, Methods.size());
6438 Result += " "; Result += VarName;
6439 Result += TopLevelDeclName;
6440 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6441 Result += "\t"; Result += "sizeof(_objc_method)"; Result += ",\n";
6442 Result += "\t"; Result += utostr(Methods.size()); Result += ",\n";
6446 Result += "\t{{(struct objc_selector *)\"";
6448 Result += "\t{(struct objc_selector *)\"";
6449 Result += (MD)->getSelector().getAsString(); Result += "\"";
6450 Result += ", ";
6453 Result += "\""; Result += MethodTypeString; Result += "\"";
6454 Result += ", ";
6456 Result += "0";
6458 Result += "(void *)";
6459 Result += RewriteObj.MethodInternalNames[MD];
6462 Result += "}}\n";
6464 Result += "},\n";
6466 Result += "};\n";
6471 ASTContext *Context, std::string &Result,
6477 Result += "\nstatic ";
6478 Write__prop_list_t_TypeDecl(Result, Properties.size());
6479 Result += " "; Result += VarName;
6480 Result += ProtocolName;
6481 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6482 Result += "\t"; Result += "sizeof(_prop_t)"; Result += ",\n";
6483 Result += "\t"; Result += utostr(Properties.size()); Result += ",\n";
6487 Result += "\t{{\"";
6489 Result += "\t{\"";
6490 Result += PropDecl->getName(); Result += "\",";
6494 Result += "\""; Result += QuotePropertyTypeString; Result += "\"";
6496 Result += "}}\n";
6498 Result += "},\n";
6500 Result += "};\n";
6518 static void Write__class_ro_t_initializer(ASTContext *Context, std::string &Result,
6528 Result += "\nstatic struct _class_ro_t ";
6529 Result += VarName; Result += ClassName;
6530 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6531 Result += "\t";
6532 Result += llvm::utostr(flags); Result += ", ";
6533 Result += InstanceStart; Result += ", ";
6534 Result += InstanceSize; Result += ", \n";
6535 Result += "\t";
6539 Result += "(unsigned int)0, \n\t";
6541 Result += "0, \n\t";
6542 Result += "\""; Result += ClassName; Result += "\",\n\t";
6545 Result += "(const struct _method_list_t *)&";
6547 Result += "_OBJC_$_CLASS_METHODS_";
6549 Result += "_OBJC_$_INSTANCE_METHODS_";
6550 Result += ClassName;
6551 Result += ",\n\t";
6554 Result += "0, \n\t";
6557 Result += "(const struct _objc_protocol_list *)&";
6558 Result += "_OBJC_CLASS_PROTOCOLS_$_"; Result += ClassName;
6559 Result += ",\n\t";
6562 Result += "0, \n\t";
6565 Result += "(const struct _ivar_list_t *)&";
6566 Result += "_OBJC_$_INSTANCE_VARIABLES_"; Result += ClassName;
6567 Result += ",\n\t";
6570 Result += "0, \n\t";
6573 Result += "0, \n\t";
6575 Result += "(const struct _prop_list_t *)&";
6576 Result += "_OBJC_$_PROP_LIST_"; Result += ClassName;
6577 Result += ",\n";
6580 Result += "0, \n";
6582 Result += "};\n";
6585 static void Write_class_t(ASTContext *Context, std::string &Result,
6601 Result += "\n";
6602 Result += "extern \"C\" ";
6604 Result += "__declspec(dllexport) ";
6606 Result += "__declspec(dllimport) ";
6608 Result += "struct _class_t OBJC_CLASS_$_";
6609 Result += CDecl->getNameAsString();
6610 Result += ";\n";
6615 Result += "\n";
6616 Result += "extern \"C\" ";
6618 Result += "__declspec(dllexport) ";
6620 Result += "__declspec(dllimport) ";
6622 Result += "struct _class_t ";
6623 Result += VarName;
6624 Result += SuperClass->getNameAsString();
6625 Result += ";\n";
6628 Result += "extern \"C\" ";
6630 Result += "__declspec(dllexport) ";
6632 Result += "__declspec(dllimport) ";
6634 Result += "struct _class_t ";
6635 Result += VarName;
6636 Result += RootClass->getNameAsString();
6637 Result += ";\n";
6641 Result += "\nextern \"C\" __declspec(dllexport) struct _class_t ";
6642 Result += VarName; Result += CDecl->getNameAsString();
6643 Result += " __attribute__ ((used, section (\"__DATA,__objc_data\"))) = {\n";
6644 Result += "\t";
6647 Result += "0, // &"; Result += VarName;
6648 Result += RootClass->getNameAsString();
6649 Result += ",\n\t";
6650 Result += "0, // &"; Result += VarName;
6651 Result += CDecl->getSuperClass()->getNameAsString();
6652 Result += ",\n\t";
6655 Result += "0, // &"; Result += VarName;
6656 Result += CDecl->getNameAsString();
6657 Result += ",\n\t";
6658 Result += "0, // &OBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6659 Result += ",\n\t";
6663 Result += "0, // &OBJC_METACLASS_$_";
6664 Result += CDecl->getNameAsString();
6665 Result += ",\n\t";
6667 Result += "0, // &"; Result += VarName;
6668 Result += CDecl->getSuperClass()->getNameAsString();
6669 Result += ",\n\t";
6672 Result += "0,\n\t";
6674 Result += "0, // (void *)&_objc_empty_cache,\n\t";
6675 Result += "0, // unused, was (void *)&_objc_empty_vtable,\n\t";
6677 Result += "&_OBJC_METACLASS_RO_$_";
6679 Result += "&_OBJC_CLASS_RO_$_";
6680 Result += CDecl->getNameAsString();
6681 Result += ",\n};\n";
6691 Result += "static void OBJC_CLASS_SETUP_$_";
6692 Result += CDecl->getNameAsString();
6693 Result += "(void ) {\n";
6694 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6695 Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
6696 Result += RootClass->getNameAsString(); Result += ";\n";
6698 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6699 Result += ".superclass = ";
6701 Result += "&OBJC_CLASS_$_";
6703 Result += "&OBJC_METACLASS_$_";
6705 Result += SuperClass->getNameAsString(); Result += ";\n";
6707 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6708 Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
6710 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6711 Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
6712 Result += CDecl->getNameAsString(); Result += ";\n";
6715 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6716 Result += ".superclass = "; Result += "&OBJC_CLASS_$_";
6717 Result += SuperClass->getNameAsString(); Result += ";\n";
6720 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6721 Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
6722 Result += "}\n";
6726 std::string &Result,
6737 Result += "\n";
6738 Result += "extern \"C\" ";
6740 Result += "__declspec(dllexport) ";
6742 Result += "__declspec(dllimport) ";
6744 Result += "struct _class_t ";
6745 Result += "OBJC_CLASS_$_"; Result += ClassName;
6746 Result += ";\n";
6748 Result += "\nstatic struct _category_t ";
6749 Result += "_OBJC_$_CATEGORY_";
6750 Result += ClassName; Result += "_$_"; Result += CatName;
6751 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
6752 Result += "{\n";
6753 Result += "\t\""; Result += ClassName; Result += "\",\n";
6754 Result += "\t0, // &"; Result += "OBJC_CLASS_$_"; Result += ClassName;
6755 Result += ",\n";
6757 Result += "\t(const struct _method_list_t *)&";
6758 Result += "_OBJC_$_CATEGORY_INSTANCE_METHODS_";
6759 Result += ClassName; Result += "_$_"; Result += CatName;
6760 Result += ",\n";
6763 Result += "\t0,\n";
6766 Result += "\t(const struct _method_list_t *)&";
6767 Result += "_OBJC_$_CATEGORY_CLASS_METHODS_";
6768 Result += ClassName; Result += "_$_"; Result += CatName;
6769 Result += ",\n";
6772 Result += "\t0,\n";
6775 Result += "\t(const struct _protocol_list_t *)&";
6776 Result += "_OBJC_CATEGORY_PROTOCOLS_$_";
6777 Result += ClassName; Result += "_$_"; Result += CatName;
6778 Result += ",\n";
6781 Result += "\t0,\n";
6784 Result += "\t(const struct _prop_list_t *)&"; Result += "_OBJC_$_PROP_LIST_";
6785 Result += ClassName; Result += "_$_"; Result += CatName;
6786 Result += ",\n";
6789 Result += "\t0,\n";
6791 Result += "};\n";
6794 Result += "static void OBJC_CATEGORY_SETUP_$_";
6795 Result += ClassDecl->getNameAsString();
6796 Result += "_$_";
6797 Result += CatName;
6798 Result += "(void ) {\n";
6799 Result += "\t_OBJC_$_CATEGORY_";
6800 Result += ClassDecl->getNameAsString();
6801 Result += "_$_";
6802 Result += CatName;
6803 Result += ".cls = "; Result += "&OBJC_CLASS_$_"; Result += ClassName;
6804 Result += ";\n}\n";
6808 ASTContext *Context, std::string &Result,
6815 Result += "\nstatic const char *";
6816 Result += VarName; Result += ProtocolName;
6817 Result += " [] __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
6818 Result += "{\n";
6824 Result += "\t\""; Result += QuoteMethodTypeString; Result += "\"";
6826 Result += "\n};\n";
6828 Result += ",\n";
6835 std::string &Result,
6849 Result += "\n";
6853 Result += "__declspec(allocate(\".objc_ivar$B\")) ";
6858 Result += "extern \"C\" unsigned long int ";
6860 Result += "extern \"C\" __declspec(dllexport) unsigned long int ";
6862 RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
6864 WriteInternalIvarName(CDecl, IvarDecl, Result);
6865 Result += " __attribute__ ((used, section (\"__DATA,__objc_ivar\")))";
6866 Result += " = ";
6867 RewriteObj.RewriteIvarOffsetComputation(IvarDecl, Result);
6868 Result += ";\n";
6877 ASTContext *Context, std::string &Result,
6882 Write_IvarOffsetVar(RewriteObj, Context, Result, OriginalIvars, CDecl);
6897 Result += "\nstatic ";
6898 Write__ivar_list_t_TypeDecl(Result, Ivars.size());
6899 Result += " "; Result += VarName;
6900 Result += CDecl->getNameAsString();
6901 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6902 Result += "\t"; Result += "sizeof(_ivar_t)"; Result += ",\n";
6903 Result += "\t"; Result += utostr(Ivars.size()); Result += ",\n";
6907 Result += "\t{{";
6909 Result += "\t {";
6910 Result += "(unsigned long int *)&";
6912 RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
6914 WriteInternalIvarName(CDecl, IvarDecl, Result);
6915 Result += ", ";
6917 Result += "\"";
6919 RewriteObj.ObjCIvarBitfieldGroupDecl(Ivars[i], Result);
6921 Result += IvarDecl->getName();
6922 Result += "\", ";
6932 Result += "\""; Result += QuoteIvarTypeString; Result += "\", ";
6938 Result += llvm::utostr(Align); Result += ", ";
6940 Result += llvm::utostr(Size.getQuantity());
6942 Result += "}}\n";
6944 Result += "},\n";
6946 Result += "};\n";
6952 std::string &Result) {
6957 WriteModernMetadataDeclarations(Context, Result);
6964 RewriteObjCProtocolMetaData(I, Result);
6994 Write__extendedMethodTypes_initializer(*this, Context, Result,
7000 Write_protocol_list_initializer(Context, Result, SuperProtocols,
7004 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7008 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7012 Write_method_list_t_initializer(*this, Context, Result, OptInstanceMethods,
7016 Write_method_list_t_initializer(*this, Context, Result, OptClassMethods,
7022 Write_prop_list_t_initializer(*this, Context, Result, ProtocolProperties,
7028 Result += "\n";
7030 Result += "static ";
7031 Result += "struct _protocol_t _OBJC_PROTOCOL_";
7032 Result += PDecl->getNameAsString();
7033 Result += " __attribute__ ((used, section (\"__DATA,__datacoal_nt,coalesced\"))) = {\n";
7034 Result += "\t0,\n"; // id is; is null
7035 Result += "\t\""; Result += PDecl->getNameAsString(); Result += "\",\n";
7037 Result += "\t(const struct _protocol_list_t *)&"; Result += "_OBJC_PROTOCOL_REFS_";
7038 Result += PDecl->getNameAsString(); Result += ",\n";
7041 Result += "\t0,\n";
7043 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_INSTANCE_METHODS_";
7044 Result += PDecl->getNameAsString(); Result += ",\n";
7047 Result += "\t0,\n";
7050 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_CLASS_METHODS_";
7051 Result += PDecl->getNameAsString(); Result += ",\n";
7054 Result += "\t0,\n";
7057 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_INSTANCE_METHODS_";
7058 Result += PDecl->getNameAsString(); Result += ",\n";
7061 Result += "\t0,\n";
7064 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_CLASS_METHODS_";
7065 Result += PDecl->getNameAsString(); Result += ",\n";
7068 Result += "\t0,\n";
7071 Result += "\t(const struct _prop_list_t *)&_OBJC_PROTOCOL_PROPERTIES_";
7072 Result += PDecl->getNameAsString(); Result += ",\n";
7075 Result += "\t0,\n";
7077 Result += "\t"; Result += "sizeof(_protocol_t)"; Result += ",\n";
7078 Result += "\t0,\n";
7081 Result += "\t(const char **)&"; Result += "_OBJC_PROTOCOL_METHOD_TYPES_";
7082 Result += PDecl->getNameAsString();
7083 Result += "\n};\n";
7086 Result += "\t0\n};\n";
7089 Result += "static ";
7090 Result += "struct _protocol_t *";
7091 Result += "_OBJC_LABEL_PROTOCOL_$_"; Result += PDecl->getNameAsString();
7092 Result += " = &_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
7093 Result += ";\n";
7104 std::string &Result) {
7108 RewriteObjCProtocolMetaData(Protocols[i], Result);
7117 Result += "\n";
7119 Result += "__declspec(allocate(\".cat_cls_meth$B\")) ";
7120 Result += "static struct {\n";
7121 Result += "\tstruct _objc_protocol_list *next;\n";
7122 Result += "\tint protocol_count;\n";
7123 Result += "\tstruct _objc_protocol *class_protocols[";
7124 Result += utostr(Protocols.size());
7125 Result += "];\n} _OBJC_";
7126 Result += prefix;
7127 Result += "_PROTOCOLS_";
7128 Result += ClassName;
7129 Result += " __attribute__ ((used, section (\"__OBJC, __cat_cls_meth\")))= "
7131 Result += utostr(Protocols.size());
7132 Result += "\n";
7134 Result += "\t,{&_OBJC_PROTOCOL_";
7135 Result += Protocols[0]->getNameAsString();
7136 Result += " \n";
7139 Result += "\t ,&_OBJC_PROTOCOL_";
7140 Result += Protocols[i]->getNameAsString();
7141 Result += "\n";
7143 Result += "\t }\n};\n";
7159 std::string &Result) {
7167 WriteModernMetadataDeclarations(Context, Result);
7178 Write__ivar_list_t_initializer(*this, Context, Result, IVars,
7205 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7211 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7225 RewriteObjCProtocolMetaData(*I, Result);
7228 Write_protocol_list_initializer(Context, Result,
7235 Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
7256 Write__class_ro_t_initializer(Context, Result, flags,
7295 Write__class_ro_t_initializer(Context, Result, flags,
7304 Write_class_t(Context, Result,
7308 Write_class_t(Context, Result,
7317 void RewriteModernObjC::RewriteClassSetupInitHook(std::string &Result) {
7321 Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
7322 Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
7323 Result += "static void *OBJC_CLASS_SETUP[] = {\n";
7327 Result += "\t(void *)&OBJC_CLASS_SETUP_$_";
7328 Result += CDecl->getName(); Result += ",\n";
7330 Result += "};\n";
7333 void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) {
7339 RewriteObjCClassMetaData(ClassImplementation[i], Result);
7341 RewriteClassSetupInitHook(Result);
7345 RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
7347 RewriteCategorySetupInitHook(Result);
7351 Result += "__declspec(allocate(\".objc_classlist$B\")) ";
7352 Result += "static struct _class_t *L_OBJC_LABEL_CLASS_$ [";
7353 Result += llvm::utostr(ClsDefCount); Result += "]";
7354 Result +=
7358 Result += "\t&OBJC_CLASS_$_";
7359 Result += ClassImplementation[i]->getNameAsString();
7360 Result += ",\n";
7362 Result += "};\n";
7366 Result += "__declspec(allocate(\".objc_nlclslist$B\")) \n";
7367 Result += "static struct _class_t *_OBJC_LABEL_NONLAZY_CLASS_$[] = {\n\t";
7369 Result += "\t&OBJC_CLASS_$_"; Result += DefinedNonLazyClasses[i]->getNameAsString();
7370 Result += ",\n";
7372 Result += "};\n";
7378 Result += "__declspec(allocate(\".objc_catlist$B\")) ";
7379 Result += "static struct _category_t *L_OBJC_LABEL_CATEGORY_$ [";
7380 Result += llvm::utostr(CatDefCount); Result += "]";
7381 Result +=
7385 Result += "\t&_OBJC_$_CATEGORY_";
7386 Result +=
7388 Result += "_$_";
7389 Result += CategoryImplementation[i]->getNameAsString();
7390 Result += ",\n";
7392 Result += "};\n";
7397 Result += "__declspec(allocate(\".objc_nlcatlist$B\")) \n";
7398 Result += "static struct _category_t *_OBJC_LABEL_NONLAZY_CATEGORY_$[] = {\n\t";
7400 Result += "\t&_OBJC_$_CATEGORY_";
7401 Result +=
7403 Result += "_$_";
7404 Result += DefinedNonLazyCategories[i]->getNameAsString();
7405 Result += ",\n";
7407 Result += "};\n";
7411 void RewriteModernObjC::WriteImageInfo(std::string &Result) {
7413 Result += "__declspec(allocate(\".objc_imageinfo$B\")) \n";
7415 Result += "static struct IMAGE_INFO { unsigned version; unsigned flag; } ";
7417 Result += "_OBJC_IMAGE_INFO = { 0, 2 };\n";
7423 std::string &Result) {
7424 WriteModernMetadataDeclarations(Context, Result);
7455 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7461 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7471 RewriteObjCProtocolMetaData(I, Result);
7473 Write_protocol_list_initializer(Context, Result,
7480 Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
7485 Write_category_t(*this, Context, Result,
7499 void RewriteModernObjC::RewriteCategorySetupInitHook(std::string &Result) {
7503 Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
7504 Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
7505 Result += "static void *OBJC_CATEGORY_SETUP[] = {\n";
7510 Result += "\t(void *)&OBJC_CATEGORY_SETUP_$_";
7511 Result += ClassDecl->getName();
7512 Result += "_$_";
7513 Result += CatDecl->getName();
7514 Result += ",\n";
7516 Result += "};\n";
7527 std::string &Result) {
7537 Result += "\nstruct _objc_method {\n";
7538 Result += "\tSEL _cmd;\n";
7539 Result += "\tchar *method_types;\n";
7540 Result += "\tvoid *_imp;\n";
7541 Result += "};\n";
7555 Result += "\n";
7558 Result += "__declspec(allocate(\".inst_meth$B\")) ";
7560 Result += "__declspec(allocate(\".cls_meth$B\")) ";
7562 Result += "static struct {\n";
7563 Result += "\tstruct _objc_method_list *next_method;\n";
7564 Result += "\tint method_count;\n";
7565 Result += "\tstruct _objc_method method_list[";
7566 Result += utostr(NumMethods);
7567 Result += "];\n} _OBJC_";
7568 Result += prefix;
7569 Result += IsInstanceMethod ? "INSTANCE" : "CLASS";
7570 Result += "_METHODS_";
7571 Result += ClassName;
7572 Result += " __attribute__ ((used, section (\"__OBJC, __";
7573 Result += IsInstanceMethod ? "inst" : "cls";
7574 Result += "_meth\")))= ";
7575 Result += "{\n\t0, " + utostr(NumMethods) + "\n";
7577 Result += "\t,{{(SEL)\"";
7578 Result += (*MethodBegin)->getSelector().getAsString().c_str();
7581 Result += "\", \"";
7582 Result += MethodTypeString;
7583 Result += "\", (void *)";
7584 Result += MethodInternalNames[*MethodBegin];
7585 Result += "}\n";
7587 Result += "\t ,{(SEL)\"";
7588 Result += (*MethodBegin)->getSelector().getAsString().c_str();
7591 Result += "\", \"";
7592 Result += MethodTypeString;
7593 Result += "\", (void *)";
7594 Result += MethodInternalNames[*MethodBegin];
7595 Result += "}\n";
7597 Result += "\t }\n};\n";