[cfe-commits] r72079 - /cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Fariborz Jahanian fjahanian at apple.com
Mon May 18 17:28:45 PDT 2009


Author: fjahanian
Date: Mon May 18 19:28:43 2009
New Revision: 72079

URL: http://llvm.org/viewvc/llvm-project?rev=72079&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=72079&r1=72078&r2=72079&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Mon May 18 19:28:43 2009
@@ -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() {





More information about the cfe-commits mailing list