]> granicus.if.org Git - clang/commitdiff
fix a crash compiling code with its own definition of objc_assign_weak.
authorChris Lattner <sabre@nondot.org>
Fri, 17 Apr 2009 22:12:36 +0000 (22:12 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 17 Apr 2009 22:12:36 +0000 (22:12 +0000)
rdar://6800430

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69392 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/runtime-fns.m

index 5bb48e4e94809c321f63dbd48fd53199a5b9f207..1f12d85a9f622e836cdf071eabcd5e35b46a4fd5 100644 (file)
@@ -92,7 +92,14 @@ public:
   llvm::Constant *GcReadWeakFn;
   
   /// GcAssignWeakFn -- LLVM objc_assign_weak function.
-  llvm::Constant *GcAssignWeakFn;
+  llvm::Constant *getGcAssignWeakFn() {
+    // id objc_assign_weak (id, id *)
+    std::vector<const llvm::Type*> Args(1, ObjectPtrTy);
+    Args.push_back(ObjectPtrTy->getPointerTo());
+    llvm::FunctionType *FTy =
+      llvm::FunctionType::get(ObjectPtrTy, Args, false);
+    return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
+  }
   
   /// GcAssignGlobalFn -- LLVM objc_assign_global function.
   llvm::Constant *GcAssignGlobalFn;
@@ -2282,7 +2289,7 @@ void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
   }
   src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
   dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
-  CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
+  CGF.Builder.CreateCall2(ObjCTypes.getGcAssignWeakFn(),
                           src, dst, "weakassign");
   return;
 }
@@ -3278,13 +3285,12 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
   FTy = Types.GetFunctionType(Types.getFunctionInfo(IdType, Params), false);
   GcReadWeakFn = CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
 
-  // id objc_assign_weak (id, id *)
+  // id objc_assign_global (id, id *)
   Params.clear();
   Params.push_back(IdType);
   Params.push_back(Ctx.getPointerType(IdType));
   
   FTy = Types.GetFunctionType(Types.getFunctionInfo(IdType, Params), false);
-  GcAssignWeakFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
   GcAssignGlobalFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
   GcAssignIvarFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
   GcAssignStrongCastFn = 
@@ -5248,7 +5254,7 @@ void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
   }
   src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
   dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
-  CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
+  CGF.Builder.CreateCall2(ObjCTypes.getGcAssignWeakFn(),
                           src, dst, "weakassign");
   return;
 }
index c53b0a32133dd43936b667421d44b1c7d4476569..0d8570799902068f4add890008a7447f66a83475 100644 (file)
@@ -25,4 +25,9 @@ void f0(id x) {
 id objc_msgSend(int x) {
   return 0;
 }
+
+// rdar://6800430
+void objc_assign_weak(id value, id *location) {
+}
+
 #endif