[cfe-commits] r154534 - in /cfe/trunk: lib/Rewrite/RewriteModernObjC.cpp test/Rewriter/rewrite-modern-ivars-2.mm
Fariborz Jahanian
fjahanian at apple.com
Wed Apr 11 14:12:36 PDT 2012
Author: fjahanian
Date: Wed Apr 11 16:12:36 2012
New Revision: 154534
URL: http://llvm.org/viewvc/llvm-project?rev=154534&view=rev
Log:
modern objective-c translator. Fixes a translation bug when
first ivar in the list is a bitfield.
// rdar://11229770
Modified:
cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
cfe/trunk/test/Rewriter/rewrite-modern-ivars-2.mm
Modified: cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp?rev=154534&r1=154533&r2=154534&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteModernObjC.cpp Wed Apr 11 16:12:36 2012
@@ -6416,7 +6416,8 @@
}
}
-static void Write_IvarOffsetVar(ASTContext *Context,
+static void Write_IvarOffsetVar(RewriteModernObjC &RewriteObj,
+ ASTContext *Context,
std::string &Result,
ArrayRef<ObjCIvarDecl *> Ivars,
ObjCInterfaceDecl *CDecl) {
@@ -6446,17 +6447,8 @@
WriteInternalIvarName(CDecl, IvarDecl, Result);
Result += " __attribute__ ((used, section (\"__DATA,__objc_ivar\")))";
Result += " = ";
- if (IvarDecl->isBitField()) {
- // FIXME: The hack below doesn't work for bitfields. For now, we simply
- // place all bitfields at offset 0.
- Result += "0;\n";
- }
- else {
- Result += "__OFFSETOFIVAR__(struct ";
- Result += CDecl->getNameAsString();
- Result += "_IMPL, ";
- Result += IvarDecl->getName(); Result += ");\n";
- }
+ RewriteObj.RewriteIvarOffsetComputation(IvarDecl, Result);
+ Result += ";\n";
}
}
@@ -6466,7 +6458,7 @@
StringRef VarName,
ObjCInterfaceDecl *CDecl) {
if (Ivars.size() > 0) {
- Write_IvarOffsetVar(Context, Result, Ivars, CDecl);
+ Write_IvarOffsetVar(RewriteObj, Context, Result, Ivars, CDecl);
Result += "\nstatic ";
Write__ivar_list_t_TypeDecl(Result, Ivars.size());
@@ -6875,11 +6867,7 @@
ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
if (IVD) {
- InstanceStart += "__OFFSETOFIVAR__(struct ";
- InstanceStart += CDecl->getNameAsString();
- InstanceStart += "_IMPL, ";
- InstanceStart += IVD->getNameAsString();
- InstanceStart += ")";
+ RewriteIvarOffsetComputation(IVD, InstanceStart);
}
else
InstanceStart = InstanceSize;
Modified: cfe/trunk/test/Rewriter/rewrite-modern-ivars-2.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-modern-ivars-2.mm?rev=154534&r1=154533&r2=154534&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-modern-ivars-2.mm (original)
+++ cfe/trunk/test/Rewriter/rewrite-modern-ivars-2.mm Wed Apr 11 16:12:36 2012
@@ -71,3 +71,31 @@
@implementation NSFileLocationComponent @end
+// rdar://11229770
+
+ at interface Foo {
+ int bar:26;
+}
+ at end
+
+ at implementation Foo
+ at end
+
+ at interface Foo1 {
+ int bar:26;
+ int bar2:4;
+}
+ at end
+
+ at implementation Foo1
+ at end
+
+ at interface Foo3 {
+ int foo;
+ int bar:26;
+}
+ at end
+
+ at implementation Foo3
+ at end
+
More information about the cfe-commits
mailing list