]> granicus.if.org Git - clang/commitdiff
Simplify previous commit.
authorSteve Naroff <snaroff@apple.com>
Tue, 2 Dec 2008 16:05:55 +0000 (16:05 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 2 Dec 2008 16:05:55 +0000 (16:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60416 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteObjC.cpp

index 7f55d793d7c73cc237db6006614064a48e8f3f72..68ba314c11612e6c400efd49e9fe53b6f69d0d42 100644 (file)
@@ -609,19 +609,19 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID) {
     return; // FIXME: is this correct?
     
   // Generate the 'getter' function.
-  std::string Getr;
   ObjCPropertyDecl *PD = PID->getPropertyDecl();
-
-  RewriteObjCMethodDecl(PD->getGetterMethodDecl(), Getr);
   ObjCInterfaceDecl *ClassDecl = PD->getGetterMethodDecl()->getClassInterface();
-
-  Getr += "{ ";
   ObjCIvarDecl *OID = PID->getPropertyIvarDecl();
-  if (OID) {
-    // Synthesize an explicit cast to gain access to the ivar.
-    Getr += "return " + getIvarAccessString(ClassDecl, OID);
-    Getr += "; }";
-  } 
+  
+  if (!OID)
+    return;
+    
+  std::string Getr;
+  RewriteObjCMethodDecl(PD->getGetterMethodDecl(), Getr);
+  Getr += "{ ";
+  // Synthesize an explicit cast to gain access to the ivar.
+  Getr += "return " + getIvarAccessString(ClassDecl, OID);
+  Getr += "; }";
   InsertText(onePastSemiLoc, Getr.c_str(), Getr.size());
   
   if (PD->isReadOnly())
@@ -630,14 +630,11 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID) {
   // Generate the 'setter' function.
   std::string Setr;
   RewriteObjCMethodDecl(PD->getSetterMethodDecl(), Setr);
-  
   Setr += "{ ";
-  if (OID) {
-    // Synthesize an explicit cast to initialize the ivar.
-    Setr += getIvarAccessString(ClassDecl, OID) + " = ";
-    Setr += OID->getNameAsCString();
-    Setr += "; }";
-  } 
+  // Synthesize an explicit cast to initialize the ivar.
+  Setr += getIvarAccessString(ClassDecl, OID) + " = ";
+  Setr += OID->getNameAsCString();
+  Setr += "; }";
   InsertText(onePastSemiLoc, Setr.c_str(), Setr.size());
 }