Home | History | Annotate | Download | only in Rewrite

Lines Matching refs:Result

373     void ObjCIvarBitfieldGroupDecl(ObjCIvarDecl *IV, std::string &Result);
375 void ObjCIvarBitfieldGroupType(ObjCIvarDecl *IV, std::string &Result);
377 void ObjCIvarBitfieldGroupOffset(ObjCIvarDecl *IV, std::string &Result);
395 std::string &Result);
397 void RewriteObjCFieldDecl(FieldDecl *fieldDecl, std::string &Result);
401 Result);
403 bool RewriteObjCFieldDeclType(QualType &Type, std::string &Result);
406 std::string &Result);
446 std::string &Result);
448 std::string &Result);
450 std::string &Result);
451 void RewriteClassSetupInitHook(std::string &Result);
453 void RewriteMetaDataIntoBuffer(std::string &Result);
454 void WriteImageInfo(std::string &Result);
456 std::string &Result);
457 void RewriteCategorySetupInitHook(std::string &Result);
461 std::string &Result);
574 QualType getSimpleFunctionType(QualType result,
577 if (result == Context->getObjCInstanceType())
578 result = Context->getObjCIdType();
581 return Context->getFunctionType(result, args, fpi);
828 ObjCIvarDecl *IvarDecl, std::string &Result) {
829 Result += "OBJC_IVAR_$_";
830 Result += IDecl->getName();
831 Result += "$";
832 Result += IvarDecl->getName();
1965 std::string Result;
1966 ConvertSourceLocationToLineDirective(Catch->getLocStart(), Result);
1974 Result += "catch (_objc_exc_"; Result += IDecl->getNameAsString();
1975 Result += " *_"; Result += catchDecl->getNameAsString();
1976 Result += ")";
1977 ReplaceText(startLoc, rParenBuf-startBuf+1, Result);
1979 Result.clear();
1980 Result = "{ ";
1981 Result += IDecl->getNameAsString();
1982 Result += " *"; Result += catchDecl->getNameAsString();
1983 Result += " = ("; Result += IDecl->getNameAsString(); Result += "*)";
1984 Result += "_"; Result += catchDecl->getNameAsString();
1986 Result += "; ";
1988 ReplaceText(lBraceLoc, 1, Result);
3088 /// returnType - Result type of the method being synthesized.
3638 std::string &Result) {
3640 Result += "\t";
3646 return RewriteObjCFieldDeclType(ElemTy, Result);
3652 Result += "\n\tstruct ";
3654 Result += "\n\tunion ";
3658 Result += RD->getName();
3661 Result += " ";
3664 Result += " {\n";
3666 RewriteObjCFieldDecl(FD, Result);
3667 Result += "\t} ";
3674 Result += "\n\tenum ";
3675 Result += ED->getName();
3678 Result += " ";
3682 Result += " {\n";
3684 Result += "\t"; Result += EC->getName(); Result += " = ";
3686 Result += Val.toString(10);
3687 Result += ",\n";
3689 Result += "\t} ";
3694 Result += "\t";
3703 std::string &Result) {
3707 bool EleboratedType = RewriteObjCFieldDeclType(Type, Result);
3710 Result += Name;
3712 Result += " : "; Result += utostr(fieldDecl->getBitWidthValue(*Context));
3718 Result += "[";
3720 Result += utostr(Dim.getZExtValue());
3721 Result += "]";
3727 Result += ";\n";
3733 std::string &Result) {
3756 RewriteObjCFieldDeclType(Type, Result);
3757 Result += ";";
3846 std::string &Result) {
3848 Result += CDecl->getName();
3849 Result += "__GRBF_";
3851 Result += utostr(GroupNo);
3858 std::string &Result) {
3860 Result += CDecl->getName();
3861 Result += "__T_";
3863 Result += utostr(GroupNo);
3870 std::string &Result) {
3871 Result += "OBJC_IVAR_$_";
3872 ObjCIvarBitfieldGroupDecl(IV, Result);
3885 std::string &Result) {
3906 ReplaceText(LocStart, endBuf-startBuf, Result);
3914 RewriteLocallyDefinedNamedAggregates(IVars[i], Result);
3922 RewriteObjCFieldDeclType(QT, Result);
3923 Result += ";";
3928 Result += "\nstruct ";
3929 Result += CDecl->getNameAsString();
3930 Result += "_IMPL {\n";
3933 Result += "\tstruct "; Result += RCDecl->getNameAsString();
3934 Result += "_IMPL "; Result += RCDecl->getNameAsString();
3935 Result += "_IVARS;\n";
3941 Result += "\tstruct ";
3942 ObjCIvarBitfieldGroupType(IV, Result); Result += " ";
3943 ObjCIvarBitfieldGroupDecl(IV, Result); Result += ";\n";
3948 RewriteObjCFieldDecl(IVars[i], Result);
3951 Result += "};\n";
3953 ReplaceText(LocStart, endBuf-startBuf, Result);
3962 std::string &Result) {
3978 Result += "\n";
3980 Result += "__declspec(allocate(\".objc_ivar$B\")) ";
3981 Result += "extern \"C\" ";
3985 Result += "__declspec(dllimport) ";
3987 Result += "unsigned long ";
3989 ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
3993 WriteInternalIvarName(CDecl, IvarDecl, Result);
3994 Result += ";";
4399 // removed as result of rewriting of block literals.
4532 /// whose result type may be a block pointer or whose argument type(s)
5824 std::string &Result) {
5827 Result += "static ";
5828 Result += "struct _protocol_t *";
5829 Result += "_OBJC_PROTOCOL_REFERENCE_$_";
5830 Result += PDecl->getNameAsString();
5831 Result += " = &";
5832 Result += "_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
5833 Result += ";\n";
6073 std::string &Result) {
6074 Result += "__OFFSETOFIVAR__(struct ";
6075 Result += ivar->getContainingInterface()->getNameAsString();
6077 Result += "_IMPL";
6078 Result += ", ";
6080 ObjCIvarBitfieldGroupDecl(ivar, Result);
6082 Result += ivar->getNameAsString();
6083 Result += ")";
6188 static void WriteModernMetadataDeclarations(ASTContext *Context, std::string &Result) {
6193 Result += "\nstruct _prop_t {\n";
6194 Result += "\tconst char *name;\n";
6195 Result += "\tconst char *attributes;\n";
6196 Result += "};\n";
6198 Result += "\nstruct _protocol_t;\n";
6200 Result += "\nstruct _objc_method {\n";
6201 Result += "\tstruct objc_selector * _cmd;\n";
6202 Result += "\tconst char *method_type;\n";
6203 Result += "\tvoid *_imp;\n";
6204 Result += "};\n";
6206 Result += "\nstruct _protocol_t {\n";
6207 Result += "\tvoid * isa; // NULL\n";
6208 Result += "\tconst char *protocol_name;\n";
6209 Result += "\tconst struct _protocol_list_t * protocol_list; // super protocols\n";
6210 Result += "\tconst struct method_list_t *instance_methods;\n";
6211 Result += "\tconst struct method_list_t *class_methods;\n";
6212 Result += "\tconst struct method_list_t *optionalInstanceMethods;\n";
6213 Result += "\tconst struct method_list_t *optionalClassMethods;\n";
6214 Result += "\tconst struct _prop_list_t * properties;\n";
6215 Result += "\tconst unsigned int size; // sizeof(struct _protocol_t)\n";
6216 Result += "\tconst unsigned int flags; // = 0\n";
6217 Result += "\tconst char ** extendedMethodTypes;\n";
6218 Result += "};\n";
6220 Result += "\nstruct _ivar_t {\n";
6221 Result += "\tunsigned long int *offset; // pointer to ivar offset location\n";
6222 Result += "\tconst char *name;\n";
6223 Result += "\tconst char *type;\n";
6224 Result += "\tunsigned int alignment;\n";
6225 Result += "\tunsigned int size;\n";
6226 Result += "};\n";
6228 Result += "\nstruct _class_ro_t {\n";
6229 Result += "\tunsigned int flags;\n";
6230 Result += "\tunsigned int instanceStart;\n";
6231 Result += "\tunsigned int instanceSize;\n";
6234 Result += "\tunsigned int reserved;\n";
6235 Result += "\tconst unsigned char *ivarLayout;\n";
6236 Result += "\tconst char *name;\n";
6237 Result += "\tconst struct _method_list_t *baseMethods;\n";
6238 Result += "\tconst struct _objc_protocol_list *baseProtocols;\n";
6239 Result += "\tconst struct _ivar_list_t *ivars;\n";
6240 Result
6241 Result += "\tconst struct _prop_list_t *properties;\n";
6242 Result += "};\n";
6244 Result += "\nstruct _class_t {\n";
6245 Result += "\tstruct _class_t *isa;\n";
6246 Result += "\tstruct _class_t *superclass;\n";
6247 Result += "\tvoid *cache;\n";
6248 Result += "\tvoid *vtable;\n";
6249 Result += "\tstruct _class_ro_t *ro;\n";
6250 Result += "};\n";
6252 Result += "\nstruct _category_t {\n";
6253 Result += "\tconst char *name;\n";
6254 Result += "\tstruct _class_t *cls;\n";
6255 Result += "\tconst struct _method_list_t *instance_methods;\n";
6256 Result += "\tconst struct _method_list_t *class_methods;\n";
6257 Result += "\tconst struct _protocol_list_t *protocols;\n";
6258 Result += "\tconst struct _prop_list_t *properties;\n";
6259 Result += "};\n";
6261 Result += "extern \"C\" __declspec(dllimport) struct objc_cache _objc_empty_cache;\n";
6262 Result += "#pragma warning(disable:4273)\n";
6266 static void Write_protocol_list_t_TypeDecl(std::string &Result,
6268 Result += "struct /*_protocol_list_t*/"; Result += " {\n";
6269 Result += "\tlong protocol_count; // Note, this is 32/64 bit\n";
6270 Result += "\tstruct _protocol_t *super_protocols[";
6271 Result += utostr(super_protocol_count); Result += "];\n";
6272 Result += "}";
6275 static void Write_method_list_t_TypeDecl(std::string &Result,
6277 Result += "struct /*_method_list_t*/"; Result += " {\n";
6278 Result += "\tunsigned int entsize; // sizeof(struct _objc_method)\n";
6279 Result += "\tunsigned int method_count;\n";
6280 Result += "\tstruct _objc_method method_list[";
6281 Result += utostr(method_count); Result += "];\n";
6282 Result += "}";
6285 static void Write__prop_list_t_TypeDecl(std::string &Result,
6287 Result += "struct /*_prop_list_t*/"; Result += " {\n";
6288 Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
6289 Result += "\tunsigned int count_of_properties;\n";
6290 Result += "\tstruct _prop_t prop_list[";
6291 Result += utostr(property_count); Result += "];\n";
6292 Result += "}";
6295 static void Write__ivar_list_t_TypeDecl(std::string &Result,
6297 Result += "struct /*_ivar_list_t*/"; Result += " {\n";
6298 Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
6299 Result += "\tunsigned int count;\n";
6300 Result += "\tstruct _ivar_t ivar_list[";
6301 Result += utostr(ivar_count); Result += "];\n";
6302 Result += "}";
6305 static void Write_protocol_list_initializer(ASTContext *Context, std::string &Result,
6310 Result += "\nstatic ";
6311 Write_protocol_list_t_TypeDecl(Result, SuperProtocols.size());
6312 Result += " "; Result += VarName;
6313 Result += ProtocolName;
6314 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6315 Result += "\t"; Result += utostr(SuperProtocols.size()); Result += ",\n";
6318 Result += "\t&"; Result += "_OBJC_PROTOCOL_";
6319 Result += SuperPD->getNameAsString();
6321 Result += "\n};\n";
6323 Result += ",\n";
6329 ASTContext *Context, std::string &Result,
6335 Result += "\nstatic ";
6336 Write_method_list_t_TypeDecl(Result, Methods.size());
6337 Result += " "; Result += VarName;
6338 Result += TopLevelDeclName;
6339 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6340 Result += "\t"; Result += "sizeof(_objc_method)"; Result += ",\n";
6341 Result += "\t"; Result += utostr(Methods.size()); Result += ",\n";
6345 Result += "\t{{(struct objc_selector *)\"";
6347 Result += "\t{(struct objc_selector *)\"";
6348 Result += (MD)->getSelector().getAsString(); Result += "\"";
6349 Result += ", ";
6352 Result += "\""; Result += MethodTypeString; Result += "\"";
6353 Result += ", ";
6355 Result += "0";
6357 Result += "(void *)";
6358 Result += RewriteObj.MethodInternalNames[MD];
6361 Result += "}}\n";
6363 Result += "},\n";
6365 Result += "};\n";
6370 ASTContext *Context, std::string &Result,
6376 Result += "\nstatic ";
6377 Write__prop_list_t_TypeDecl(Result, Properties.size());
6378 Result += " "; Result += VarName;
6379 Result += ProtocolName;
6380 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6381 Result += "\t"; Result += "sizeof(_prop_t)"; Result += ",\n";
6382 Result += "\t"; Result += utostr(Properties.size()); Result += ",\n";
6386 Result += "\t{{\"";
6388 Result += "\t{\"";
6389 Result += PropDecl->getName(); Result += "\",";
6393 Result += "\""; Result += QuotePropertyTypeString; Result += "\"";
6395 Result += "}}\n";
6397 Result += "},\n";
6399 Result += "};\n";
6417 static void Write__class_ro_t_initializer(ASTContext *Context, std::string &Result,
6427 Result += "\nstatic struct _class_ro_t ";
6428 Result += VarName; Result += ClassName;
6429 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6430 Result += "\t";
6431 Result += llvm::utostr(flags); Result += ", ";
6432 Result += InstanceStart; Result += ", ";
6433 Result += InstanceSize; Result += ", \n";
6434 Result += "\t";
6438 Result += "(unsigned int)0, \n\t";
6440 Result += "0, \n\t";
6441 Result += "\""; Result += ClassName; Result += "\",\n\t";
6444 Result += "(const struct _method_list_t *)&";
6446 Result += "_OBJC_$_CLASS_METHODS_";
6448 Result += "_OBJC_$_INSTANCE_METHODS_";
6449 Result += ClassName;
6450 Result += ",\n\t";
6453 Result += "0, \n\t";
6456 Result += "(const struct _objc_protocol_list *)&";
6457 Result += "_OBJC_CLASS_PROTOCOLS_$_"; Result += ClassName;
6458 Result += ",\n\t";
6461 Result += "0, \n\t";
6464 Result += "(const struct _ivar_list_t *)&";
6465 Result += "_OBJC_$_INSTANCE_VARIABLES_"; Result += ClassName;
6466 Result += ",\n\t";
6469 Result += "0, \n\t";
6472 Result += "0, \n\t";
6474 Result += "(const struct _prop_list_t *)&";
6475 Result += "_OBJC_$_PROP_LIST_"; Result += ClassName;
6476 Result += ",\n";
6479 Result += "0, \n";
6481 Result += "};\n";
6484 static void Write_class_t(ASTContext *Context, std::string &Result,
6500 Result += "\n";
6501 Result += "extern \"C\" ";
6503 Result += "__declspec(dllexport) ";
6505 Result += "__declspec(dllimport) ";
6507 Result += "struct _class_t OBJC_CLASS_$_";
6508 Result += CDecl->getNameAsString();
6509 Result += ";\n";
6514 Result += "\n";
6515 Result += "extern \"C\" ";
6517 Result += "__declspec(dllexport) ";
6519 Result += "__declspec(dllimport) ";
6521 Result += "struct _class_t ";
6522 Result += VarName;
6523 Result += SuperClass->getNameAsString();
6524 Result += ";\n";
6527 Result += "extern \"C\" ";
6529 Result += "__declspec(dllexport) ";
6531 Result += "__declspec(dllimport) ";
6533 Result += "struct _class_t ";
6534 Result += VarName;
6535 Result += RootClass->getNameAsString();
6536 Result += ";\n";
6540 Result += "\nextern \"C\" __declspec(dllexport) struct _class_t ";
6541 Result += VarName; Result += CDecl->getNameAsString();
6542 Result += " __attribute__ ((used, section (\"__DATA,__objc_data\"))) = {\n";
6543 Result += "\t";
6546 Result += "0, // &"; Result += VarName;
6547 Result += RootClass->getNameAsString();
6548 Result += ",\n\t";
6549 Result += "0, // &"; Result += VarName;
6550 Result += CDecl->getSuperClass()->getNameAsString();
6551 Result += ",\n\t";
6554 Result += "0, // &"; Result += VarName;
6555 Result += CDecl->getNameAsString();
6556 Result += ",\n\t";
6557 Result += "0, // &OBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6558 Result += ",\n\t";
6562 Result += "0, // &OBJC_METACLASS_$_";
6563 Result += CDecl->getNameAsString();
6564 Result += ",\n\t";
6566 Result += "0, // &"; Result += VarName;
6567 Result += CDecl->getSuperClass()->getNameAsString();
6568 Result += ",\n\t";
6571 Result += "0,\n\t";
6573 Result += "0, // (void *)&_objc_empty_cache,\n\t";
6574 Result += "0, // unused, was (void *)&_objc_empty_vtable,\n\t";
6576 Result += "&_OBJC_METACLASS_RO_$_";
6578 Result += "&_OBJC_CLASS_RO_$_";
6579 Result += CDecl->getNameAsString();
6580 Result += ",\n};\n";
6590 Result += "static void OBJC_CLASS_SETUP_$_";
6591 Result += CDecl->getNameAsString();
6592 Result += "(void ) {\n";
6593 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6594 Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
6595 Result += RootClass->getNameAsString(); Result += ";\n";
6597 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6598 Result += ".superclass = ";
6600 Result += "&OBJC_CLASS_$_";
6602 Result += "&OBJC_METACLASS_$_";
6604 Result += SuperClass->getNameAsString(); Result += ";\n";
6606 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6607 Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
6609 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6610 Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
6611 Result += CDecl->getNameAsString(); Result += ";\n";
6614 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6615 Result += ".superclass = "; Result += "&OBJC_CLASS_$_";
6616 Result += SuperClass->getNameAsString(); Result += ";\n";
6619 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6620 Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
6621 Result += "}\n";
6625 std::string &Result,
6636 Result += "\n";
6637 Result += "extern \"C\" ";
6639 Result += "__declspec(dllexport) ";
6641 Result += "__declspec(dllimport) ";
6643 Result += "struct _class_t ";
6644 Result += "OBJC_CLASS_$_"; Result += ClassName;
6645 Result += ";\n";
6647 Result += "\nstatic struct _category_t ";
6648 Result += "_OBJC_$_CATEGORY_";
6649 Result += ClassName; Result += "_$_"; Result += CatName;
6650 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
6651 Result += "{\n";
6652 Result += "\t\""; Result += ClassName; Result += "\",\n";
6653 Result += "\t0, // &"; Result += "OBJC_CLASS_$_"; Result += ClassName;
6654 Result += ",\n";
6656 Result += "\t(const struct _method_list_t *)&";
6657 Result += "_OBJC_$_CATEGORY_INSTANCE_METHODS_";
6658 Result += ClassName; Result += "_$_"; Result += CatName;
6659 Result += ",\n";
6662 Result += "\t0,\n";
6665 Result += "\t(const struct _method_list_t *)&";
6666 Result += "_OBJC_$_CATEGORY_CLASS_METHODS_";
6667 Result += ClassName; Result += "_$_"; Result += CatName;
6668 Result += ",\n";
6671 Result += "\t0,\n";
6674 Result += "\t(const struct _protocol_list_t *)&";
6675 Result += "_OBJC_CATEGORY_PROTOCOLS_$_";
6676 Result += ClassName; Result += "_$_"; Result += CatName;
6677 Result += ",\n";
6680 Result += "\t0,\n";
6683 Result += "\t(const struct _prop_list_t *)&"; Result += "_OBJC_$_PROP_LIST_";
6684 Result += ClassName; ResultResult += CatName;
6685 Result += ",\n";
6688 Result += "\t0,\n";
6690 Result += "};\n";
6693 Result += "static void OBJC_CATEGORY_SETUP_$_";
6694 Result += ClassDecl->getNameAsString();
6695 Result += "_$_";
6696 Result += CatName;
6697 Result += "(void ) {\n";
6698 Result += "\t_OBJC_$_CATEGORY_";
6699 Result += ClassDecl->getNameAsString();
6700 Result += "_$_";
6701 Result += CatName;
6702 Result += ".cls = "; Result += "&OBJC_CLASS_$_"; Result += ClassName;
6703 Result += ";\n}\n";
6707 ASTContext *Context, std::string &Result,
6714 Result += "\nstatic const char *";
6715 Result += VarName; Result += ProtocolName;
6716 Result += " [] __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
6717 Result += "{\n";
6723 Result += "\t\""; Result += QuoteMethodTypeString; Result += "\"";
6725 Result += "\n};\n";
6727 Result += ",\n";
6734 std::string &Result,
6748 Result += "\n";
6752 Result += "__declspec(allocate(\".objc_ivar$B\")) ";
6757 Result += "extern \"C\" unsigned long int ";
6759 Result += "extern \"C\" __declspec(dllexport) unsigned long int ";
6761 RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
6763 WriteInternalIvarName(CDecl, IvarDecl, Result);
6764 Result += " __attribute__ ((used, section (\"__DATA,__objc_ivar\")))";
6765 Result += " = ";
6766 RewriteObj.RewriteIvarOffsetComputation(IvarDecl, Result);
6767 Result += ";\n";
6776 ASTContext *Context, std::string &Result,
6781 Write_IvarOffsetVar(RewriteObj, Context, Result, OriginalIvars, CDecl);
6796 Result += "\nstatic ";
6797 Write__ivar_list_t_TypeDecl(Result, Ivars.size());
6798 Result += " "; Result += VarName;
6799 Result += CDecl->getNameAsString();
6800 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6801 Result += "\t"; Result += "sizeof(_ivar_t)"; Result += ",\n";
6802 Result += "\t"; Result += utostr(Ivars.size()); Result += ",\n";
6806 Result += "\t{{";
6808 Result += "\t {";
6809 Result += "(unsigned long int *)&";
6811 RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
6813 WriteInternalIvarName(CDecl, IvarDecl, Result);
6814 Result += ", ";
6816 Result += "\"";
6818 RewriteObj.ObjCIvarBitfieldGroupDecl(Ivars[i], Result);
6820 Result += IvarDecl->getName();
6821 Result += "\", ";
6831 Result += "\""; Result += QuoteIvarTypeString; Result += "\", ";
6837 Result += llvm::utostr(Align); Result += ", ";
6839 Result += llvm::utostr(Size.getQuantity());
6841 Result += "}}\n";
6843 Result += "},\n";
6845 Result += "};\n";
6851 std::string &Result) {
6856 WriteModernMetadataDeclarations(Context, Result);
6863 RewriteObjCProtocolMetaData(I, Result);
6893 Write__extendedMethodTypes_initializer(*this, Context, Result,
6899 Write_protocol_list_initializer(Context, Result, SuperProtocols,
6903 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
6907 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
6911 Write_method_list_t_initializer(*this, Context, Result, OptInstanceMethods,
6915 Write_method_list_t_initializer(*this, Context, Result, OptClassMethods,
6922 Write_prop_list_t_initializer(*this, Context, Result, ProtocolProperties,
6928 Result += "\n";
6930 Result += "static ";
6931 Result += "struct _protocol_t _OBJC_PROTOCOL_";
6932 Result += PDecl->getNameAsString();
6933 Result += " __attribute__ ((used)) = {\n";
6934 Result += "\t0,\n"; // id is; is null
6935 Result += "\t\""; Result += PDecl->getNameAsString(); Result += "\",\n";
6937 Result += "\t(const struct _protocol_list_t *)&"; Result += "_OBJC_PROTOCOL_REFS_";
6938 Result += PDecl->getNameAsString(); Result += ",\n";
6941 Result += "\t0,\n";
6943 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_INSTANCE_METHODS_";
6944 Result += PDecl->getNameAsString(); Result += ",\n";
6947 Result += "\t0,\n";
6950 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_CLASS_METHODS_";
6951 Result += PDecl->getNameAsString(); Result += ",\n";
6954 Result += "\t0,\n";
6957 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_INSTANCE_METHODS_";
6958 Result += PDecl->getNameAsString(); Result += ",\n";
6961 Result += "\t0,\n";
6964 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_CLASS_METHODS_";
6965 Result += PDecl->getNameAsString(); Result += ",\n";
6968 Result += "\t0,\n";
6971 Result += "\t(const struct _prop_list_t *)&_OBJC_PROTOCOL_PROPERTIES_";
6972 Result += PDecl->getNameAsString(); Result += ",\n";
6975 Result += "\t0,\n";
6977 Result += "\t"; Result += "sizeof(_protocol_t)"; Result += ",\n";
6978 Result += "\t0,\n";
6981 Result += "\t(const char **)&"; Result += "_OBJC_PROTOCOL_METHOD_TYPES_";
6982 Result += PDecl->getNameAsString();
6983 Result += "\n};\n";
6986 Result += "\t0\n};\n";
6989 Result += "static ";
6990 Result += "struct _protocol_t *";
6991 Result += "_OBJC_LABEL_PROTOCOL_$_"; Result += PDecl->getNameAsString();
6992 Result += " = &_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
6993 Result += ";\n";
7013 std::string &Result) {
7021 WriteModernMetadataDeclarations(Context, Result);
7032 Write__ivar_list_t_initializer(*this, Context, Result, IVars,
7059 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7065 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7079 RewriteObjCProtocolMetaData(*I, Result);
7082 Write_protocol_list_initializer(Context, Result,
7090 Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
7109 Write__class_ro_t_initializer(Context, Result, flags,
7148 Write__class_ro_t_initializer(Context, Result, flags,
7157 Write_class_t(Context, Result,
7161 Write_class_t(Context, Result,
7169 void RewriteModernObjC::RewriteClassSetupInitHook(std::string &Result) {
7173 Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
7174 Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
7175 Result += "static void *OBJC_CLASS_SETUP[] = {\n";
7179 Result += "\t(void *)&OBJC_CLASS_SETUP_$_";
7180 Result += CDecl->getName(); Result += ",\n";
7182 Result += "};\n";
7185 void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) {
7191 RewriteObjCClassMetaData(ClassImplementation[i], Result);
7193 RewriteClassSetupInitHook(Result);
7197 RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
7199 RewriteCategorySetupInitHook(Result);
7203 Result += "__declspec(allocate(\".objc_classlist$B\")) ";
7204 Result += "static struct _class_t *L_OBJC_LABEL_CLASS_$ [";
7205 Result += llvm::utostr(ClsDefCount); Result += "]";
7206 Result +=
7210 Result += "\t&OBJC_CLASS_$_";
7211 Result += ClassImplementation[i]->getNameAsString();
7212 Result += ",\n";
7214 Result += "};\n";
7218 Result += "__declspec(allocate(\".objc_nlclslist$B\")) \n";
7219 Result += "static struct _class_t *_OBJC_LABEL_NONLAZY_CLASS_$[] = {\n\t";
7221 Result += "\t&OBJC_CLASS_$_"; Result += DefinedNonLazyClasses[i]->getNameAsString();
7222 Result += ",\n";
7224 Result += "};\n";
7230 Result += "__declspec(allocate(\".objc_catlist$B\")) ";
7231 Result += "static struct _category_t *L_OBJC_LABEL_CATEGORY_$ [";
7232 Result += llvm::utostr(CatDefCount); Result += "]";
7233 Result +=
7237 Result += "\t&_OBJC_$_CATEGORY_";
7238 Result +=
7240 Result += "_$_";
7241 Result += CategoryImplementation[i]->getNameAsString();
7242 Result += ",\n";
7244 Result += "};\n";
7249 Result += "__declspec(allocate(\".objc_nlcatlist$B\")) \n";
7250 Result += "static struct _category_t *_OBJC_LABEL_NONLAZY_CATEGORY_$[] = {\n\t";
7252 Result += "\t&_OBJC_$_CATEGORY_";
7253 Result +=
7255 Result += "_$_";
7256 Result += DefinedNonLazyCategories[i]->getNameAsString();
7257 Result += ",\n";
7259 Result += "};\n";
7263 void RewriteModernObjC::WriteImageInfo(std::string &Result) {
7265 Result += "__declspec(allocate(\".objc_imageinfo$B\")) \n";
7267 Result += "static struct IMAGE_INFO { unsigned version; unsigned flag; } ";
7269 Result += "_OBJC_IMAGE_INFO = { 0, 2 };\n";
7275 std::string &Result) {
7276 WriteModernMetadataDeclarations(Context, Result);
7307 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7313 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7323 RewriteObjCProtocolMetaData(I, Result);
7325 Write_protocol_list_initializer(Context, Result,
7333 Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
7338 Write_category_t(*this, Context, Result,
7351 void RewriteModernObjC::RewriteCategorySetupInitHook(std::string &Result) {
7355 Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
7356 Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
7357 Result += "static void *OBJC_CATEGORY_SETUP[] = {\n";
7362 Result += "\t(void *)&OBJC_CATEGORY_SETUP_$_";
7363 Result += ClassDecl->getName();
7364 Result += "_$_";
7365 Result += CatDecl->getName();
7366 Result += ",\n";
7368 Result += "};\n";
7379 std::string &Result) {
7389 Result += "\nstruct _objc_method {\n";
7390 Result += "\tSEL _cmd;\n";
7391 Result += "\tchar *method_types;\n";
7392 Result += "\tvoid *_imp;\n";
7393 Result += "};\n";
7407 Result += "\n";
7410 Result += "__declspec(allocate(\".inst_meth$B\")) ";
7412 Result += "__declspec(allocate(\".cls_meth$B\")) ";
7414 Result += "static struct {\n";
7415 Result += "\tstruct _objc_method_list *next_method;\n";
7416 Result += "\tint method_count;\n";
7417 Result += "\tstruct _objc_method method_list[";
7418 Result += utostr(NumMethods);
7419 Result += "];\n} _OBJC_";
7420 Result += prefix;
7421 Result += IsInstanceMethod ? "INSTANCE" : "CLASS";
7422 Result += "_METHODS_";
7423 Result += ClassName;
7424 Result += " __attribute__ ((used, section (\"__OBJC, __";
7425 Result += IsInstanceMethod ? "inst" : "cls";
7426 Result += "_meth\")))= ";
7427 Result += "{\n\t0, " + utostr(NumMethods) + "\n";
7429 Result += "\t,{{(SEL)\"";
7430 Result += (*MethodBegin)->getSelector().getAsString().c_str();
7433 Result += "\", \"";
7434 Result += MethodTypeString;
7435 Result += "\", (void *)";
7436 Result += MethodInternalNames[*MethodBegin];
7437 Result += "}\n";
7439 Result += "\t ,{(SEL)\"";
7440 Result += (*MethodBegin)->getSelector().getAsString().c_str();
7443 Result += "\", \"";
7444 Result += MethodTypeString;
7445 Result += "\", (void *)";
7446 Result += MethodInternalNames[*MethodBegin];
7447 Result += "}\n";
7449 Result += "\t }\n};\n";