]> granicus.if.org Git - clang/commitdiff
Refactored RewriteObjcMethodsMetaData to better rewrite
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 25 Oct 2007 00:14:44 +0000 (00:14 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 25 Oct 2007 00:14:44 +0000 (00:14 +0000)
instance/class methods metadata.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43320 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteTest.cpp

index 66e22037260d795c1cb239aa27d906402efe45f9..17fd0473fce6ec89d4c551734350595061e5b3a8 100644 (file)
@@ -68,8 +68,8 @@ namespace {
     
     void RewriteObjcMethodsMetaData(ObjcMethodDecl **Methods,
                                     int NumMethods,
+                                    bool IsInstanceMethod,
                                     const char *prefix,
-                                    const char *MethodKind,
                                     const char *ClassName);
     
     void RewriteObjcProtocolsMetaData(ObjcProtocolDecl **Protocols,
@@ -358,8 +358,8 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
 /// class methods.
 void RewriteTest::RewriteObjcMethodsMetaData(ObjcMethodDecl **Methods,
                                              int NumMethods,
+                                             bool IsInstanceMethod,
                                              const char *prefix,
-                                             const char *MethodKind,
                                              const char *ClassName) {
   static bool objc_impl_method = false;
   if (NumMethods > 0 && !objc_impl_method) {
@@ -389,8 +389,9 @@ void RewriteTest::RewriteObjcMethodsMetaData(ObjcMethodDecl **Methods,
     printf("\tint method_count;\n");
     printf("\tstruct _objc_method method_list[%d];\n", NumMethods);
     printf("} _OBJC_%s%s_METHODS_%s "
-           "__attribute__ ((section (\"__OBJC, __inst_meth\")))= "
-           "{\n\t0, %d\n", prefix, MethodKind, ClassName, NumMethods);
+           "__attribute__ ((section (\"__OBJC, __%s_meth\")))= "
+           "{\n\t0, %d\n", prefix, IsInstanceMethod ? "INSTANCE" : "CLASS", 
+           ClassName, IsInstanceMethod ? "inst" : "cls", NumMethods);
     for (int i = 0; i < NumMethods; i++)
       // TODO: 1) method selector name may hav to go into their own section
       // 2) encode method types for use here (which may have to go into 
@@ -547,12 +548,14 @@ void RewriteTest::RewriteObjcCategoryImplDecl(ObjcCategoryImplDecl *IDecl) {
   // Build _objc_method_list for class's instance methods if needed
   RewriteObjcMethodsMetaData(IDecl->getInstanceMethods(),
                              IDecl->getNumInstanceMethods(),
-                             "CATEGORY_", "INSTANCE", FullCategoryName);
+                             true,
+                             "CATEGORY_", FullCategoryName);
   
   // Build _objc_method_list for class's class methods if needed
   RewriteObjcMethodsMetaData(IDecl->getClassMethods(),
                              IDecl->getNumClassMethods(),
-                             "CATEGORY_", "CLASS", FullCategoryName);
+                             false,
+                             "CATEGORY_", FullCategoryName);
   
   // Protocols referenced in class declaration?
   RewriteObjcProtocolsMetaData(CDecl->getReferencedProtocols(),
@@ -666,12 +669,14 @@ void RewriteTest::RewriteObjcClassMetaData(ObjcImplementationDecl *IDecl) {
   // Build _objc_method_list for class's instance methods if needed
   RewriteObjcMethodsMetaData(IDecl->getInstanceMethods(), 
                              IDecl->getNumInstanceMethods(), 
-                             "", "INSTANCE", IDecl->getName());
+                             true,
+                             "", IDecl->getName());
   
   // Build _objc_method_list for class's class methods if needed
   RewriteObjcMethodsMetaData(IDecl->getClassMethods(), 
-                             IDecl->getNumClassMethods(), 
-                             "", "CLASS", IDecl->getName());
+                             IDecl->getNumClassMethods(),
+                             false,
+                             "", IDecl->getName());
     
   // Protocols referenced in class declaration?
   RewriteObjcProtocolsMetaData(CDecl->getReferencedProtocols(),