[cfe-commits] r147750 - in /cfe/trunk/lib/CodeGen: CGObjC.cpp CodeGenModule.h

Fariborz Jahanian fjahanian at apple.com
Sun Jan 8 11:13:24 PST 2012


Author: fjahanian
Date: Sun Jan  8 13:13:23 2012
New Revision: 147750

URL: http://llvm.org/viewvc/llvm-project?rev=147750&view=rev
Log:
objc++: more atomic property api code for
c++ object properties. wip.

Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=147750&r1=147749&r2=147750&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Sun Jan  8 13:13:23 2012
@@ -2549,18 +2549,22 @@
   if ((!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic))
       || /* temporary */ true) 
     return 0;
+  llvm::Constant * HelperFn = 0;
   if (forSetter) {
     if (hasTrivialSetExpr(PID))
       return 0;
+    assert(PID->getSetterCXXAssignment() && "SetterCXXAssignment - null");
+    if ((HelperFn = CGM.getAtomicSetterHelperFnMap(Ty)))
+      return HelperFn;
   }
-  else 
+  else  {
     if (hasTrivialGetExpr(PID))
       return 0;
-  llvm::Constant * HelperFn = CGM.getAtomicHelperFnMap(Ty);
-  if (HelperFn)
-    return HelperFn;
+    assert(PID->getGetterCXXConstructor() && "getGetterCXXConstructor - null");
+    if ((HelperFn = CGM.getAtomicGetterHelperFnMap(Ty)))
+      return HelperFn;
+  }
     
-  assert(PID->getSetterCXXAssignment() && "SetterCXXAssignment - null");
   
   ASTContext &C = getContext();
   IdentifierInfo *II
@@ -2615,7 +2619,8 @@
                                     VK_LValue, OK_Ordinary, SourceLocation());
   
   Expr *Args[2] = { DST, SRC };
-  CallExpr *CalleeExp = cast<CallExpr>(PID->getSetterCXXAssignment());
+  CallExpr *CalleeExp = forSetter ? cast<CallExpr>(PID->getSetterCXXAssignment())
+                                  : cast<CallExpr>(PID->getGetterCXXConstructor());
   CXXOperatorCallExpr *TheCall =
     new (C) CXXOperatorCallExpr(C, OO_Equal, CalleeExp->getCallee(),
                                 Args, 2, DestTy->getPointeeType(), 
@@ -2625,7 +2630,10 @@
 
   FinishFunction();
   HelperFn = llvm::ConstantExpr::getBitCast(Fn, VoidPtrTy);
-  CGM.setAtomicHelperFnMap(Ty, HelperFn);
+  if (forSetter)
+    CGM.setAtomicSetterHelperFnMap(Ty, HelperFn);
+  else
+    CGM.setAtomicGetterHelperFnMap(Ty, HelperFn);
   return HelperFn;
   
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=147750&r1=147749&r2=147750&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Sun Jan  8 13:13:23 2012
@@ -277,7 +277,8 @@
   llvm::StringMap<llvm::GlobalVariable*> ConstantStringMap;
   llvm::DenseMap<const Decl*, llvm::Value*> StaticLocalDeclMap;
   
-  llvm::DenseMap<QualType, llvm::Constant *> AtomicHelperFnMap;
+  llvm::DenseMap<QualType, llvm::Constant *> AtomicSetterHelperFnMap;
+  llvm::DenseMap<QualType, llvm::Constant *> AtomicGetterHelperFnMap;
 
   /// CXXGlobalInits - Global variables with initializers that need to run
   /// before main.
@@ -400,12 +401,20 @@
     StaticLocalDeclMap[D] = GV;
   }
 
-  llvm::Constant *getAtomicHelperFnMap(QualType Ty) {
-    return AtomicHelperFnMap[Ty];
+  llvm::Constant *getAtomicSetterHelperFnMap(QualType Ty) {
+    return AtomicSetterHelperFnMap[Ty];
   }
-  void setAtomicHelperFnMap(QualType Ty,
+  void setAtomicSetterHelperFnMap(QualType Ty,
                             llvm::Constant *Fn) {
-    AtomicHelperFnMap[Ty] = Fn;
+    AtomicSetterHelperFnMap[Ty] = Fn;
+  }
+
+  llvm::Constant *getAtomicGetterHelperFnMap(QualType Ty) {
+    return AtomicGetterHelperFnMap[Ty];
+  }
+  void setAtomicGetterHelperFnMap(QualType Ty,
+                            llvm::Constant *Fn) {
+    AtomicGetterHelperFnMap[Ty] = Fn;
   }
 
   CGDebugInfo *getModuleDebugInfo() { return DebugInfo; }





More information about the cfe-commits mailing list