aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-03-11 00:12:29 +0000
committerSteve Naroff <snaroff@apple.com>2008-03-11 00:12:29 +0000
commit946a693aea83123f4039012c3bca7bc70800018b (patch)
tree826d0148afe01a5159eab76cd542c9f62cd6fd43 /Driver/RewriteTest.cpp
parentba9ac4e5b86842216a0a0eef5886d41e0d7fed0e (diff)
Generate meta-data in a C++ compatible way (remove 2 dependencies on C "flexible array member" idiom and perform some extra casts).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index c9779a4547..dbb3ff51bb 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -2222,21 +2222,23 @@ void RewriteTest::RewriteObjCMethodsMetaData(instmeth_iterator MethodBegin,
Result += "\tvoid *_imp;\n";
Result += "};\n";
- /* struct _objc_method_list {
- struct _objc_method_list *next_method;
- int method_count;
- struct _objc_method method_list[];
- }
- */
- Result += "\nstruct _objc_method_list {\n";
- Result += "\tstruct _objc_method_list *next_method;\n";
- Result += "\tint method_count;\n";
- Result += "\tstruct _objc_method method_list[];\n};\n";
objc_impl_method = true;
}
// Build _objc_method_list for class's methods if needed
- Result += "\nstatic struct _objc_method_list _OBJC_";
+
+ /* struct {
+ struct _objc_method_list *next_method;
+ int method_count;
+ struct _objc_method method_list[];
+ }
+ */
+ Result += "\nstatic struct {\n";
+ Result += "\tstruct _objc_method_list *next_method;\n";
+ Result += "\tint method_count;\n";
+ Result += "\tstruct _objc_method method_list[";
+ Result += utostr(MethodEnd-MethodBegin);
+ Result += "];\n} _OBJC_";
Result += prefix;
Result += IsInstanceMethod ? "INSTANCE" : "CLASS";
Result += "_METHODS_";
@@ -2252,7 +2254,7 @@ void RewriteTest::RewriteObjCMethodsMetaData(instmeth_iterator MethodBegin,
Context->getObjCEncodingForMethodDecl(*MethodBegin, MethodTypeString);
Result += "\", \"";
Result += MethodTypeString;
- Result += "\", ";
+ Result += "\", (void *)";
Result += MethodInternalNames[*MethodBegin];
Result += "}\n";
for (++MethodBegin; MethodBegin != MethodEnd; ++MethodBegin) {
@@ -2262,7 +2264,7 @@ void RewriteTest::RewriteObjCMethodsMetaData(instmeth_iterator MethodBegin,
Context->getObjCEncodingForMethodDecl(*MethodBegin, MethodTypeString);
Result += "\", \"";
Result += MethodTypeString;
- Result += "\", ";
+ Result += "\", (void *)";
Result += MethodInternalNames[*MethodBegin];
Result += "}\n";
}
@@ -2579,18 +2581,19 @@ void RewriteTest::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
Result += "\tint ivar_offset;\n";
Result += "};\n";
- /* struct _objc_ivar_list {
- int ivar_count;
- struct _objc_ivar ivar_list[];
- };
- */
- Result += "\nstruct _objc_ivar_list {\n";
- Result += "\tint ivar_count;\n";
- Result += "\tstruct _objc_ivar ivar_list[];\n};\n";
objc_ivar = true;
}
- Result += "\nstatic struct _objc_ivar_list _OBJC_INSTANCE_VARIABLES_";
+ /* struct {
+ int ivar_count;
+ struct _objc_ivar ivar_list[nIvars];
+ };
+ */
+ Result += "\nstatic struct {\n";
+ Result += "\tint ivar_count;\n";
+ Result += "\tstruct _objc_ivar ivar_list[";
+ Result += utostr(NumIvars);
+ Result += "];\n} _OBJC_INSTANCE_VARIABLES_";
Result += IDecl->getName();
Result += " __attribute__ ((section (\"__OBJC, __instance_vars\")))= "
"{\n\t";
@@ -2765,7 +2768,7 @@ void RewriteTest::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
else
Result += ",0";
if (IDecl->getNumInstanceMethods() > 0) {
- Result += ", &_OBJC_INSTANCE_METHODS_";
+ Result += ", (struct _objc_method_list *)&_OBJC_INSTANCE_METHODS_";
Result += CDecl->getName();
Result += ", 0\n\t";
}