[cfe-commits] r60426 - /cfe/trunk/Driver/RewriteObjC.cpp
Steve Naroff
snaroff at apple.com
Tue Dec 2 09:36:46 PST 2008
Author: snaroff
Date: Tue Dec 2 11:36:43 2008
New Revision: 60426
URL: http://llvm.org/viewvc/llvm-project?rev=60426&view=rev
Log:
Make sure synthesized properties get inserted into the classes/categories meta data.
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=60426&r1=60425&r2=60426&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Tue Dec 2 11:36:43 2008
@@ -169,7 +169,9 @@
void RewriteInclude();
void RewriteTabs();
void RewriteForwardClassDecl(ObjCClassDecl *Dcl);
- void RewritePropertyImplDecl(ObjCPropertyImplDecl *PID);
+ void RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
+ ObjCImplementationDecl *IMD,
+ ObjCCategoryImplDecl *CID);
void RewriteInterfaceDecl(ObjCInterfaceDecl *Dcl);
void RewriteImplementationDecl(NamedDecl *Dcl);
void RewriteObjCMethodDecl(ObjCMethodDecl *MDecl, std::string &ResultStr);
@@ -596,7 +598,9 @@
return S;
}
-void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID) {
+void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
+ ObjCImplementationDecl *IMD,
+ ObjCCategoryImplDecl *CID) {
SourceLocation startLoc = PID->getLocStart();
InsertText(startLoc, "// ", 3);
const char *startBuf = SM->getCharacterData(startLoc);
@@ -623,6 +627,15 @@
Getr += "return " + getIvarAccessString(ClassDecl, OID);
Getr += "; }";
InsertText(onePastSemiLoc, Getr.c_str(), Getr.size());
+
+ // Add the rewritten getter to trigger meta data generation. An alternate, and
+ // possibly cleaner approach is to hack RewriteObjCMethodsMetaData() to deal
+ // with properties explicitly. The following addInstanceMethod() required far
+ // less code change (and actually models what the rewriter is doing).
+ if (IMD)
+ IMD->addInstanceMethod(PD->getGetterMethodDecl());
+ else
+ CID->addInstanceMethod(PD->getGetterMethodDecl());
if (PD->isReadOnly())
return;
@@ -636,6 +649,12 @@
Setr += OID->getNameAsCString();
Setr += "; }";
InsertText(onePastSemiLoc, Setr.c_str(), Setr.size());
+
+ // Add the rewritten setter to trigger meta data generation.
+ if (IMD)
+ IMD->addInstanceMethod(PD->getSetterMethodDecl());
+ else
+ CID->addInstanceMethod(PD->getSetterMethodDecl());
}
void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) {
@@ -919,7 +938,7 @@
for (ObjCCategoryImplDecl::propimpl_iterator
I = IMD ? IMD->propimpl_begin() : CID->propimpl_begin(),
E = IMD ? IMD->propimpl_end() : CID->propimpl_end(); I != E; ++I) {
- RewritePropertyImplDecl(*I);
+ RewritePropertyImplDecl(*I, IMD, CID);
}
if (IMD)
More information about the cfe-commits
mailing list