• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/llvm-project/clang/lib/Frontend/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 std::string &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);
831 ObjCIvarDecl *IvarDecl, std::string &Result) {
832 Result += "OBJC_IVAR_$_";
833 Result += IDecl->getName();
834 Result += "$";
835 Result += IvarDecl->getName();
1971 std::string Result;
1972 ConvertSourceLocationToLineDirective(Catch->getBeginLoc(), Result);
1980 Result += "catch (_objc_exc_"; Result += IDecl->getNameAsString();
1981 Result += " *_"; Result += catchDecl->getNameAsString();
1982 Result += ")";
1983 ReplaceText(startLoc, rParenBuf-startBuf+1, Result);
1985 Result.clear();
1986 Result = "{ ";
1987 Result += IDecl->getNameAsString();
1988 Result += " *"; Result += catchDecl->getNameAsString();
1989 Result += " = ("; Result += IDecl->getNameAsString(); Result += "*)";
1990 Result += "_"; Result += catchDecl->getNameAsString();
1992 Result += "; ";
1994 ReplaceText(lBraceLoc, 1, Result);
3086 /// returnType - Result type of the method being synthesized.
3634 std::string &Result) {
3636 Result += "\t";
3642 return RewriteObjCFieldDeclType(ElemTy, Result);
3648 Result += "\n\tstruct ";
3650 Result += "\n\tunion ";
3654 Result += RD->getName();
3657 Result += " ";
3660 Result += " {\n";
3662 RewriteObjCFieldDecl(FD, Result);
3663 Result += "\t} ";
3670 Result += "\n\tenum ";
3671 Result += ED->getName();
3674 Result += " ";
3678 Result += " {\n";
3680 Result += "\t"; Result += EC->getName(); Result += " = ";
3682 Result += Val.toString(10);
3683 Result += ",\n";
3685 Result += "\t} ";
3690 Result += "\t";
3699 std::string &Result) {
3703 bool EleboratedType = RewriteObjCFieldDeclType(Type, Result);
3706 Result += Name;
3708 Result += " : "; Result += utostr(fieldDecl->getBitWidthValue(*Context));
3714 Result += "[";
3716 Result += utostr(Dim.getZExtValue());
3717 Result += "]";
3723 Result += ";\n";
3729 std::string &Result) {
3752 RewriteObjCFieldDeclType(Type, Result);
3753 Result += ";";
3842 std::string &Result) {
3844 Result += CDecl->getName();
3845 Result += "__GRBF_";
3847 Result += utostr(GroupNo);
3854 std::string &Result) {
3856 Result += CDecl->getName();
3857 Result += "__T_";
3859 Result += utostr(GroupNo);
3866 std::string &Result) {
3867 Result += "OBJC_IVAR_$_";
3868 ObjCIvarBitfieldGroupDecl(IV, Result);
3881 std::string &Result) {
3902 ReplaceText(LocStart, endBuf-startBuf, Result);
3910 RewriteLocallyDefinedNamedAggregates(IVars[i], Result);
3918 RewriteObjCFieldDeclType(QT, Result);
3919 Result += ";";
3924 Result += "\nstruct ";
3925 Result += CDecl->getNameAsString();
3926 Result += "_IMPL {\n";
3929 Result += "\tstruct "; Result += RCDecl->getNameAsString();
3930 Result += "_IMPL "; Result += RCDecl->getNameAsString();
3931 Result += "_IVARS;\n";
3937 Result += "\tstruct ";
3938 ObjCIvarBitfieldGroupType(IV, Result); Result += " ";
3939 ObjCIvarBitfieldGroupDecl(IV, Result); Result += ";\n";
3944 RewriteObjCFieldDecl(IVars[i], Result);
3947 Result += "};\n";
3949 ReplaceText(LocStart, endBuf-startBuf, Result);
3958 std::string &Result) {
3975 Result += "\n";
3977 Result += "__declspec(allocate(\".objc_ivar$B\")) ";
3978 Result += "extern \"C\" ";
3982 Result += "__declspec(dllimport) ";
3984 Result += "unsigned long ";
3986 ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
3990 WriteInternalIvarName(CDecl, IvarDecl, Result);
3991 Result += ";";
5816 std::string &Result) {
5819 Result += "static ";
5820 Result += "struct _protocol_t *";
5821 Result += "_OBJC_PROTOCOL_REFERENCE_$_";
5822 Result += PDecl->getNameAsString();
5823 Result += " = &";
5824 Result += "_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
5825 Result += ";\n";
6065 std::string &Result) {
6066 Result += "__OFFSETOFIVAR__(struct ";
6067 Result += ivar->getContainingInterface()->getNameAsString();
6069 Result += "_IMPL";
6070 Result += ", ";
6072 ObjCIvarBitfieldGroupDecl(ivar, Result);
6074 Result += ivar->getNameAsString();
6075 Result += ")";
6180 static void WriteModernMetadataDeclarations(ASTContext *Context, std::string &Result) {
6185 Result += "\nstruct _prop_t {\n";
6186 Result += "\tconst char *name;\n";
6187 Result += "\tconst char *attributes;\n";
6188 Result += "};\n";
6190 Result += "\nstruct _protocol_t;\n";
6192 Result += "\nstruct _objc_method {\n";
6193 Result += "\tstruct objc_selector * _cmd;\n";
6194 Result += "\tconst char *method_type;\n";
6195 Result += "\tvoid *_imp;\n";
6196 Result += "};\n";
6198 Result += "\nstruct _protocol_t {\n";
6199 Result += "\tvoid * isa; // NULL\n";
6200 Result += "\tconst char *protocol_name;\n";
6201 Result += "\tconst struct _protocol_list_t * protocol_list; // super protocols\n";
6202 Result += "\tconst struct method_list_t *instance_methods;\n";
6203 Result += "\tconst struct method_list_t *class_methods;\n";
6204 Result += "\tconst struct method_list_t *optionalInstanceMethods;\n";
6205 Result += "\tconst struct method_list_t *optionalClassMethods;\n";
6206 Result += "\tconst struct _prop_list_t * properties;\n";
6207 Result += "\tconst unsigned int size; // sizeof(struct _protocol_t)\n";
6208 Result += "\tconst unsigned int flags; // = 0\n";
6209 Result += "\tconst char ** extendedMethodTypes;\n";
6210 Result += "};\n";
6212 Result += "\nstruct _ivar_t {\n";
6213 Result += "\tunsigned long int *offset; // pointer to ivar offset location\n";
6214 Result += "\tconst char *name;\n";
6215 Result += "\tconst char *type;\n";
6216 Result += "\tunsigned int alignment;\n";
6217 Result += "\tunsigned int size;\n";
6218 Result += "};\n";
6220 Result += "\nstruct _class_ro_t {\n";
6221 Result += "\tunsigned int flags;\n";
6222 Result += "\tunsigned int instanceStart;\n";
6223 Result += "\tunsigned int instanceSize;\n";
6226 Result += "\tunsigned int reserved;\n";
6227 Result += "\tconst unsigned char *ivarLayout;\n";
6228 Result += "\tconst char *name;\n";
6229 Result += "\tconst struct _method_list_t *baseMethods;\n";
6230 Result += "\tconst struct _objc_protocol_list *baseProtocols;\n";
6231 Result += "\tconst struct _ivar_list_t *ivars;\n";
6232 Result += "\tconst unsigned char *weakIvarLayout;\n";
6233 Result += "\tconst struct _prop_list_t *properties;\n";
6234 Result += "};\n";
6236 Result += "\nstruct _class_t {\n";
6237 Result += "\tstruct _class_t *isa;\n";
6238 Result += "\tstruct _class_t *superclass;\n";
6239 Result += "\tvoid *cache;\n";
6240 Result += "\tvoid *vtable;\n";
6241 Result += "\tstruct _class_ro_t *ro;\n";
6242 Result += "};\n";
6244 Result += "\nstruct _category_t {\n";
6245 Result += "\tconst char *name;\n";
6246 Result += "\tstruct _class_t *cls;\n";
6247 Result += "\tconst struct _method_list_t *instance_methods;\n";
6248 Result += "\tconst struct _method_list_t *class_methods;\n";
6249 Result += "\tconst struct _protocol_list_t *protocols;\n";
6250 Result += "\tconst struct _prop_list_t *properties;\n";
6251 Result += "};\n";
6253 Result += "extern \"C\" __declspec(dllimport) struct objc_cache _objc_empty_cache;\n";
6254 Result += "#pragma warning(disable:4273)\n";
6258 static void Write_protocol_list_t_TypeDecl(std::string &Result,
6260 Result += "struct /*_protocol_list_t*/"; Result += " {\n";
6261 Result += "\tlong protocol_count; // Note, this is 32/64 bit\n";
6262 Result += "\tstruct _protocol_t *super_protocols[";
6263 Result += utostr(super_protocol_count); Result += "];\n";
6264 Result += "}";
6267 static void Write_method_list_t_TypeDecl(std::string &Result,
6269 Result += "struct /*_method_list_t*/"; Result += " {\n";
6270 Result += "\tunsigned int entsize; // sizeof(struct _objc_method)\n";
6271 Result += "\tunsigned int method_count;\n";
6272 Result += "\tstruct _objc_method method_list[";
6273 Result += utostr(method_count); Result += "];\n";
6274 Result += "}";
6277 static void Write__prop_list_t_TypeDecl(std::string &Result,
6279 Result += "struct /*_prop_list_t*/"; Result += " {\n";
6280 Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
6281 Result += "\tunsigned int count_of_properties;\n";
6282 Result += "\tstruct _prop_t prop_list[";
6283 Result += utostr(property_count); Result += "];\n";
6284 Result += "}";
6287 static void Write__ivar_list_t_TypeDecl(std::string &Result,
6289 Result += "struct /*_ivar_list_t*/"; Result += " {\n";
6290 Result += "\tunsigned int entsize; // sizeof(struct _prop_t)\n";
6291 Result += "\tunsigned int count;\n";
6292 Result += "\tstruct _ivar_t ivar_list[";
6293 Result += utostr(ivar_count); Result += "];\n";
6294 Result += "}";
6297 static void Write_protocol_list_initializer(ASTContext *Context, std::string &Result,
6302 Result += "\nstatic ";
6303 Write_protocol_list_t_TypeDecl(Result, SuperProtocols.size());
6304 Result += " "; Result += VarName;
6305 Result += ProtocolName;
6306 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6307 Result += "\t"; Result += utostr(SuperProtocols.size()); Result += ",\n";
6310 Result += "\t&"; Result += "_OBJC_PROTOCOL_";
6311 Result += SuperPD->getNameAsString();
6313 Result += "\n};\n";
6315 Result += ",\n";
6321 ASTContext *Context, std::string &Result,
6327 Result += "\nstatic ";
6328 Write_method_list_t_TypeDecl(Result, Methods.size());
6329 Result += " "; Result += VarName;
6330 Result += TopLevelDeclName;
6331 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6332 Result += "\t"; Result += "sizeof(_objc_method)"; Result += ",\n";
6333 Result += "\t"; Result += utostr(Methods.size()); Result += ",\n";
6337 Result += "\t{{(struct objc_selector *)\"";
6339 Result += "\t{(struct objc_selector *)\"";
6340 Result += (MD)->getSelector().getAsString(); Result += "\"";
6341 Result += ", ";
6343 Result += "\""; Result += MethodTypeString; Result += "\"";
6344 Result += ", ";
6346 Result += "0";
6348 Result += "(void *)";
6349 Result += RewriteObj.MethodInternalNames[MD];
6352 Result += "}}\n";
6354 Result += "},\n";
6356 Result += "};\n";
6361 ASTContext *Context, std::string &Result,
6367 Result += "\nstatic ";
6368 Write__prop_list_t_TypeDecl(Result, Properties.size());
6369 Result += " "; Result += VarName;
6370 Result += ProtocolName;
6371 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6372 Result += "\t"; Result += "sizeof(_prop_t)"; Result += ",\n";
6373 Result += "\t"; Result += utostr(Properties.size()); Result += ",\n";
6377 Result += "\t{{\"";
6379 Result += "\t{\"";
6380 Result += PropDecl->getName(); Result += "\",";
6385 Result += "\""; Result += QuotePropertyTypeString; Result += "\"";
6387 Result += "}}\n";
6389 Result += "},\n";
6391 Result += "};\n";
6409 static void Write__class_ro_t_initializer(ASTContext *Context, std::string &Result,
6419 Result += "\nstatic struct _class_ro_t ";
6420 Result += VarName; Result += ClassName;
6421 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6422 Result += "\t";
6423 Result += llvm::utostr(flags); Result += ", ";
6424 Result += InstanceStart; Result += ", ";
6425 Result += InstanceSize; Result += ", \n";
6426 Result += "\t";
6430 Result += "(unsigned int)0, \n\t";
6432 Result += "0, \n\t";
6433 Result += "\""; Result += ClassName; Result += "\",\n\t";
6436 Result += "(const struct _method_list_t *)&";
6438 Result += "_OBJC_$_CLASS_METHODS_";
6440 Result += "_OBJC_$_INSTANCE_METHODS_";
6441 Result += ClassName;
6442 Result += ",\n\t";
6445 Result += "0, \n\t";
6448 Result += "(const struct _objc_protocol_list *)&";
6449 Result += "_OBJC_CLASS_PROTOCOLS_$_"; Result += ClassName;
6450 Result += ",\n\t";
6453 Result += "0, \n\t";
6456 Result += "(const struct _ivar_list_t *)&";
6457 Result += "_OBJC_$_INSTANCE_VARIABLES_"; Result += ClassName;
6458 Result += ",\n\t";
6461 Result += "0, \n\t";
6464 Result += "0, \n\t";
6466 Result += "(const struct _prop_list_t *)&";
6467 Result += "_OBJC_$_PROP_LIST_"; Result += ClassName;
6468 Result += ",\n";
6471 Result += "0, \n";
6473 Result += "};\n";
6476 static void Write_class_t(ASTContext *Context, std::string &Result,
6492 Result += "\n";
6493 Result += "extern \"C\" ";
6495 Result += "__declspec(dllexport) ";
6497 Result += "__declspec(dllimport) ";
6499 Result += "struct _class_t OBJC_CLASS_$_";
6500 Result += CDecl->getNameAsString();
6501 Result += ";\n";
6506 Result += "\n";
6507 Result += "extern \"C\" ";
6509 Result += "__declspec(dllexport) ";
6511 Result += "__declspec(dllimport) ";
6513 Result += "struct _class_t ";
6514 Result += VarName;
6515 Result += SuperClass->getNameAsString();
6516 Result += ";\n";
6519 Result += "extern \"C\" ";
6521 Result += "__declspec(dllexport) ";
6523 Result += "__declspec(dllimport) ";
6525 Result += "struct _class_t ";
6526 Result += VarName;
6527 Result += RootClass->getNameAsString();
6528 Result += ";\n";
6532 Result += "\nextern \"C\" __declspec(dllexport) struct _class_t ";
6533 Result += VarName; Result += CDecl->getNameAsString();
6534 Result += " __attribute__ ((used, section (\"__DATA,__objc_data\"))) = {\n";
6535 Result += "\t";
6538 Result += "0, // &"; Result += VarName;
6539 Result += RootClass->getNameAsString();
6540 Result += ",\n\t";
6541 Result += "0, // &"; Result += VarName;
6542 Result += CDecl->getSuperClass()->getNameAsString();
6543 Result += ",\n\t";
6546 Result += "0, // &"; Result += VarName;
6547 Result += CDecl->getNameAsString();
6548 Result += ",\n\t";
6549 Result += "0, // &OBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6550 Result += ",\n\t";
6554 Result += "0, // &OBJC_METACLASS_$_";
6555 Result += CDecl->getNameAsString();
6556 Result += ",\n\t";
6558 Result += "0, // &"; Result += VarName;
6559 Result += CDecl->getSuperClass()->getNameAsString();
6560 Result += ",\n\t";
6563 Result += "0,\n\t";
6565 Result += "0, // (void *)&_objc_empty_cache,\n\t";
6566 Result += "0, // unused, was (void *)&_objc_empty_vtable,\n\t";
6568 Result += "&_OBJC_METACLASS_RO_$_";
6570 Result += "&_OBJC_CLASS_RO_$_";
6571 Result += CDecl->getNameAsString();
6572 Result += ",\n};\n";
6582 Result += "static void OBJC_CLASS_SETUP_$_";
6583 Result += CDecl->getNameAsString();
6584 Result += "(void ) {\n";
6585 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6586 Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
6587 Result += RootClass->getNameAsString(); Result += ";\n";
6589 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6590 Result += ".superclass = ";
6592 Result += "&OBJC_CLASS_$_";
6594 Result += "&OBJC_METACLASS_$_";
6596 Result += SuperClass->getNameAsString(); Result += ";\n";
6598 Result += "\tOBJC_METACLASS_$_"; Result += CDecl->getNameAsString();
6599 Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
6601 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6602 Result += ".isa = "; Result += "&OBJC_METACLASS_$_";
6603 Result += CDecl->getNameAsString(); Result += ";\n";
6606 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6607 Result += ".superclass = "; Result += "&OBJC_CLASS_$_";
6608 Result += SuperClass->getNameAsString(); Result += ";\n";
6611 Result += "\tOBJC_CLASS_$_"; Result += CDecl->getNameAsString();
6612 Result += ".cache = "; Result += "&_objc_empty_cache"; Result += ";\n";
6613 Result += "}\n";
6617 std::string &Result,
6628 Result += "\n";
6629 Result += "extern \"C\" ";
6631 Result += "__declspec(dllexport) ";
6633 Result += "__declspec(dllimport) ";
6635 Result += "struct _class_t ";
6636 Result += "OBJC_CLASS_$_"; Result += ClassName;
6637 Result += ";\n";
6639 Result += "\nstatic struct _category_t ";
6640 Result += "_OBJC_$_CATEGORY_";
6641 Result += ClassName; Result += "_$_"; Result += CatName;
6642 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
6643 Result += "{\n";
6644 Result += "\t\""; Result += ClassName; Result += "\",\n";
6645 Result += "\t0, // &"; Result += "OBJC_CLASS_$_"; Result += ClassName;
6646 Result += ",\n";
6648 Result += "\t(const struct _method_list_t *)&";
6649 Result += "_OBJC_$_CATEGORY_INSTANCE_METHODS_";
6650 Result += ClassName; Result += "_$_"; Result += CatName;
6651 Result += ",\n";
6654 Result += "\t0,\n";
6657 Result += "\t(const struct _method_list_t *)&";
6658 Result += "_OBJC_$_CATEGORY_CLASS_METHODS_";
6659 Result += ClassName; Result += "_$_"; Result += CatName;
6660 Result += ",\n";
6663 Result += "\t0,\n";
6666 Result += "\t(const struct _protocol_list_t *)&";
6667 Result += "_OBJC_CATEGORY_PROTOCOLS_$_";
6668 Result += ClassName; Result += "_$_"; Result += CatName;
6669 Result += ",\n";
6672 Result += "\t0,\n";
6675 Result += "\t(const struct _prop_list_t *)&"; Result += "_OBJC_$_PROP_LIST_";
6676 Result += ClassName; Result += "_$_"; Result += CatName;
6677 Result += ",\n";
6680 Result += "\t0,\n";
6682 Result += "};\n";
6685 Result += "static void OBJC_CATEGORY_SETUP_$_";
6686 Result += ClassDecl->getNameAsString();
6687 Result += "_$_";
6688 Result += CatName;
6689 Result += "(void ) {\n";
6690 Result += "\t_OBJC_$_CATEGORY_";
6691 Result += ClassDecl->getNameAsString();
6692 Result += "_$_";
6693 Result += CatName;
6694 Result += ".cls = "; Result += "&OBJC_CLASS_$_"; Result += ClassName;
6695 Result += ";\n}\n";
6699 ASTContext *Context, std::string &Result,
6706 Result += "\nstatic const char *";
6707 Result += VarName; Result += ProtocolName;
6708 Result += " [] __attribute__ ((used, section (\"__DATA,__objc_const\"))) = \n";
6709 Result += "{\n";
6716 Result += "\t\""; Result += QuoteMethodTypeString; Result += "\"";
6718 Result += "\n};\n";
6720 Result += ",\n";
6727 std::string &Result,
6741 Result += "\n";
6745 Result += "__declspec(allocate(\".objc_ivar$B\")) ";
6750 Result += "extern \"C\" unsigned long int ";
6752 Result += "extern \"C\" __declspec(dllexport) unsigned long int ";
6754 RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
6756 WriteInternalIvarName(CDecl, IvarDecl, Result);
6757 Result += " __attribute__ ((used, section (\"__DATA,__objc_ivar\")))";
6758 Result += " = ";
6759 RewriteObj.RewriteIvarOffsetComputation(IvarDecl, Result);
6760 Result += ";\n";
6769 ASTContext *Context, std::string &Result,
6774 Write_IvarOffsetVar(RewriteObj, Context, Result, OriginalIvars, CDecl);
6789 Result += "\nstatic ";
6790 Write__ivar_list_t_TypeDecl(Result, Ivars.size());
6791 Result += " "; Result += VarName;
6792 Result += CDecl->getNameAsString();
6793 Result += " __attribute__ ((used, section (\"__DATA,__objc_const\"))) = {\n";
6794 Result += "\t"; Result += "sizeof(_ivar_t)"; Result += ",\n";
6795 Result += "\t"; Result += utostr(Ivars.size()); Result += ",\n";
6799 Result += "\t{{";
6801 Result += "\t {";
6802 Result += "(unsigned long int *)&";
6804 RewriteObj.ObjCIvarBitfieldGroupOffset(IvarDecl, Result);
6806 WriteInternalIvarName(CDecl, IvarDecl, Result);
6807 Result += ", ";
6809 Result += "\"";
6811 RewriteObj.ObjCIvarBitfieldGroupDecl(Ivars[i], Result);
6813 Result += IvarDecl->getName();
6814 Result += "\", ";
6824 Result += "\""; Result += QuoteIvarTypeString; Result += "\", ";
6830 Result += llvm::utostr(Align); Result += ", ";
6832 Result += llvm::utostr(Size.getQuantity());
6834 Result += "}}\n";
6836 Result += "},\n";
6838 Result += "};\n";
6844 std::string &Result) {
6849 WriteModernMetadataDeclarations(Context, Result);
6856 RewriteObjCProtocolMetaData(I, Result);
6886 Write__extendedMethodTypes_initializer(*this, Context, Result,
6892 Write_protocol_list_initializer(Context, Result, SuperProtocols,
6896 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
6900 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
6904 Write_method_list_t_initializer(*this, Context, Result, OptInstanceMethods,
6908 Write_method_list_t_initializer(*this, Context, Result, OptClassMethods,
6915 Write_prop_list_t_initializer(*this, Context, Result, ProtocolProperties,
6921 Result += "\n";
6923 Result += "static ";
6924 Result += "struct _protocol_t _OBJC_PROTOCOL_";
6925 Result += PDecl->getNameAsString();
6926 Result += " __attribute__ ((used)) = {\n";
6927 Result += "\t0,\n"; // id is; is null
6928 Result += "\t\""; Result += PDecl->getNameAsString(); Result += "\",\n";
6930 Result += "\t(const struct _protocol_list_t *)&"; Result += "_OBJC_PROTOCOL_REFS_";
6931 Result += PDecl->getNameAsString(); Result += ",\n";
6934 Result += "\t0,\n";
6936 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_INSTANCE_METHODS_";
6937 Result += PDecl->getNameAsString(); Result += ",\n";
6940 Result += "\t0,\n";
6943 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_CLASS_METHODS_";
6944 Result += PDecl->getNameAsString(); Result += ",\n";
6947 Result += "\t0,\n";
6950 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_INSTANCE_METHODS_";
6951 Result += PDecl->getNameAsString(); Result += ",\n";
6954 Result += "\t0,\n";
6957 Result += "\t(const struct method_list_t *)&_OBJC_PROTOCOL_OPT_CLASS_METHODS_";
6958 Result += PDecl->getNameAsString(); Result += ",\n";
6961 Result += "\t0,\n";
6964 Result += "\t(const struct _prop_list_t *)&_OBJC_PROTOCOL_PROPERTIES_";
6965 Result += PDecl->getNameAsString(); Result += ",\n";
6968 Result += "\t0,\n";
6970 Result += "\t"; Result += "sizeof(_protocol_t)"; Result += ",\n";
6971 Result += "\t0,\n";
6974 Result += "\t(const char **)&"; Result += "_OBJC_PROTOCOL_METHOD_TYPES_";
6975 Result += PDecl->getNameAsString();
6976 Result += "\n};\n";
6979 Result += "\t0\n};\n";
6982 Result += "static ";
6983 Result += "struct _protocol_t *";
6984 Result += "_OBJC_LABEL_PROTOCOL_$_"; Result += PDecl->getNameAsString();
6985 Result += " = &_OBJC_PROTOCOL_"; Result += PDecl->getNameAsString();
6986 Result += ";\n";
7006 std::string &Result) {
7014 WriteModernMetadataDeclarations(Context, Result);
7025 Write__ivar_list_t_initializer(*this, Context, Result, IVars,
7052 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7058 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7072 RewriteObjCProtocolMetaData(*I, Result);
7075 Write_protocol_list_initializer(Context, Result,
7083 Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
7102 Write__class_ro_t_initializer(Context, Result, flags,
7141 Write__class_ro_t_initializer(Context, Result, flags,
7150 Write_class_t(Context, Result,
7154 Write_class_t(Context, Result,
7162 void RewriteModernObjC::RewriteClassSetupInitHook(std::string &Result) {
7166 Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
7167 Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
7168 Result += "static void *OBJC_CLASS_SETUP[] = {\n";
7172 Result += "\t(void *)&OBJC_CLASS_SETUP_$_";
7173 Result += CDecl->getName(); Result += ",\n";
7175 Result += "};\n";
7178 void RewriteModernObjC::RewriteMetaDataIntoBuffer(std::string &Result) {
7184 RewriteObjCClassMetaData(ClassImplementation[i], Result);
7186 RewriteClassSetupInitHook(Result);
7190 RewriteObjCCategoryImplDecl(CategoryImplementation[i], Result);
7192 RewriteCategorySetupInitHook(Result);
7196 Result += "__declspec(allocate(\".objc_classlist$B\")) ";
7197 Result += "static struct _class_t *L_OBJC_LABEL_CLASS_$ [";
7198 Result += llvm::utostr(ClsDefCount); Result += "]";
7199 Result +=
7203 Result += "\t&OBJC_CLASS_$_";
7204 Result += ClassImplementation[i]->getNameAsString();
7205 Result += ",\n";
7207 Result += "};\n";
7211 Result += "__declspec(allocate(\".objc_nlclslist$B\")) \n";
7212 Result += "static struct _class_t *_OBJC_LABEL_NONLAZY_CLASS_$[] = {\n\t";
7214 Result += "\t&OBJC_CLASS_$_"; Result += DefinedNonLazyClasses[i]->getNameAsString();
7215 Result += ",\n";
7217 Result += "};\n";
7223 Result += "__declspec(allocate(\".objc_catlist$B\")) ";
7224 Result += "static struct _category_t *L_OBJC_LABEL_CATEGORY_$ [";
7225 Result += llvm::utostr(CatDefCount); Result += "]";
7226 Result +=
7230 Result += "\t&_OBJC_$_CATEGORY_";
7231 Result +=
7233 Result += "_$_";
7234 Result += CategoryImplementation[i]->getNameAsString();
7235 Result += ",\n";
7237 Result += "};\n";
7242 Result += "__declspec(allocate(\".objc_nlcatlist$B\")) \n";
7243 Result += "static struct _category_t *_OBJC_LABEL_NONLAZY_CATEGORY_$[] = {\n\t";
7245 Result += "\t&_OBJC_$_CATEGORY_";
7246 Result +=
7248 Result += "_$_";
7249 Result += DefinedNonLazyCategories[i]->getNameAsString();
7250 Result += ",\n";
7252 Result += "};\n";
7256 void RewriteModernObjC::WriteImageInfo(std::string &Result) {
7258 Result += "__declspec(allocate(\".objc_imageinfo$B\")) \n";
7260 Result += "static struct IMAGE_INFO { unsigned version; unsigned flag; } ";
7262 Result += "_OBJC_IMAGE_INFO = { 0, 2 };\n";
7268 std::string &Result) {
7269 WriteModernMetadataDeclarations(Context, Result);
7300 Write_method_list_t_initializer(*this, Context, Result, InstanceMethods,
7306 Write_method_list_t_initializer(*this, Context, Result, ClassMethods,
7316 RewriteObjCProtocolMetaData(I, Result);
7318 Write_protocol_list_initializer(Context, Result,
7326 Write_prop_list_t_initializer(*this, Context, Result, ClassProperties,
7331 Write_category_t(*this, Context, Result,
7344 void RewriteModernObjC::RewriteCategorySetupInitHook(std::string &Result) {
7348 Result += "#pragma section(\".objc_inithooks$B\", long, read, write)\n";
7349 Result += "__declspec(allocate(\".objc_inithooks$B\")) ";
7350 Result += "static void *OBJC_CATEGORY_SETUP[] = {\n";
7355 Result += "\t(void *)&OBJC_CATEGORY_SETUP_$_";
7356 Result += ClassDecl->getName();
7357 Result += "_$_";
7358 Result += CatDecl->getName();
7359 Result += ",\n";
7361 Result += "};\n";
7372 std::string &Result) {
7382 Result += "\nstruct _objc_method {\n";
7383 Result += "\tSEL _cmd;\n";
7384 Result += "\tchar *method_types;\n";
7385 Result += "\tvoid *_imp;\n";
7386 Result += "};\n";
7400 Result += "\n";
7403 Result += "__declspec(allocate(\".inst_meth$B\")) ";
7405 Result += "__declspec(allocate(\".cls_meth$B\")) ";
7407 Result += "static struct {\n";
7408 Result += "\tstruct _objc_method_list *next_method;\n";
7409 Result += "\tint method_count;\n";
7410 Result += "\tstruct _objc_method method_list[";
7411 Result += utostr(NumMethods);
7412 Result += "];\n} _OBJC_";
7413 Result += prefix;
7414 Result += IsInstanceMethod ? "INSTANCE" : "CLASS";
7415 Result += "_METHODS_";
7416 Result += ClassName;
7417 Result += " __attribute__ ((used, section (\"__OBJC, __";
7418 Result += IsInstanceMethod ? "inst" : "cls";
7419 Result += "_meth\")))= ";
7420 Result += "{\n\t0, " + utostr(NumMethods) + "\n";
7422 Result += "\t,{{(SEL)\"";
7423 Result += (*MethodBegin)->getSelector().getAsString().c_str();
7426 Result += "\", \"";
7427 Result += MethodTypeString;
7428 Result += "\", (void *)";
7429 Result += MethodInternalNames[*MethodBegin];
7430 Result += "}\n";
7432 Result += "\t ,{(SEL)\"";
7433 Result += (*MethodBegin)->getSelector().getAsString().c_str();
7436 Result += "\", \"";
7437 Result += MethodTypeString;
7438 Result += "\", (void *)";
7439 Result += MethodInternalNames[*MethodBegin];
7440 Result += "}\n";
7442 Result += "\t }\n};\n";