This patch allows clang to generate code for declared properties on the GNU runtime.  As with @synchronized, this requires some extra functions that are included with other libraries (not with the GNU runtime itself) and so will cause linker errors when these are not present.
Patch by David Chisnall.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72079 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp
index 1617e0b..c351fa2 100644
--- a/lib/CodeGen/CGObjCGNU.cpp
+++ b/lib/CodeGen/CGObjCGNU.cpp
@@ -1130,11 +1130,37 @@
 }
 
 llvm::Function *CGObjCGNU::GetPropertyGetFunction() {
-  return 0;
+	std::vector<const llvm::Type*> Params;
+	const llvm::Type *BoolTy =
+		CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
+	Params.push_back(IdTy);
+	Params.push_back(SelectorTy);
+	// FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
+	Params.push_back(LongTy);
+	Params.push_back(BoolTy);
+	// void objc_getProperty (id, SEL, ptrdiff_t, bool)
+	const llvm::FunctionType *FTy =
+		llvm::FunctionType::get(IdTy, Params, false);
+	return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
+				"objc_getProperty"));
 }
 
 llvm::Function *CGObjCGNU::GetPropertySetFunction() {
-  return 0;
+	std::vector<const llvm::Type*> Params;
+	const llvm::Type *BoolTy =
+		CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
+	Params.push_back(IdTy);
+	Params.push_back(SelectorTy);
+	// FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
+	Params.push_back(LongTy);
+	Params.push_back(IdTy);
+	Params.push_back(BoolTy);
+	Params.push_back(BoolTy);
+	// void objc_setProperty (id, SEL, ptrdiff_t, id, bool, bool)
+	const llvm::FunctionType *FTy =
+		llvm::FunctionType::get(llvm::Type::VoidTy, Params, false);
+	return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
+				"objc_setProperty"));
 }
 
 llvm::Function *CGObjCGNU::EnumerationMutationFunction() {